# $Id$ # # common rules for compilation of sources files to preprocessed # for compiled-in version and build date. # # this file is automatically included if BUILDDATESOURCES is set. # # Variables: # # srcdir ... source directory. # CXX ... path of GNU C++ compiler # CC ... path of GNU C compiler # BUILDDATESOURCES... list of source files to preprocess with __VERSION__, __BUILD_DATE__ and __SOURCE_SHA256__ # EXT_CFLAGS... pkg-config CFLAGS, determined by common-compile.mk # INCLUDES ... list of optional include directories # CFLAGS ... C options like -Wall -g -O2 # CXXFLAGS ... C++ options like -Wall -g -O2 # VERSION ... The version of the build artifact, determined by common-compile.mk # debian/changelog version must contain exactly 4 parts, i.e. 1.2.3.4 or 1.2.3-4 # BUILD_DATE=$(shell date '+%Y-%m-%d %H:%M:%S%z') BUILDDATESAH256INPUT=$(addprefix $(srcdir)/,$(BUILDDATESOURCES)) $(addprefix $(srcdir)/,$(SOURCES)) $(addprefix $(srcdir)/,$(HEADERS)) $(addprefix $(srcdir)/,$(UICFILES)) $(addprefix $(srcdir)/,$(YSOURCES)) BUILDDATETARGETSOURCES=$(join $(addsuffix _builddate,$(basename $(BUILDDATESOURCES))),$(suffix $(BUILDDATESOURCES))) BUILDDATEOBJS=$(addsuffix _builddate.o,$(basename $(BUILDDATESOURCES))) .SECONDARY=$(BUILDDATETARGETSOURCES) OBJS:=$(OBJS) $(BUILDDATEOBJS) # fake dependency in order to always force rebuild builddate_foo: source_hashes_builddate.sha256: $(BUILDDATESAH256INPUT) sha256sum $(BUILDDATESAH256INPUT) > $@ %_builddate.c: $(srcdir)/%.c source_hashes_builddate.sha256 builddate_foo sed -e 's/__VERSION__/$(VERSION)/g' -e 's/__BUILD_DATE__/$(BUILD_DATE)/g' -e 's/__SOURCE_SHA256__/$(shell sha256sum source_hashes_builddate.sha256)/g' < $< > $@ %_builddate.cpp: $(srcdir)/%.cpp source_hashes_builddate.sha256 builddate_foo sed -e 's/__VERSION__/$(VERSION)/g' -e 's/__BUILD_DATE__/$(BUILD_DATE)/g' -e 's/__SOURCE_SHA256__/$(shell sha256sum source_hashes_builddate.sha256)/g' < $< > $@ %_builddate.o: %_builddate.c $(CC) $(ABI_CFLAGS) $(CFLAGS) $(EXT_CFLAGS) $(INCLUDES) -c $< -o $*_builddate.o %_builddate.o: %_builddate.cpp $(CXX) $(ABI_CFLAGS) $(CXXFLAGS) $(EXT_CFLAGS) $(INCLUDES) -c $< -o $*_builddate.o clean:: rm -f $(BUILDDATETARGETSOURCES) rm -f source_hashes_builddate.sha256