aboutsummaryrefslogtreecommitdiff
path: root/libcommon/makefile
diff options
context:
space:
mode:
Diffstat (limited to 'libcommon/makefile')
-rw-r--r--libcommon/makefile53
1 files changed, 45 insertions, 8 deletions
diff --git a/libcommon/makefile b/libcommon/makefile
index 44c789a..cdb57bc 100644
--- a/libcommon/makefile
+++ b/libcommon/makefile
@@ -16,8 +16,9 @@ cxx_od := $(cxx_obj:.o=.o.d)
common.l := $(out_base)/common.l
common.l.cpp-options := $(out_base)/common.l.cpp-options
-default := $(out_base)/
-clean := $(out_base)/.clean
+default := $(out_base)/
+dist := $(out_base)/.dist
+clean := $(out_base)/.clean
# Import.
#
@@ -43,14 +44,10 @@ endif
#
$(common.l): $(cxx_obj) $(odb.l) $(odb_db.l)
-$(cxx_obj) $(cxx_od): $(common.l.cpp-options)
-$(common.l.cpp-options): value := -I$(src_base)
+$(cxx_obj) $(cxx_od): $(common.l.cpp-options) $(out_base)/config.h
+$(common.l.cpp-options): value := -I$(out_base) -I$(src_base)
$(common.l.cpp-options): $(odb_db.l.cpp-options) $(odb.l.cpp-options)
-ifeq ($(db_id),mysql)
-$(cxx_obj): cpp_options += -DDB_ID_MYSQL
-endif
-
genf := $(cli_tun:.cli=.hxx) $(cli_tun:.cli=.ixx) $(cli_tun:.cli=.cxx)
gen := $(addprefix $(out_base)/,$(genf))
@@ -63,19 +60,59 @@ $(gen): cli_options += \
$(call include-dep,$(cxx_od),$(cxx_obj),$(gen))
+$(out_base)/config.h: $(dcf_root)/configuration-dynamic.make
+ @echo '// file : libcommon/config.h' >$@
+ @echo '// author : automatically generated' >>$@
+ @echo '' >>$@
+ @echo '#ifndef LIBCOMMON_CONFIG_H' >>$@
+ @echo '#define LIBCOMMON_CONFIG_H' >>$@
+ @echo '' >>$@
+ifeq ($(db_id),mysql)
+ @echo '#define DB_ID_MYSQL 1' >>$@
+endif
+ @echo '' >>$@
+ @echo '#endif // LIBCOMMON_CONFIG_H' >>$@
+
# Convenience alias for default target.
#
$(out_base)/: $(common.l)
+# Dist.
+#
+$(dist): export sources := $(cxx_tun) $(cli_tun:.cli=.cxx)
+$(dist): export headers = $(subst $(src_base)/,,$(shell find $(src_base) \
+-name '*.hxx' -o -name '*.ixx' -o -name '*.txx'))
+$(dist): data_dist := $(cli_tun)
+$(dist): export extra_dist := $(data_dist)
+
+$(dist): $(gen)
+ $(call dist-data,$(sources) $(headers) $(data_dist) config.h.in)
+ $(call meta-automake)
+
# Clean.
#
$(clean): $(common.l).o.clean \
$(common.l.cpp-options).clean \
$(addsuffix .cxx.clean,$(cxx_obj)) \
$(addsuffix .cxx.clean,$(cxx_od))
+ $(call message,rm $$1,rm -f $$1,$(out_base)/config.h)
+
+# Generated .gitignore.
+#
+ifeq ($(out_base),$(src_base))
+$(common.l): | $(out_base)/.gitignore
+
+$(out_base)/.gitignore: files := config.h
+$(clean): $(out_base)/.gitignore.clean
+
+$(call include,$(bld_root)/git/gitignore.make)
+endif
# How to.
#
+$(call include,$(bld_root)/dist.make)
+$(call include,$(bld_root)/meta/automake.make)
+
$(call include,$(cli_rules))
$(call include,$(bld_root)/cxx/cxx-d.make)
$(call include,$(bld_root)/cxx/cxx-o.make)