1# -*-Makefile-*-
2# Makefile fragment to generate makefile.all and update version.c
3
4# Non-core sources and version.c
5noncoresrc = bf_test.c gpexecute.c gplt_x11.c strftime.c version.c vms.c
6
7coresrc := $(filter-out $(noncoresrc),$(wildcard *.c))
8
9coreterm := $(shell cd ../term && echo *.trm)
10
11version := $(shell cat $(top_srcdir)/VERSION)
12file_version := $(shell sed -n 's/.*gnuplot_version.*"\(.*\)".*/\1/p' ./version.c|tr -d ' ')
13
14patchlevel := $(shell cat $(top_srcdir)/PATCHLEVEL)
15file_pl := $(shell sed -n 's/.*gnuplot_patchlevel.*"\(.*\)".*/\1/p' ./version.c|tr -d ' ')
16
17last_change := $(shell dd if=$(top_srcdir)/ChangeLog bs=11 count=1 2> /dev/null)
18
19date := $(shell date)
20
21makefile.all: $(srcdir)/Makefile.maint
22	@echo "# $@ generated automatically by GNU make" >$@t
23	@echo >>$@t
24	@echo '# List of core object files except version.$$(O)' >>$@t
25	@echo COREOBJS = $(coresrc:.c=.'$$(O)') \
26	 | fmt | (tr '\012' @; echo) | sed 's/@$$/%/;s/@/ \\@/g' \
27	 | tr @% '\012\012' >>$@t
28	@echo "# List of terminal driver sources" >>$@t
29	@echo CORETERM = $(patsubst %.trm,$$\(T\)%.trm,$(coreterm)) \
30	 | fmt | (tr '\012' @; echo) | sed 's/@$$/%/;s/@/ \\@/g' \
31	 | tr @% '\012\012' >>$@t
32	@if cmp -s $@ $@t; then rm -f $@t; else mv $@t $@; fi
33
34makefile.awc: makefile.all
35	sed -e 's/\\/\&/g' makefile.all > $@
36
37version.c: $(top_srcdir)/VERSION $(top_srcdir)/PATCHLEVEL
38	@echo Making $@
39	@if [ "$(version)" != "$(file_version)" -o \
40	     "$(patchlevel)" != "$(file_pl)" ]; then \
41	  sed -e '/^const char gnuplot_version/ s/"[^"]*"/"@VERS@"/' \
42	      -e '/^const char gnuplot_patchlevel/ s/"[^"]*"/"@PLVL@"/' \
43	      -e "s/@VERS@/$(version)/" -e "s/@PLVL@/$(patchlevel)/" \
44	      $@ >$@t; \
45	  if cmp -s $@ $@t; then rm -f $@t; else mv $@t $@; fi \
46	fi
47
48