r14471: Convert installheader script to perl
authorJelmer Vernooij <jelmer@samba.org>
Thu, 16 Mar 2006 13:04:28 +0000 (13:04 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:57:30 +0000 (13:57 -0500)
(This used to be commit c6a478a1af38cad5622d3c3c53a7a99f9770b169)

source4/main.mk
source4/script/installheader.pl [new file with mode: 0755]
source4/script/installheader.sh [deleted file]

index eceb90342ae0f25b49e73eae357e338ea3087359..429b326f8b9101a0ea2a3c69012f9a525257a66c 100644 (file)
@@ -128,7 +128,7 @@ installlib: libraries installdirs
        @$(SHELL) $(srcdir)/script/installlib.sh $(DESTDIR)$(LIBDIR) $(STATIC_LIBS)
 
 installheader: headers installdirs
-       @$(SHELL) $(srcdir)/script/installheader.sh $(DESTDIR)$(INCLUDEDIR) $(PUBLIC_HEADERS) $(DEFAULT_HEADERS)
+       @$(PERL) $(srcdir)/script/installheader.pl $(DESTDIR)$(INCLUDEDIR) $(PUBLIC_HEADERS) $(DEFAULT_HEADERS)
 
 installdat: installdirs
        @$(SHELL) $(srcdir)/script/installdat.sh $(DESTDIR)$(DATADIR) $(srcdir)
diff --git a/source4/script/installheader.pl b/source4/script/installheader.pl
new file mode 100755 (executable)
index 0000000..1af05f3
--- /dev/null
@@ -0,0 +1,44 @@
+#!/usr/bin/perl
+use strict;
+use File::Basename;
+
+my $includedir = shift;
+
+sub install_header($$)
+{
+       my ($src,$dst) = @_;
+
+       open(IN, "<$src");
+       open(OUT, ">$dst");
+
+       while (<IN>) {
+               print OUT $_;
+       }
+
+       close(OUT);
+       close(IN);
+}
+
+foreach my $p (@ARGV)
+{
+ my $p2 = basename($p);
+ print "Installing $p as $includedir/$p2\n";
+
+ if ( -f "$includedir/$p2" ) {
+   unlink("$includedir/$p2.old");
+   rename("$includedir/$p2", "$includedir/$p2.old");
+ }
+
+ install_header($p,"$includedir/$p2");
+}
+
+print <<EOF;
+======================================================================
+The headers are installed. You may restore the old headers (if there
+were any) using the command "make revert". You may uninstall the headers
+using the command "make uninstallheader" or "make uninstall" to uninstall
+binaries, man pages and shell scripts.
+======================================================================
+EOF
+
+exit 0;
diff --git a/source4/script/installheader.sh b/source4/script/installheader.sh
deleted file mode 100755 (executable)
index 9aed5ed..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-#!/bin/sh
-
-INCLUDEDIR=$1
-shift
-
-for p in $*; do
- p2=`basename $p`
- echo Installing $p as $INCLUDEDIR/$p2
- if [ -f $INCLUDEDIR/$p2 ]; then
-   rm -f $INCLUDEDIR/$p2.old
-   mv $INCLUDEDIR/$p2 $INCLUDEDIR/$p2.old
- fi
- cp $p $INCLUDEDIR/
-
-done
-
-cat << EOF
-======================================================================
-The headers are installed. You may restore the old headers (if there
-were any) using the command "make revert". You may uninstall the headers
-using the command "make uninstallheader" or "make uninstall" to uninstall
-binaries, man pages and shell scripts.
-======================================================================
-EOF
-
-exit 0