Browse Source

20171024 GNU make (wenn $MAKE = GNU make, dann $> in Makefiles.in mit sed zu $^ umwandeln)

Altlast 7 năm trước cách đây
mục cha
commit
a04e90cd9e
3 tập tin đã thay đổi với 30 bổ sung17 xóa
  1. 15 15
      Makefile.in
  2. 1 1
      conf/Makefile
  3. 14 1
      conf/substitute.sh

+ 15 - 15
Makefile.in

@@ -7,7 +7,7 @@ Makefile: Makefile.in conf/substitutions.sed conf/Makefile conf/substitutions.co
 conf/substitutions.sed: conf/Makefile conf/substitutions.conf
 
 conf/substitutions.conf:
-	cd conf && make
+	cd conf && ${MAKE}
 
 build: src/Makefile src/nodes2prom src/json-pp
 
@@ -15,10 +15,10 @@ src/Makefile: src/Makefile.in
 	conf/substitute.sh $> $@
 
 src/nodes2prom: src/Makefile
-	cd src && make nodes2prom
+	cd src && ${MAKE} nodes2prom
 
 src/json-pp: src/Makefile
-	cd src && make json-pp
+	cd src && ${MAKE} json-pp
 
 test: test/Makefile test/tmp
 
@@ -26,7 +26,7 @@ test/Makefile: test/Makefile.in
 	conf/substitute.sh $> $@
 
 test/tmp:
-	cd test && make test
+	cd test && ${MAKE} test
 
 etc: etc/Makefile etc/crontab etc/nodes2prometheus.sh
 
@@ -34,10 +34,10 @@ etc/Makefile: etc/Makefile.in
 	conf/substitute.sh $> $@
 
 etc/crontab:
-	cd etc && make
+	cd etc && ${MAKE}
 
 etc/nodes2prometheus.sh:
-	cd etc && make
+	cd etc && ${MAKE}
 
 dashboard: dashboard/Makefile dashboard/%%DASHBOARD_PREFIX%%status.json
 
@@ -45,7 +45,7 @@ dashboard/Makefile: dashboard/Makefile.in
 	conf/substitute.sh $> $@
 
 dashboard/%%DASHBOARD_PREFIX%%status.json:
-	cd dashboard && make
+	cd dashboard && ${MAKE}
 
 dist: dist/Makefile dist/nodes2grafana.txz
 
@@ -53,7 +53,7 @@ dist/Makefile: dist/Makefile.in
 	conf/substitute.sh $> $@
 
 dist/nodes2grafana.txz:
-	cd dist && rm -f $@ && make
+	cd dist && rm -f $@ && ${MAKE}
 
 install: install-bin install-crontab install-dashboard
 
@@ -66,12 +66,12 @@ install-crontab: etc/crontab
 	-diff /tmp/crontab.old $>
 
 install-dashboard:
-	cd dashboard && make install
+	cd dashboard && ${MAKE} install
 
 clean:
-	cd conf && make clean
-	[ ! -r test/Makefile ] || { cd test && make clean && rm -f Makefile ; }
-	[ ! -r etc/Makefile ] || { cd etc && make clean && rm -f Makefile ; }
-	[ ! -r src/Makefile ] || { cd src && make clean && rm -f Makefile ; }
-	[ ! -r dashboard/Makefile ] || { cd dashboard && make clean && rm -f Makefile ; }
-	[ ! -r dist/Makefile ] || { cd dist && make clean && rm -f Makefile ; }
+	cd conf && ${MAKE} clean
+	[ ! -r test/Makefile ] || { cd test && ${MAKE} clean && rm -f Makefile ; }
+	[ ! -r etc/Makefile ] || { cd etc && ${MAKE} clean && rm -f Makefile ; }
+	[ ! -r src/Makefile ] || { cd src && ${MAKE} clean && rm -f Makefile ; }
+	[ ! -r dashboard/Makefile ] || { cd dashboard && ${MAKE} clean && rm -f Makefile ; }
+	[ ! -r dist/Makefile ] || { cd dist && ${MAKE} clean && rm -f Makefile ; }

+ 1 - 1
conf/Makefile

@@ -6,7 +6,7 @@ substitutions.sed: substitutions.conf
 		-e 's@^[[:space:]]*#.*@@' \
 		-e 's@!@\\!@g' \
 		-e 's@^([[:alnum:]_]+)[[:space:]]+(.+)@s!%%\1%%!\2!g@p' \
-		$> > $@
+		substitutions.conf > $@
 
 substitutions.conf: substitutions.conf.local substitutions.conf.default
 	cp -p substitutions.conf.local $@

+ 14 - 1
conf/substitute.sh

@@ -1,3 +1,16 @@
 #!/bin/sh
 
-sed -f `dirname $0`/substitutions.sed $1 > $2
+[ -n "$MAKE" ] || MAKE=make
+SED_COMMAND="sed -f `dirname $0`/substitutions.sed"
+SED_EXTRA=
+
+case $1 in
+	*Makefile*.in)
+		if ${MAKE} --version 2>&1 | fgrep -q "GNU Make"
+		then
+			SED_EXTRA="-e s/\$>/$^/g"
+		fi
+		;;
+esac
+
+$SED_COMMAND $SED_EXTRA $1 > $2