aboutsummaryrefslogtreecommitdiff
path: root/libcommon
diff options
context:
space:
mode:
Diffstat (limited to 'libcommon')
-rw-r--r--libcommon/Makefile.am12
-rw-r--r--libcommon/common.cxx4
-rw-r--r--libcommon/common.hxx4
-rw-r--r--libcommon/config.h.in15
-rw-r--r--libcommon/export.hxx39
-rw-r--r--libcommon/makefile53
6 files changed, 118 insertions, 9 deletions
diff --git a/libcommon/Makefile.am b/libcommon/Makefile.am
new file mode 100644
index 0000000..d42cff2
--- /dev/null
+++ b/libcommon/Makefile.am
@@ -0,0 +1,12 @@
+# file : libcommon/Makefile.am
+# author : Boris Kolpackov <boris@codesynthesis.com>
+# copyright : Copyright (c) 2009-2010 Code Synthesis Tools CC
+# license : GNU GPL v2; see accompanying LICENSE file
+
+noinst_LTLIBRARIES = libcommon.la
+libcommon_la_SOURCES = __path__(sources) __path__(headers)
+
+EXTRA_DIST = __file__(extra_dist)
+
+libcommon_la_CPPFLAGS= -I'$(builddir)' -I'$(srcdir)' -DLIBCOMMON_DYNAMIC_LIB
+libcommon_la_LDFLAGS = -no-undefined -rpath '$(libdir)'
diff --git a/libcommon/common.cxx b/libcommon/common.cxx
index bfc3482..0c88818 100644
--- a/libcommon/common.cxx
+++ b/libcommon/common.cxx
@@ -6,6 +6,10 @@
#include <cstdlib> // std::exit
#include <iostream>
+#ifndef _MSC_VER
+# include <config.h>
+#endif
+
#ifdef DB_ID_MYSQL
# include <odb/mysql/database.hxx>
#endif
diff --git a/libcommon/common.hxx b/libcommon/common.hxx
index 8e5bd4d..411ece5 100644
--- a/libcommon/common.hxx
+++ b/libcommon/common.hxx
@@ -10,7 +10,9 @@
#include <odb/database.hxx>
-std::auto_ptr<odb::database>
+#include <export.hxx>
+
+LIBCOMMON_EXPORT std::auto_ptr<odb::database>
create_database (int argc, char* argv[]);
#endif // LIBCOMMON_COMMON_HXX
diff --git a/libcommon/config.h.in b/libcommon/config.h.in
new file mode 100644
index 0000000..9d18901
--- /dev/null
+++ b/libcommon/config.h.in
@@ -0,0 +1,15 @@
+/* file : libcommon/config.h.in
+ * author : Boris Kolpackov <boris@codesynthesis.com>
+ * copyright : Copyright (c) 2009-2010 Code Synthesis Tools CC
+ * license : GNU GPL v2; see accompanying LICENSE file
+ */
+
+/* This file is automatically processed by configure. */
+
+#ifndef LIBCOMMON_CONFIG_H
+#define LIBCOMMON_CONFIG_H
+
+#undef DB_ID_MYSQL
+#undef LIBCOMMON_STATIC_LIB
+
+#endif /* LIBCOMMON_CONFIG_H */
diff --git a/libcommon/export.hxx b/libcommon/export.hxx
new file mode 100644
index 0000000..8bbb96c
--- /dev/null
+++ b/libcommon/export.hxx
@@ -0,0 +1,39 @@
+// file : libcommon/export.hxx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC
+// license : GNU GPL v2; see accompanying LICENSE file
+
+#ifndef LIBCOMMON_EXPORT_HXX
+#define LIBCOMMON_EXPORT_HXX
+
+#ifndef _MSC_VER
+# include <config.h>
+#endif
+
+#ifdef LIBCOMMON_STATIC_LIB
+# define LIBCOMMON_EXPORT
+#else
+# ifdef _WIN32
+# ifdef _MSC_VER
+# ifdef LIBCOMMON_DYNAMIC_LIB
+# define LIBCOMMON_EXPORT __declspec(dllexport)
+# else
+# define LIBCOMMON_EXPORT __declspec(dllimport)
+# endif
+# else
+# ifdef LIBCOMMON_DYNAMIC_LIB
+# ifdef DLL_EXPORT
+# define LIBCOMMON_EXPORT __declspec(dllexport)
+# else
+# define LIBCOMMON_EXPORT
+# endif
+# else
+# define LIBCOMMON_EXPORT __declspec(dllimport)
+# endif
+# endif
+# else
+# define LIBCOMMON_EXPORT
+# endif
+#endif
+
+#endif // LIBCOMMON_EXPORT_HXX
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)