[makefile] use mktemp to create unique temp files

This assumes that mktemp is available, but should provide a better solution for issue #229.

Also create a variable holding the tempfile name which is unique to each target.
This should prevent problems with parallel builds, since these variables are global.
This commit is contained in:
Felix Ruess
2013-03-21 16:43:42 +01:00
parent 7325f9fec8
commit 77cd732702
7 changed files with 112 additions and 94 deletions
+7 -8
View File
@@ -3,9 +3,6 @@
DATADIR = $(PAPARAZZI_HOME)/conf/maps_data
Q=@
# default directory for temporary files
TMPDIR ?= /tmp
all: $(PAPARAZZI_HOME)/conf/maps.xml
clean:
@@ -25,13 +22,15 @@ $(DATADIR)/maps.google.com: $(DATADIR) FORCE
$(PAPARAZZI_HOME)/conf/maps.xml: $(DATADIR)/maps.google.com
$(eval GOOGLE_VERSION := $(shell grep -E "http://khm[0-9]+.google.com/kh/v=[0-9]+.x26" $(DATADIR)/maps.google.com | sed -E 's#.*http://khm[0-9]+.google.com/kh/v=##;s#.x26.*##'))
$(eval $@_TMP := $(shell mktemp))
@echo "Updated google maps version to $(GOOGLE_VERSION)"
@echo "-----------------------------------------------"
$(Q)echo "<!DOCTYPE maps SYSTEM \"maps.dtd\">" > $(TMPDIR)/maps.xml
$(Q)echo "" >> $(TMPDIR)/maps.xml
$(Q)echo "<maps google_version=\"$(GOOGLE_VERSION)\"/>" >> $(TMPDIR)/maps.xml
$(Q)echo "" >> $(TMPDIR)/maps.xml
$(Q)mv $(TMPDIR)/maps.xml $@
$(Q)echo "<!DOCTYPE maps SYSTEM \"maps.dtd\">" > $($@_TMP)
$(Q)echo "" >> $($@_TMP)
$(Q)echo "<maps google_version=\"$(GOOGLE_VERSION)\"/>" >> $($@_TMP)
$(Q)echo "" >> $($@_TMP)
$(Q)mv $($@_TMP) $@
$(Q)chmod a+r $@
FORCE:
.PHONY: all clean