From ab350eafd2c1a98ea98090fdb3bd9b7ae4f7336b Mon Sep 17 00:00:00 2001
From: Eelco Dolstra <e.dolstra@tudelft.nl>
Date: Fri, 18 Jul 2003 07:42:57 +0000
Subject: [PATCH] * Generate nar.sh, fetchurl.sh.

---
 configure.ac                  |  4 +++-
 corepkgs/Makefile.am          | 11 +----------
 corepkgs/fetchurl/Makefile.am |  8 ++++++++
 corepkgs/nar/Makefile.am      | 10 ++++++++++
 corepkgs/nar/nar.sh           |  5 -----
 corepkgs/nar/nar.sh.in        |  5 +++++
 corepkgs/nar/unnar.sh         |  4 ----
 corepkgs/nar/unnar.sh.in      |  4 ++++
 scripts/Makefile.am           |  8 +-------
 9 files changed, 32 insertions(+), 27 deletions(-)
 create mode 100644 corepkgs/fetchurl/Makefile.am
 create mode 100644 corepkgs/nar/Makefile.am
 delete mode 100644 corepkgs/nar/nar.sh
 create mode 100644 corepkgs/nar/nar.sh.in
 delete mode 100644 corepkgs/nar/unnar.sh
 create mode 100644 corepkgs/nar/unnar.sh.in

diff --git a/configure.ac b/configure.ac
index 77a5f1f1f..9db0a8807 100644
--- a/configure.ac
+++ b/configure.ac
@@ -12,5 +12,7 @@ AC_PROG_CXX
 AC_PROG_RANLIB
 
 AM_CONFIG_HEADER([config.h])
-AC_CONFIG_FILES([Makefile src/Makefile scripts/Makefile corepkgs/Makefile])
+AC_CONFIG_FILES([Makefile src/Makefile scripts/Makefile
+			  corepkgs/Makefile corepkgs/fetchurl/Makefile
+			  corepkgs/nar/Makefile])
 AC_OUTPUT
diff --git a/corepkgs/Makefile.am b/corepkgs/Makefile.am
index 9298865bf..e5b892bfc 100644
--- a/corepkgs/Makefile.am
+++ b/corepkgs/Makefile.am
@@ -1,10 +1 @@
-install-data-local:
-	$(INSTALL) -d $(datadir)/fix
-	$(INSTALL) -d $(datadir)/fix/fetchurl
-	$(INSTALL_DATA) fetchurl/fetchurl.fix $(datadir)/fix/fetchurl
-	$(INSTALL_DATA) fetchurl/fetchurl.sh $(datadir)/fix/fetchurl
-	$(INSTALL) -d $(datadir)/fix/nar
-	$(INSTALL_DATA) nar/nar.fix $(datadir)/fix/nar
-	$(INSTALL_DATA) nar/nar.sh $(datadir)/fix/nar
-	$(INSTALL_DATA) nar/unnar.fix $(datadir)/fix/nar
-	$(INSTALL_DATA) nar/unnar.sh $(datadir)/fix/nar
+SUBDIRS = fetchurl nar
diff --git a/corepkgs/fetchurl/Makefile.am b/corepkgs/fetchurl/Makefile.am
new file mode 100644
index 000000000..6bae43907
--- /dev/null
+++ b/corepkgs/fetchurl/Makefile.am
@@ -0,0 +1,8 @@
+all-local: fetchurl.sh
+
+install-exec-local:
+	$(INSTALL) -d $(datadir)/fix/fetchurl
+	$(INSTALL_DATA) fetchurl.fix $(datadir)/fix/fetchurl
+	$(INSTALL_DATA) fetchurl.sh $(datadir)/fix/fetchurl
+
+include ../../substitute.mk
diff --git a/corepkgs/nar/Makefile.am b/corepkgs/nar/Makefile.am
new file mode 100644
index 000000000..508eeff7c
--- /dev/null
+++ b/corepkgs/nar/Makefile.am
@@ -0,0 +1,10 @@
+all-local: nar.sh unnar.sh
+
+install-exec-local:
+	$(INSTALL) -d $(datadir)/fix/nar
+	$(INSTALL_DATA) nar.fix $(datadir)/fix/nar
+	$(INSTALL_DATA) nar.sh $(datadir)/fix/nar
+	$(INSTALL_DATA) unnar.fix $(datadir)/fix/nar
+	$(INSTALL_DATA) unnar.sh $(datadir)/fix/nar
+
+include ../../substitute.mk
diff --git a/corepkgs/nar/nar.sh b/corepkgs/nar/nar.sh
deleted file mode 100644
index a7b6be8aa..000000000
--- a/corepkgs/nar/nar.sh
+++ /dev/null
@@ -1,5 +0,0 @@
-#! /bin/sh
-
-echo "packing $path into $out..."
-/nix/bin/nix --dump --file "$path" | bzip2 > $out || exit 1
-
diff --git a/corepkgs/nar/nar.sh.in b/corepkgs/nar/nar.sh.in
new file mode 100644
index 000000000..bffbbaf5e
--- /dev/null
+++ b/corepkgs/nar/nar.sh.in
@@ -0,0 +1,5 @@
+#! /bin/sh
+
+echo "packing $path into $out..."
+@bindir@/nix --dump --file "$path" | bzip2 > $out || exit 1
+
diff --git a/corepkgs/nar/unnar.sh b/corepkgs/nar/unnar.sh
deleted file mode 100644
index cc21efb2b..000000000
--- a/corepkgs/nar/unnar.sh
+++ /dev/null
@@ -1,4 +0,0 @@
-#! /bin/sh
-
-echo "unpacking $nar to $out..."
-bunzip2 < $nar | /nix/bin/nix --restore "$out" || exit 1
diff --git a/corepkgs/nar/unnar.sh.in b/corepkgs/nar/unnar.sh.in
new file mode 100644
index 000000000..4b00cb981
--- /dev/null
+++ b/corepkgs/nar/unnar.sh.in
@@ -0,0 +1,4 @@
+#! /bin/sh
+
+echo "unpacking $nar to $out..."
+bunzip2 < $nar | @bindir@/nix --restore "$out" || exit 1
diff --git a/scripts/Makefile.am b/scripts/Makefile.am
index a8cbe8222..fb2ef566d 100644
--- a/scripts/Makefile.am
+++ b/scripts/Makefile.am
@@ -10,10 +10,4 @@ install-exec-local:
 # !!! don't overwrite local modifications
 	$(INSTALL_DATA) prebuilts.conf $(sysconfdir)/nix/prebuilts.conf
 
-%: %.in Makefile
-	sed \
-	 -e s^@prefix\@^$(prefix)^g \
-	 -e s^@sysconfdir\@^$(sysconfdir)^g \
-	 -e s^@localstatedir\@^$(localstatedir)^g \
-	 < $< > $@ || rm $@
-	chmod +x $@
+include ../substitute.mk
-- 
GitLab