From cd63dba445d476317e9a25c9d791a7078a0395c8 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 15 Nov 2011 17:40:25 +0200 Subject: Add support for selecting threading implementation --- build/bootstrap.make | 3 +++ build/configuration-rules.make | 18 ++++++++++++++++++ build/configuration.make | 22 ++++++++++++++++++++++ build/configure | 26 ++++++++++++++++++++++++++ odb/makefile | 31 +++++++++++++++++++++++++++++-- 5 files changed, 98 insertions(+), 2 deletions(-) create mode 100644 build/configuration-rules.make create mode 100644 build/configuration.make create mode 100644 build/configure diff --git a/build/bootstrap.make b/build/bootstrap.make index 26b7eeb..00d384d 100644 --- a/build/bootstrap.make +++ b/build/bootstrap.make @@ -16,6 +16,9 @@ ifeq ($(patsubst %build/bootstrap.make,,$(lastword $(MAKEFILE_LIST))),) include $(build)/bootstrap.make endif +# Configuration +# +$(call include,$(scf_root)/configuration.make) # Aliases # diff --git a/build/configuration-rules.make b/build/configuration-rules.make new file mode 100644 index 0000000..a198679 --- /dev/null +++ b/build/configuration-rules.make @@ -0,0 +1,18 @@ +# file : build/configuration-rules.make +# author : Boris Kolpackov +# copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +$(dcf_root)/configuration-dynamic.make: | $(dcf_root)/. + $(call message,,$(scf_root)/configure $@) + +ifndef %foreign% + +disfigure:: + $(call message,rm $$1,rm -f $$1,$(dcf_root)/configuration-dynamic.make) + +endif + +ifeq ($(.DEFAULT_GOAL),$(dcf_root)/configuration-dynamic.make) +.DEFAULT_GOAL := +endif diff --git a/build/configuration.make b/build/configuration.make new file mode 100644 index 0000000..0919150 --- /dev/null +++ b/build/configuration.make @@ -0,0 +1,22 @@ +# file : build/configuration.make +# author : Boris Kolpackov +# copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +$(call include-once,$(scf_root)/configuration-rules.make,$(dcf_root)) + +# Dynamic configuration. +# +libodb_threads := + +$(call -include,$(dcf_root)/configuration-dynamic.make) + +ifdef libodb_threads + +$(out_root)/%: libodb_threads := $(libodb_threads) + +else + +.NOTPARALLEL: + +endif diff --git a/build/configure b/build/configure new file mode 100644 index 0000000..5816683 --- /dev/null +++ b/build/configure @@ -0,0 +1,26 @@ +#! /usr/bin/env bash + +# file : build/configure +# author : Boris Kolpackov +# copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +# $1 out file +# +# bld_root - build root +# project_name - project name +# + +source $bld_root/dialog.bash + +$echo +$echo "Please select the threading implementation:" +$echo +$echo "(1) POSIX" +$echo "(2) Win32" +$echo "(3) None" +$echo + +threads=`read_option "posix win32 none" "posix"` + +echo "libodb_threads := $threads" >$1 diff --git a/odb/makefile b/odb/makefile index 54499a0..6c243e8 100644 --- a/odb/makefile +++ b/odb/makefile @@ -44,7 +44,22 @@ details/win32/exceptions.cxx win32_dll_cxx := details/win32/dll.cxx -cxx_tun := $(cxx) $(posix_cxx) +cxx_tun := $(cxx) + +ifeq ($(libodb_threads),posix) +cxx_tun += $(posix_cxx) +endif + +ifeq ($(libodb_threads),win32) +cxx_tun += $(win32_cxx) + +$(call include,$(bld_root)/ld/configuration-lib.make) # ld_lib_type + +ifeq ($(ld_lib_type),shared) +cxx_tun += $(win32_dll_cxx) +endif +endif + cxx_obj := $(addprefix $(out_base)/,$(cxx_tun:.cxx=.o)) cxx_od := $(cxx_obj:.o=.o.d) @@ -58,7 +73,11 @@ clean := $(out_base)/.clean # Build. # -$(odb.l): $(cxx_obj) -lpthread +$(odb.l): $(cxx_obj) + +ifeq ($(libodb_threads),posix) +$(odb.l): -lpthread +endif $(cxx_obj) $(cxx_od): $(odb.l.cpp-options) $(out_base)/details/config.h $(odb.l.cpp-options): value := -I$(out_root) -I$(src_root) @@ -71,7 +90,15 @@ $(out_base)/details/config.h: | $(out_base)/details/. @echo '#ifndef ODB_DETAILS_CONFIG_H' >>$@ @echo '#define ODB_DETAILS_CONFIG_H' >>$@ @echo '' >>$@ +ifeq ($(libodb_threads),posix) @echo '#define ODB_THREADS_POSIX 1' >>$@ +endif +ifeq ($(libodb_threads),win32) + @echo '#define ODB_THREADS_WIN32 1' >>$@ +endif +ifeq ($(libodb_threads),none) + @echo '#define ODB_THREADS_NONE 1' >>$@ +endif @echo '' >>$@ @echo '#endif /* ODB_DETAILS_CONFIG_H */' >>$@ -- cgit v1.1