r14471: Convert installheader script to perl
[kai/samba.git] / source4 / script / installheader.pl
1 #!/usr/bin/perl
2 use strict;
3 use File::Basename;
4
5 my $includedir = shift;
6
7 sub install_header($$)
8 {
9         my ($src,$dst) = @_;
10
11         open(IN, "<$src");
12         open(OUT, ">$dst");
13
14         while (<IN>) {
15                 print OUT $_;
16         }
17
18         close(OUT);
19         close(IN);
20 }
21
22 foreach my $p (@ARGV)
23 {
24  my $p2 = basename($p);
25  print "Installing $p as $includedir/$p2\n";
26
27  if ( -f "$includedir/$p2" ) {
28    unlink("$includedir/$p2.old");
29    rename("$includedir/$p2", "$includedir/$p2.old");
30  }
31
32  install_header($p,"$includedir/$p2");
33 }
34
35 print <<EOF;
36 ======================================================================
37 The headers are installed. You may restore the old headers (if there
38 were any) using the command "make revert". You may uninstall the headers
39 using the command "make uninstallheader" or "make uninstall" to uninstall
40 binaries, man pages and shell scripts.
41 ======================================================================
42 EOF
43
44 exit 0;