Initial release of Maemo 5 port of gnuplot
[gnuplot] / src / Makefile.maint
diff --git a/src/Makefile.maint b/src/Makefile.maint
new file mode 100644 (file)
index 0000000..3eaa7b6
--- /dev/null
@@ -0,0 +1,43 @@
+# -*-Makefile-*-
+# Makefile fragment to generate makefile.all and update version.c
+
+# Non-core sources and version.c
+noncoresrc = amiga.c ansi2knr.c bf_test.c corplot.c gpexecute.c gplt_x11.c \
+os9.c strftime.c version.c vms.c
+
+coresrc := $(filter-out $(noncoresrc),$(wildcard *.c))
+
+coreterm := $(shell cd ../term && echo *.trm)
+
+version := $(shell cat ../VERSION)
+file_version := $(shell sed -n 's/.*gnuplot_version.*"\(.*\)".*/\1/p' ./version.c|tr -d ' ')
+
+patchlevel := $(shell cat ../PATCHLEVEL)
+file_pl := $(shell sed -n 's/.*gnuplot_patchlevel.*"\(.*\)".*/\1/p' ./version.c|tr -d ' ')
+
+date := $(shell date)
+
+makefile.all: Makefile.maint
+       @echo "# $@ generated automatically by GNU make" >$@t
+       @echo >>$@t
+       @echo '# List of core object files except version.$$(O)' >>$@t
+       @echo COREOBJS = $(coresrc:.c=.'$$(O)') \
+        | fmt | (tr '\012' @; echo) | sed 's/@$$/%/;s/@/ \\@/g' \
+        | tr @% '\012\012' >>$@t
+       @echo "# List of terminal driver sources" >>$@t
+       @echo CORETERM = $(patsubst %.trm,$$\(T\)%.trm,$(coreterm)) \
+        | fmt | (tr '\012' @; echo) | sed 's/@$$/%/;s/@/ \\@/g' \
+        | tr @% '\012\012' >>$@t
+       @if cmp -s $@ $@t; then rm -f $@t; else mv $@t $@; fi
+
+version.c: ../VERSION ../PATCHLEVEL
+       @echo Making $@
+       @if [ "$(version)" != "$(file_version)" -o \
+            "$(patchlevel)" != "$(file_pl)" ]; then \
+         sed -e '/^const char gnuplot_version/ s/"[^"]*"/"@VERS@"/' \
+             -e '/^const char gnuplot_patchlevel/ s/"[^"]*"/"@PLVL@"/' \
+             -e '/^const char gnuplot_date/ s/"[^"]*"/"@DATE@"/' \
+             -e "s/@VERS@/$(version)/" -e "s/@PLVL@/$(patchlevel)/" \
+             -e "s/@DATE@/$(date)/" $@ >$@t; \
+         if cmp -s $@ $@t; then rm -f $@t; else mv $@t $@; fi \
+       fi