diff options
author | Andreas Baumann <abaumann@yahoo.com> | 2012-07-12 19:18:06 +0200 |
---|---|---|
committer | Andreas Baumann <abaumann@yahoo.com> | 2012-07-12 19:18:06 +0200 |
commit | b1e647baf2e1724838e34d25339a3672caf09e14 (patch) | |
tree | 1e305a8efc6138603c3949a4ab083b252b9e39c8 /makefiles | |
parent | 7d4bf0e6f0f7e65ab3b2e6465755aa00d896d76e (diff) | |
download | crawler-b1e647baf2e1724838e34d25339a3672caf09e14.tar.gz crawler-b1e647baf2e1724838e34d25339a3672caf09e14.tar.bz2 |
added basic structure
Diffstat (limited to 'makefiles')
-rw-r--r-- | makefiles/gmake/clean.mk | 21 | ||||
-rw-r--r-- | makefiles/gmake/compiler.mk | 100 | ||||
-rw-r--r-- | makefiles/gmake/depend.mk | 49 | ||||
-rw-r--r-- | makefiles/gmake/dist.mk | 15 | ||||
-rwxr-xr-x | makefiles/gmake/guess_env | 371 | ||||
-rw-r--r-- | makefiles/gmake/help.mk | 25 | ||||
-rw-r--r-- | makefiles/gmake/i18n.mk | 12 | ||||
-rw-r--r-- | makefiles/gmake/install.mk | 40 | ||||
-rw-r--r-- | makefiles/gmake/libs.mk | 63 | ||||
-rw-r--r-- | makefiles/gmake/platform.mk | 149 | ||||
-rw-r--r-- | makefiles/gmake/sub.mk | 17 | ||||
-rw-r--r-- | makefiles/gmake/top.mk | 68 |
12 files changed, 545 insertions, 385 deletions
diff --git a/makefiles/gmake/clean.mk b/makefiles/gmake/clean.mk index 92061d4..a8128af 100644 --- a/makefiles/gmake/clean.mk +++ b/makefiles/gmake/clean.mk @@ -5,8 +5,7 @@ # - local_clean, local_distclean targets in local GNUmakefile # - all artifacts to clean: # - BINS, TEST_BINS, TEST_CPP_BINS, CPP_BINS -# - OBJS, CPPOBJS, BIN_OBJS, TEST_BIN_OBJS, CPP_BIN_OBJS, TEST_CPP_BIN_OBJS -# - CMODULES, CPPMODULES +# - OBJS, CPP_OBJS, BIN_OBJS, TEST_BIN_OBJS, CPP_BIN_OBJS, TEST_CPP_BIN_OBJS # # provides: # - target: clean @@ -15,26 +14,36 @@ .PHONY: clean_recursive clean local_clean clean_recursive: + @test -z "$(PRESUBDIRS)" || ( set -e; for d in $(PRESUBDIRS)""; do \ + (set -e; $(MAKE) -C $$d clean || exit 1); done) @test -z "$(SUBDIRS)" || ( set -e; for d in $(SUBDIRS)""; do \ (set -e; $(MAKE) -C $$d clean || exit 1); done) clean: clean_recursive clean_po local_clean -@rm -f *.bak 2>/dev/null -@rm -f *~ 2>/dev/null - -@rm -f *.d port/*.d 2>/dev/null + -@rm -f *.d */*.d */*/*.d 2>/dev/null -@rm -f $(BINS) $(CPP_BINS) $(TEST_BINS) $(TEST_CPP_BINS) 2>/dev/null -@rm -f $(OBJS) $(CPP_OBJS) $(BIN_OBJS) $(TEST_BIN_OBJS) $(CPP_BIN_OBJS) $(TEST_CPP_BIN_OBJS) 2>/dev/null -@rm -f exec/* 2>/dev/null -@rm -f *.core 2>/dev/null - -@rm -f $(CMODULES) $(CPPMODULES) 2>/dev/null - -@rm -f $(CMODULES:.o=.d) $(CPPMODULES:.o=.d) 2>/dev/null -@rm -rf $(STATIC_LIB) 2>/dev/null - -@rm -rf $(DYNAMIC_LIB).$(DYNAMIC_LIB_MAJOR).$(DYNAMIC_LIB_MINOR).$(DYNAMIC_LIB_PATCH) 2>/dev/null -@rm -f $(SH_OBJS) rm -f $(SHPP_OBJS) 2>/dev/null +ifneq "$(DYNAMIC_LIB)" "" + -@rm -rf $(DYNAMIC_LIB).$(DYNAMIC_LIB_MAJOR).$(DYNAMIC_LIB_MINOR).$(DYNAMIC_LIB_PATCH) 2>/dev/null + -@rm -rf $(DYNAMIC_LIB).$(DYNAMIC_LIB_MAJOR) 2>/dev/null + -@rm -rf $(DYNAMIC_LIB) 2>/dev/null +endif +ifneq "$(DYNAMIC_MODULE)" "" + -@rm -rf $(DYNAMIC_MODULE) 2>/dev/null +endif + .PHONY: distclean_recursive distclean local_distclean distclean_recursive: + @test -z "$(PRESUBDIRS)" || ( set -e; for d in $(PRESUBDIRS)""; do \ + (set -e; $(MAKE) -C $$d distclean || exit 1); done) @test -z "$(SUBDIRS)" || ( set -e; for d in $(SUBDIRS)""; do \ (set -e; $(MAKE) -C $$d distclean || exit 1); done) diff --git a/makefiles/gmake/compiler.mk b/makefiles/gmake/compiler.mk index 01e9837..062a30b 100644 --- a/makefiles/gmake/compiler.mk +++ b/makefiles/gmake/compiler.mk @@ -33,9 +33,7 @@ GCC_MINOR_VERSION ?= $(shell $(TOPDIR)/makefiles/gmake/guess_env --gcc-minor-ver # -fstack-protector-all: does something funny to the shared objects.. # -Wstack-protector makes no sense without SSP # everything implied by -Wall is not explicitly specified (gcc 4.2.3) -# TODO: reenable -O2 # -Waggregate-return: is for K&R code and mostly useless nowadays -# -Wno-long-long: sqlite.h on FreeBSD 6.2 shows problems otherwise # compilation flags and compilers COMMON_COMPILE_FLAGS = \ @@ -119,13 +117,13 @@ endif endif -CCPP_COMPILE_FLAGS = \ +CXX_COMPILE_FLAGS = \ $(COMMON_COMPILE_FLAGS) \ -std=c++98 # gcc 4.x ifeq "$(GCC_MAJOR_VERSION)" "4" -CCPP_COMPILE_FLAGS += \ +CXX_COMPILE_FLAGS += \ -Wno-invalid-offsetof -funit-at-a-time endif @@ -133,38 +131,25 @@ ifeq "$(GCC_MAJOR_VERSION)" "3" # gcc 3.4, not tested yet ifeq "$(GCC_MINOR_VERSION)" "4" -CCPP_COMPILE_FLAGS += \ +CXX_COMPILE_FLAGS += \ -Wno-invalid-offsetof endif # gcc 3.3, testend on OpenBSD 4.2 ifeq "$(GCC_MINOR_VERSION)" "3" -#CCPP_COMPILE_FLAGS += \ +#CXX_COMPILE_FLAGS += \ # -Wdeclaration-after-statement endif endif #CC = gcc -CCPP = g++ +CXX = g++ endif # end of gcc section -# start of tcc section - -# currently we don't need this, the tcc flags are fairly consistent -#TCC_MAJOR_VERSION ?= $(shell $(TOPDIR)/makefiles/gmake/guess_env --tcc-major-version $(CC) "$(CURDIR)" $(TOPDIR)) -#TCC_MINOR_VERSION ?= $(shell $(TOPDIR)/makefiles/gmake/guess_env --tcc-minor-version $(CC) "$(CURDIR)" $(TOPDIR)) - -ifeq "$(COMPILER)" "tcc" -COMPILE_FLAGS = \ - -Wall -Werror -endif - -# end of tcc section - # start of icc section # currently we don't need this, the icc flags are fairly consistent @@ -183,33 +168,29 @@ endif # start of spro section # -xc99=all: full C99 compliance for the code (syntax and library functions) -# -Xc: full ISO compliance, no K&R stuf # -mt: enable mutlithreading (-D_REENTRANT for header files, -lthread for ld) # -errwarn=%all: convert all warnings to errors -# -v: do more restrictive syntax checking -# TODO: enable -O2 ifeq "$(COMPILER)" "spro" + +CC=CC +CXX=CC + STD99_COMPILE_FLAGS = \ -xc99=all -COMPILE_FLAGS = \ - $(STD99_COMPILE_FLAGS) -Xc -errwarn=%all -mt -v -endif -# end of spro section +COMMON_COMPILE_FLAGS = \ + -errwarn=%all -mt -# start of pcc section +COMPILE_FLAGS = \ + $(STD99_COMPILE_FLAGS) $(COMMON_COMPILE_FLAGS) -# currently we don't need this, the pcc flags are fairly consistent -#PCC_MAJOR_VERSION ?= $(shell $(TOPDIR)/makefiles/gmake/guess_env --pcc-major-version $(CC) "$(CURDIR)" $(TOPDIR)) -#PCC_MINOR_VERSION ?= $(shell $(TOPDIR)/makefiles/gmake/guess_env --pcc-minor-version $(CC) "$(CURDIR)" $(TOPDIR)) +CXX_COMPILE_FLAGS = \ + $(COMMON_COMPILE_FLAGS) -ifeq "$(COMPILER)" "pcc" -COMPILE_FLAGS = \ - --fatal-warnings endif -# end of pcc section +# end of spro section # set flags for threading support using POSIX threads. This is completly different # between compiler/platforms @@ -244,17 +225,8 @@ PTHREADS_CFLAGS = PTHREADS_LDFLAGS = PTHREADS_LIBS = endif -endif -ifeq "$(COMPILER)" "tcc" -ifeq "$(PLATFORM)" "LINUX" -PTHREADS_CFLAGS = -D_REENTRANT -PTHREADS_LDFLAGS = -PTHREADS_LIBS = -lpthread -endif -endif - -ifeq "$(COMPILER)" "pcc" +ifeq "$(COMPILER)" "icc" ifeq "$(PLATFORM)" "LINUX" PTHREADS_CFLAGS = -D_REENTRANT -pthread PTHREADS_LDFLAGS = -pthread @@ -262,12 +234,6 @@ PTHREADS_LIBS = endif endif -ifeq "$(COMPILER)" "icc" -ifeq "$(PLATFORM)" "LINUX" -PTHREADS_CFLAGS = -D_REENTRANT -pthread -PTHREADS_LDFLAGS = -pthread -PTHREADS_LIBS = -endif endif # set flags for position independend code (as required for shared libraries @@ -309,36 +275,36 @@ endif #endif #endif -CFLAGS = $(COMPILE_FLAGS) $(PLATFORM_COMPILE_FLAGS) $(INCLUDE_DIRS) $(PTHREADS_CFLAGS) -CCPPFLAGS = $(CCPP_COMPILE_FLAGS) $(PLATFORM_COMPILE_FLAGS) $(INCLUDE_DIRS) $(PTHREADS_CFLAGS) +ALL_CFLAGS = $(CFLAGS) $(COMPILE_FLAGS) $(PLATFORM_COMPILE_FLAGS) $(INCLUDE_DIRS) $(INCLUDE_CFLAGS) $(PTHREADS_CFLAGS) +ALL_CXXFLAGS = $(CXXFLAGS) $(CXX_COMPILE_FLAGS) $(PLATFORM_COMPILE_FLAGS) $(INCLUDE_DIRS) $(INCLUDE_CXXFLAGS) $(PTHREADS_CFLAGS) +ALL_LDFLAGS = $(LDFLAGS) $(INCLUDE_LDFLAGS) $(PTHREADS_LDFLAGS) $(LDFLAGS_NET) $(LDFLAGS_LT) $(LDFLAGS_DL) -LDFLAGS = $(INCLUDE_LDFLAGS) $(PTHREADS_LDFLAGS) $(LDFLAGS_NET) $(LDFLAGS_LT) -LIBS = $(INCLUDE_LIBS) $(PTHREADS_LIBS) $(LIBS_NET) $(LIBS_LT) +LIBS = $(INCLUDE_LIBS) $(PTHREADS_LIBS) $(LIBS_NET) $(LIBS_LT) $(LIBS_DL) LINK = $(CC) -CCPP_LINK = $(CCPP) +CXX_LINK = $(CXX) %.o : %.c - $(CC) -c -o $@ $(CFLAGS) $< + $(CC) -c -o $@ $(ALL_CFLAGS) $< %.o : %.cpp - $(CCPP) -c -o $@ $(CCPPFLAGS) $< + $(CXX) -c -o $@ $(ALL_CXXFLAGS) $< -%$(EXE): %.o $(OBJS) $(TEST_OBJS) - $(CCPP_LINK) -o $@ $(LDFLAGS) $(OBJS) $(TEST_OBJS) $< $(LIBS) +%$(EXE): %.o $(OBJS) $(CPP_OBJS) + $(CXX_LINK) -o $@ $(ALL_LDFLAGS) $(OBJS) $(CPP_OBJS) $< $(LIBS) %.sho : %.c - $(CC) -c -o $@ $(SO_COMPILE_FLAGS) -DSHARED $(CFLAGS) $< + $(CC) -c -o $@ $(SO_COMPILE_FLAGS) -DSHARED $(ALL_CFLAGS) $< #%$(SO) : %.sho $(OBJS) -# $(LINK) -shared -o $@ $(LDFLAGS) $(LIBS) $(OBJS) $< +# $(LINK) -shared -o $@ $(ALL_LDFLAGS) $(LIBS) $(OBJS) $< %.sho++ : %.cpp - $(CCPP) -c -o $@ $(SO_COMPILE_FLAGS) -DSHARED $(CCPPFLAGS) $< + $(CXX) -c -o $@ $(SO_COMPILE_FLAGS) -DSHARED $(ALL_CXXFLAGS) $< + +#%$(SO) : %.sho++ $(OBJS) $(CPP_OBJS) +# $(CXX_LINK) -shared -o $@ $(ALL_LDFLAGS) $(LIBS) $(OBJS) $(CPP_OBJS) $< -#%$(SO) : %.sho++ $(OBJS) $(CPPOBJS) -# $(CCPP_LINK) -shared -o $@ $(LDFLAGS) $(LIBS) $(OBJS) $(CPPOBJS) $< - -BIN_OBJS = $(BINS:$(EXE)=.o) +BIN_OBJS = $(BINS:$(EXE)=.o) TEST_BIN_OBJS = $(TEST_BINS:$(EXE)=.o) CPP_BIN_OBJS = $(CPP_BINS:$(EXE)=.o) TEST_CPP_BIN_OBJS = $(TEST_CPP_BINS:$(EXE)=.o) diff --git a/makefiles/gmake/depend.mk b/makefiles/gmake/depend.mk index eb832e7..411da66 100644 --- a/makefiles/gmake/depend.mk +++ b/makefiles/gmake/depend.mk @@ -2,7 +2,7 @@ # 'makedepend', 'gcc -MM' or similar mechanisms # # requires: -# - compilers CC and CCPP +# - compilers CC and CXX # - INCLUDEDIRS # - OBJS, CPP_OBJS and BIN_OBJS, CPP_BIN_OBJS # - TEST_BINS, TEST_BIN_OBJS, TEST_CPP_BINS, TEST_CPP_BIN_OBJS @@ -16,34 +16,12 @@ ifeq "$(COMPILER)" "gcc" %.d : %.c @echo Generating dependencies for $< - @$(CC) -DMAKE_DEPENDENCIES -MM -MT $(@:.d=.o) $(CFLAGS) $< | \ + @$(CC) -DMAKE_DEPENDENCIES -MM -MT $(@:.d=.o) $(ALL_CFLAGS) $< | \ sed "s,\($*\.o\)[ :]*\(.*\),$@ : $$\(wildcard \2\)\&\&\&\1 : \2,g" | tr -s '&' "\n" > $@ %.d : %.cpp @echo Generating dependencies for $< - @$(CCPP) -DMAKE_DEPENDENCIES -MM -MT $(@:.d=.o) $(CCPPFLAGS) $< | \ - sed "s,\($*\.o\)[ :]*\(.*\),$@ : $$\(wildcard \2\)\&\&\&\1 : \2,g" | tr -s '&' "\n" > $@ - -endif - -ifeq "$(COMPILER)" "tcc" - -%.d : %.c - @echo Generating dependencies for $< - @makedepend -DMAKE_DEPENDENCIES $(PLATFORM_COMPILE_FLAGS) $(INCLUDE_DIRS) -I/usr/lib/tcc/include -f - $< > $@ - -endif - -ifeq "$(COMPILER)" "icc" - -%.d : %.c - @echo Generating dependencies for $< - @$(CC) -DMAKE_DEPENDENCIES -MM -MT $(@:.d=.o) $(CFLAGS) $< | \ - sed "s,\($*\.o\)[ :]*\(.*\),$@ : $$\(wildcard \2\)\&\&\&\1 : \2,g" | tr -s '&' "\n" > $@ - -%.d : %.cpp - @echo Generating dependencies for $< - @$(CCPP) -DMAKE_DEPENDENCIES -MM -MT $(@:.d=.o) $(CCPPFLAGS) $< | \ + @$(CXX) -DMAKE_DEPENDENCIES -MM -MT $(@:.d=.o) $(ALL_CXXFLAGS) $< | \ sed "s,\($*\.o\)[ :]*\(.*\),$@ : $$\(wildcard \2\)\&\&\&\1 : \2,g" | tr -s '&' "\n" > $@ endif @@ -52,25 +30,24 @@ ifeq "$(COMPILER)" "spro" %.d : %.c @echo Generating dependencies for $< - @$(CC) -DMAKE_DEPENDENCIES -xM1 $(CFLAGS) $< > $@ + @$(CC) -DMAKE_DEPENDENCIES -xM1 $(ALL_CFLAGS) $< > $@ %.d : %.cpp @echo Generating dependencies for $< - @$(CCPP) -DMAKE_DEPENDENCIES -xM1 $(CCPPFLAGS) $< > $@ -endif - -ifeq "$(COMPILER)" "pcc" - -# FIXME: platform in path of compiler include files, mmh, how to fix? -%.d : %.c - @echo Generating dependencies for $< - @$(CC) -DMAKE_DEPENDENCIES $(CFLAGS) -M $< > $@ - + @$(CXX) -DMAKE_DEPENDENCIES -xM1 $(ALL_CXXFLAGS) $< > $@ endif +ifneq ($(MAKECMDGOALS),clean) +ifneq ($(MAKECMDGOALS),distclean) -include $(OBJS:.o=.d) -include $(CPP_OBJS:.o=.d) -include $(BIN_OBJS:.o=.d) -include $(CPP_BIN_OBJS:.o=.d) -include $(TEST_BIN_OBJS:.o=.d) -include $(TEST_CPP_BIN_OBJS:.o=.d) + +.PHONY: depend +depend: $(OBJS:.o=.d) $(CPP_OBJS:.o=.d) $(BIN_OBJS:.o=.d) $(CPP_BIN_OBJS:.o=.d) $(TEST_BIN_OBJS:.o=.d) $(TEST_CPP_BIN_OBJS:.o=.d) + +endif +endif diff --git a/makefiles/gmake/dist.mk b/makefiles/gmake/dist.mk index 85ceae7..dc80907 100644 --- a/makefiles/gmake/dist.mk +++ b/makefiles/gmake/dist.mk @@ -10,21 +10,24 @@ .PHONY: dist dist-bz2 dist-gz dist-Z +TMPDIR ?= /tmp + dist: -@rm -rf $(PACKAGE_NAME)-$(PACKAGE_VERSION) - -@rm -rf /tmp/$(PACKAGE_NAME)-$(PACKAGE_VERSION) - mkdir /tmp/$(PACKAGE_NAME)-$(PACKAGE_VERSION) - cp -r * /tmp/$(PACKAGE_NAME)-$(PACKAGE_VERSION)/. - -@cd /tmp/$(PACKAGE_NAME)-$(PACKAGE_VERSION) ; \ + -@rm -rf $(TMPDIR)/$(PACKAGE_NAME)-$(PACKAGE_VERSION) + mkdir $(TMPDIR)/$(PACKAGE_NAME)-$(PACKAGE_VERSION) + cp -r * $(TMPDIR)/$(PACKAGE_NAME)-$(PACKAGE_VERSION)/. + -@cd $(TMPDIR)/$(PACKAGE_NAME)-$(PACKAGE_VERSION) ; \ $(MAKE) distclean ; \ rm -f makefiles/gmake/platform.mk.vars; \ + rm -f makefiles/gmake/platform.vars; \ find . -name .svn -exec rm -rf {} \; ; \ find . -name .git -exec rm -rf {} \; ; \ cd .. ; \ tar cvf $(PACKAGE_NAME)-$(PACKAGE_VERSION).tar \ $(PACKAGE_NAME)-$(PACKAGE_VERSION) - -@rm -rf /tmp/$(PACKAGE_NAME)-$(PACKAGE_VERSION) - @mv /tmp/$(PACKAGE_NAME)-$(PACKAGE_VERSION).tar . + -@rm -rf $(TMPDIR)/$(PACKAGE_NAME)-$(PACKAGE_VERSION) + @mv $(TMPDIR)/$(PACKAGE_NAME)-$(PACKAGE_VERSION).tar . dist-bz2: dist -@rm -rf $(PACKAGE_NAME)-$(PACKAGE_VERSION).bz2 diff --git a/makefiles/gmake/guess_env b/makefiles/gmake/guess_env index 2e4f3de..60e039a 100755 --- a/makefiles/gmake/guess_env +++ b/makefiles/gmake/guess_env @@ -1,103 +1,154 @@ #!/bin/sh -# operating system and major, minor version, more should not be necessary - -UNAME_SYSTEM=`(uname -s) 2>/dev/null` -UNAME_RELEASE=`(uname -r) 2>/dev/null` -UNAME_VERSION=`(uname -v) 2>/dev/null` -UNAME_MACHINE=`(uname -m) 2>/dev/null` - -case "$UNAME_SYSTEM.$UNAME_RELEASE" in - Linux*) PLATFORM=LINUX - OS_MAJOR_VERSION=`echo $UNAME_RELEASE | cut -d . -f 1` - OS_MINOR_VERSION=`echo $UNAME_RELEASE | cut -d . -f 2` - - if test -f /etc/arch-release; then - LINUX_DIST='arch' - LINUX_REV='current' - elif test -f /etc/debian_version; then - LINUX_DIST='debian' - LINUX_REV=`cat /etc/debian_version | cut -d . -f 1` - elif test -f /etc/slackware-version; then - LINUX_DIST='slackware' - LINUX_REV=`cat /etc/slackware-version | cut -d ' ' -f 2 | cut -d . -f 1` - elif test -f /etc/redhat-release; then - LINUX_DIST='redhat' - LINUX_REV=`cat /etc/redhat-release | sed s/.*release\ // | sed s/\ .*// | cut -f 1 -d .` - else - LINUX_DIST='unknown' - LINUX_REV='unknown' - fi - ;; - - FreeBSD*) PLATFORM=FREEBSD - OS_MAJOR_VERSION=`echo $UNAME_RELEASE | cut -d . -f 1` - OS_MINOR_VERSION=`echo $UNAME_RELEASE | cut -d . -f 2 | cut -d - -f 1` - ;; - - OpenBSD*) PLATFORM=OPENBSD - OS_MAJOR_VERSION=`echo $UNAME_RELEASE | cut -d . -f 1` - OS_MINOR_VERSION=`echo $UNAME_RELEASE | cut -d . -f 2 | cut -d - -f 1` - ;; - - NetBSD*) PLATFORM=NETBSD - OS_MAJOR_VERSION=`echo $UNAME_RELEASE | cut -d . -f 1` - OS_MINOR_VERSION=`echo $UNAME_RELEASE | cut -d . -f 2 | cut -d - -f 1` - ;; - - SunOS*) PLATFORM=SUNOS - OS_MAJOR_VERSION=`echo $UNAME_RELEASE | cut -d . -f 1` - OS_MINOR_VERSION=`echo $UNAME_RELEASE | cut -d . -f 2` - ;; - - CYGWIN_NT*) PLATFORM=CYGWIN - _tmp=`echo $UNAME_SYSTEM | cut -d - -f 2` - OS_MAJOR_VERSION=`echo $_tmp | cut -d . -f 1` - OS_MINOR_VERSION=`echo $_tmp | cut -d . -f 2` - ;; - - *) - PLATFORM=UNKNOWN - echo "Unknown platform '$UNAME_SYSTEM $UNAME_RELEASE'" - exit 1 -esac +# bail out fast if we already have a cache file, otherwise building is far too slow! -# the architecture - -case "$UNAME_MACHINE" in - i*86*) ARCH=x86 - ;; - x86_64) ARCH=x86_64 - ;; - sun4u) ARCH=sun4u - ;; - - *) ARCH=UNKNOWN - echo "Unknown architecture '$UNAME_MACHINE'" - exit 1 - -esac - -# get last line, old 'tail' syntax and POSIX syntax, both exist out there -if test "x${PLATFORM}" = "xSUNOS"; then - TAIL1='tail -1' +MAKEFILE_DIR="$3/$4" +if test -f "${MAKEFILE_DIR}/makefiles/gmake/platform.vars"; then + . "${MAKEFILE_DIR}/makefiles/gmake/platform.vars" else - TAIL1='tail -n 1' -fi -# the compiler and version + # operating system and major, minor version, more should not be necessary -# what compiler do we have (we can't relly on it's name as it may be a cc link to the binary!) -CC=$2 -(( $CC -v 2>&1 | $TAIL1 ) | grep -i GCC ) 2>/dev/null 1>/dev/null -if test $? = 0; then - COMPILER='gcc' -else - ( $CC -v | grep tcc ) 2>/dev/null 1>/dev/null + UNAME_SYSTEM=`(uname -s) 2>/dev/null` + UNAME_RELEASE=`(uname -r) 2>/dev/null` + UNAME_VERSION=`(uname -v) 2>/dev/null` + UNAME_MACHINE=`(uname -m) 2>/dev/null` + + case "$UNAME_SYSTEM.$UNAME_RELEASE" in + Linux*) PLATFORM=LINUX + OS_MAJOR_VERSION=`echo $UNAME_RELEASE | cut -d . -f 1` + OS_MINOR_VERSION=`echo $UNAME_RELEASE | cut -d . -f 2` + + # LSB-system? Check for lsb-release + if test -x /usr/bin/lsb_release; then + dist=`/usr/bin/lsb_release -i | cut -f 2` + rev=`/usr/bin/lsb_release -r | cut -f 2` + case "$dist" in + Ubuntu) + LINUX_DIST='ubuntu' + LINUX_REV=$rev + ;; + + Debian) + LINUX_DIST='debian' + LINUX_REV=`echo $rev | cut -f 1 -d.` + ;; + + SUSE*LINUX) + LINUX_DIST='suse' + LINUX_REV=`echo $rev | tr -s ' ' '\t' | cut -f 2 -d ' '` + ;; + + *) + LINUX_DIST='unknown' + LINUX_REV='unknown' + ;; + esac + else + # try the older way with release files in /etc + + if test -f /etc/arch-release; then + LINUX_DIST='arch' + LINUX_REV='current' + if test "$OS_MAJOR_VERSION" = "3"; then + OS_MINOR_VERSION=`echo $UNAME_RELEASE | cut -d . -f 2 | cut -d - -f 1` + fi + elif test -f /etc/debian_version; then + LINUX_DIST='debian' + LINUX_REV=`cat /etc/debian_version | cut -d . -f 1` + elif test -f /etc/slackware-version; then + LINUX_DIST='slackware' + LINUX_REV=`cat /etc/slackware-version | cut -d ' ' -f 2 | cut -d . -f 1,2` + elif test -f /etc/redhat-release; then + LINUX_DIST='redhat' + LINUX_REV=`cat /etc/redhat-release | sed s/.*release\ // | sed s/\ .*// | cut -f 1 -d .` + elif test -f /etc/fedora-release; then + LINUX_DIST='redhat' + LINUX_REV=`cat /etc/fedora-release | cut -f 3 -d ' '` + elif test -f /etc/SuSE-release; then + grep "SUSE Linux Enterprise Server" /etc/SuSE-release + if test $? = 0; then + LINUX_DIST='sles' + LINUX_REV=`grep VERSION /etc/SuSE-release | cut -f 3 -d ' '` + else + LINUX_DIST='suse' + LINUX_REV=`grep VERSION /etc/SuSE-release | cut -f 3 -d ' '` + fi + else + LINUX_DIST='unknown' + LINUX_REV='unknown' + fi + fi + ;; + + FreeBSD*) PLATFORM=FREEBSD + OS_MAJOR_VERSION=`echo $UNAME_RELEASE | cut -d . -f 1` + OS_MINOR_VERSION=`echo $UNAME_RELEASE | cut -d . -f 2 | cut -d - -f 1` + ;; + + OpenBSD*) PLATFORM=OPENBSD + OS_MAJOR_VERSION=`echo $UNAME_RELEASE | cut -d . -f 1` + OS_MINOR_VERSION=`echo $UNAME_RELEASE | cut -d . -f 2 | cut -d - -f 1` + ;; + + NetBSD*) PLATFORM=NETBSD + OS_MAJOR_VERSION=`echo $UNAME_RELEASE | cut -d . -f 1` + OS_MINOR_VERSION=`echo $UNAME_RELEASE | cut -d . -f 2` + ;; + + SunOS*) PLATFORM=SUNOS + OS_MAJOR_VERSION=`echo $UNAME_RELEASE | cut -d . -f 1` + OS_MINOR_VERSION=`echo $UNAME_RELEASE | cut -d . -f 2` + ;; + + CYGWIN_NT*) PLATFORM=CYGWIN + _tmp=`echo $UNAME_SYSTEM | cut -d - -f 2` + OS_MAJOR_VERSION=`echo $_tmp | cut -d . -f 1` + OS_MINOR_VERSION=`echo $_tmp | cut -d . -f 2` + ;; + + *) + PLATFORM=UNKNOWN + echo "Unknown platform '$UNAME_SYSTEM $UNAME_RELEASE'" + exit 1 + esac + + # the architecture + + case "$UNAME_MACHINE" in + i*86*) ARCH=x86 + ;; + x86_64|amd64) ARCH=x86_64 + ;; + sun4u) ARCH=sun4u + ;; + + *) ARCH=UNKNOWN + echo "Unknown architecture '$UNAME_MACHINE'" + exit 1 + + esac + + # get last line, old 'tail' syntax and POSIX syntax, both exist out there + if test "x${PLATFORM}" = "xSUNOS"; then + TAIL1='tail -1' + else + TAIL1='tail -n 1' + fi + + # the compiler and version + + # do we have ccache or distcc in CC, then check the compiler, not the wrapper + CC=$2 + CC=`echo $CC | sed 's/distcc//g' | sed 's/ccache//g'` + + # what compiler do we have (we can't relly on it's name as it may be a cc link to the binary!) + (( $CC -v 2>&1 | $TAIL1 ) | grep -i GCC ) 2>/dev/null 1>/dev/null if test $? = 0; then - COMPILER='tcc' + COMPILER='gcc' else - ( $CC -V 2>&1 | grep l_cproc_p ) >/dev/null + # ( $CC -V 2>&1 | grep l_cproc_p ) >/dev/null + ( $CC -V 2>&1 | grep "Intel(R) C" | grep "Compiler" ) >/dev/null if test $? = 0; then COMPILER='icc' else @@ -105,120 +156,102 @@ else if test $? = 0; then COMPILER='spro' else - ( $CC -v | head -n 1 | grep 'pcc' ) >/dev/null - if test $? = 0; then - COMPILER='pcc' - else - COMPILER='unknown' - fi + COMPILER='unknown' fi fi fi -fi - -# version of gcc (GNU C compiler) -if test $COMPILER = "gcc"; then - GCC_VERSION=`gcc -dumpversion` - GCC_MAJOR_VERSION=`echo $GCC_VERSION | cut -d . -f 1` - GCC_MINOR_VERSION=`echo $GCC_VERSION | cut -d . -f 2` -fi + # version of gcc (GNU C compiler) -# version of tcc (Tiny C compiler) + if test $COMPILER = "gcc"; then + GCC_VERSION=`gcc -dumpversion` + GCC_MAJOR_VERSION=`echo $GCC_VERSION | cut -d . -f 1` + GCC_MINOR_VERSION=`echo $GCC_VERSION | cut -d . -f 2` + fi -if test $COMPILER = "tcc"; then - TCC_VERSION=`tcc -v | cut -d ' ' -f 3` - TCC_MAJOR_VERSION=`echo $ICC_VERSION | cut -d . -f 1` - TCC_MINOR_VERSION=`echo $ICC_VERSION | cut -d . -f 2` -fi + # version of icc (Intel C compiler) -# version of icc (Intel C compiler) + if test $COMPILER = "icc"; then + ICC_VERSION=`icc -dumpversion` + ICC_MAJOR_VERSION=`echo $ICC_VERSION | cut -d . -f 1` + ICC_MINOR_VERSION=`echo $ICC_VERSION | cut -d . -f 2` + fi -if test $COMPILER = "icc"; then - ICC_VERSION=`icc -dumpversion` - ICC_MAJOR_VERSION=`echo $ICC_VERSION | cut -d . -f 1` - ICC_MINOR_VERSION=`echo $ICC_VERSION | cut -d . -f 2` -fi + # version of spro (Sun Pro compiler, Sun Studio) -# version of spro (Sun Pro compiler, Sun Studio) + if test $COMPILER = "spro"; then + SPRO_VERSION=`$CC -xhelp=readme | head -n 1 | cut -d ' ' -f 3` + SPRO_MAJOR_VERSION=`echo $SPRO_VERSION | cut -d : -f 1` + fi -if test $COMPILER = "spro"; then - SPRO_VERSION=`$CC -xhelp=readme | head -n 1 | cut -d ' ' -f 3` - SPRO_MAJOR_VERSION=`echo $SPRO_VERSION | cut -d : -f 1` -fi + # generate the makefile snippet with conditional variables + # (conditional, so that users can overwrite them for instance + # for cross-compilation) + cat >"${MAKEFILE_DIR}/makefiles/gmake/platform.mk.vars" <<EOF +ARCH?=$ARCH +PLATFORM?=$PLATFORM +OS_MAJOR_VERSION?=$OS_MAJOR_VERSION +OS_MINOR_VERSION?=$OS_MINOR_VERSION +COMPILER?=$COMPILER +GCC_MAJOR_VERSION?=$GCC_MAJOR_VERSION +GCC_MINOR_VERSION?=$GCC_MINOR_VERSION +ICC_MAJOR_VERSION?=$ICC_MAJOR_VERSION +ICC_MINOR_VERSION?=$ICC_MINOR_VERSION +SPRO_MAJOR_VERSION?=$SPRO_MAJOR_VERSION +LINUX_DIST?=$LINUX_DIST +LINUX_REV?=$LINUX_REV +EOF -# version of pcc (Portable C Compiler) + # write the cache file (to protect against constant recomputations!) + cat >"${MAKEFILE_DIR}/makefiles/gmake/platform.vars" <<EOF +ARCH=$ARCH +PLATFORM=$PLATFORM +OS_MAJOR_VERSION=$OS_MAJOR_VERSION +OS_MINOR_VERSION=$OS_MINOR_VERSION +COMPILER=$COMPILER +GCC_MAJOR_VERSION=$GCC_MAJOR_VERSION +GCC_MINOR_VERSION=$GCC_MINOR_VERSION +ICC_MAJOR_VERSION=$ICC_MAJOR_VERSION +ICC_MINOR_VERSION=$ICC_MINOR_VERSION +SPRO_MAJOR_VERSION=$SPRO_MAJOR_VERSION +LINUX_DIST=$LINUX_DIST +LINUX_REV=$LINUX_REV +EOF -if test $COMPILER = "pcc"; then - PCC_VERSION=`$CC -v | head -n 1 | cut -d ' ' -f 2` - PCC_MAJOR_VERSION=`echo $PCC_VERSION | cut -d . -f 1` - PCC_MINOR_VERSION=`echo $PCC_VERSION | cut -d . -f 2` fi case "$1" in --platform) echo $PLATFORM ;; - + --os-major-version) echo $OS_MAJOR_VERSION ;; - + --os-minor-version) echo $OS_MINOR_VERSION ;; - + --arch) echo $ARCH ;; --compiler) echo $COMPILER ;; - + --gcc-major-version) echo $GCC_MAJOR_VERSION ;; - + --gcc-minor-version) echo $GCC_MINOR_VERSION ;; - --tcc-major-version) echo $TCC_MAJOR_VERSION - ;; - - --tcc-minor-version) echo $TCC_MINOR_VERSION - ;; - --icc-major-version) echo $ICC_MAJOR_VERSION ;; - + --icc-minor-version) echo $ICC_MINOR_VERSION ;; - + --spro-major-version) echo $SPRO_MAJOR_VERSION ;; - --pcc-major-version) echo $PCC_MAJOR_VERSION - ;; - - --pcc-minor-version) echo $PCC_MINOR_VERSION - ;; + *) echo "unkown flag '$1' requested!" + exit 1 esac -MAKEFILE_DIR="$3/$4" - -# regenerate the cache file, otherwise building is far too slow! -if test ! -f "${MAKEFILE_DIR}/makefiles/gmake/platform.mk.vars"; then - cat >"${MAKEFILE_DIR}/makefiles/gmake/platform.mk.vars" <<EOF -ARCH=$ARCH -PLATFORM=$PLATFORM -OS_MAJOR_VERSION=$OS_MAJOR_VERSION -OS_MINOR_VERSION=$OS_MINOR_VERSION -COMPILER=$COMPILER -GCC_MAJOR_VERSION=$GCC_MAJOR_VERSION -GCC_MINOR_VERSION=$GCC_MINOR_VERSION -TCC_MAJOR_VERSION=$TCC_MAJOR_VERSION -TCC_MINOR_VERSION=$TCC_MINOR_VERSION -ICC_MAJOR_VERSION=$ICC_MAJOR_VERSION -ICC_MINOR_VERSION=$ICC_MINOR_VERSION -SPRO_MAJOR_VERSION=$SPRO_MAJOR_VERSION -PCC_MAJOR_VERSION=$PCC_MAJOR_VERSION -PCC_MINOR_VERSION=$PCC_MINOR_VERSION -LINUX_DIST=$LINUX_DIST -LINUX_REV=$LINUX_REV -EOF -fi diff --git a/makefiles/gmake/help.mk b/makefiles/gmake/help.mk index fc7e321..b5ffa62 100644 --- a/makefiles/gmake/help.mk +++ b/makefiles/gmake/help.mk @@ -10,6 +10,31 @@ make install install (set 'DESTDIR' and 'prefix' at will) make uninstall uninstall (set 'DESTDIR' and 'prefix' at will) make dist[-Z|-gz|-bz2] create tarball containing all sources make help show this very help page +make config show the configuration used during build make init-po create initial version of the gettext files make merge-po merge the gettext files after changes make check-po check sanity of gettext files + +Available optional features: + +frontier implementations: + +WITH_SYSTEM_SQLITE3=1 use the system version of sqlite3 +WITH_LOCAL_SQLITE=1 use the bundled version of sqlite3 +WITH_PGSQL=1 build the Postgresql frontier + +fetcher protocol implementations: + +WITH_SYSTEM_LIBFETCH=1 use the system version of BSD libfetch +WITH_LOCAL_LIBFETCH=1 use the bundled version of BSD libfetch + +parser implementations: + +WITH_LIBXML2=1 build the libxml2 parser + +Some more obscure options: + +ENABLE_NLS=0 Don't build gettext NLS support (default is on) + +Example: +make WITH_SQLITE3=1 WITH_PGSQL=1 WITH_LIBXML2=1 diff --git a/makefiles/gmake/i18n.mk b/makefiles/gmake/i18n.mk index 08a29e4..689407e 100644 --- a/makefiles/gmake/i18n.mk +++ b/makefiles/gmake/i18n.mk @@ -74,17 +74,17 @@ all_po: $(MO_FILES) install_po: @test -z "$(GETTEXT_LANGUAGES)" || \ for lang in $(GETTEXT_LANGUAGES)""; do ( \ - echo "installing po/$$lang.mo to $(localedir)/$$lang/LC_MESSAGES.." && \ - $(INSTALL) -d -m 755 $(localedir)/$$lang/LC_MESSAGES && \ - $(INSTALL) -m 644 po/$$lang.mo $(localedir)/$$lang/LC_MESSAGES/$(CATALOG_NAME).mo || exit 1 \ + echo "installing po/$$lang.mo to $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES.." && \ + $(INSTALL) -d -m 755 $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES && \ + $(INSTALL) -m 644 po/$$lang.mo $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(CATALOG_NAME).mo || exit 1 \ ) done uninstall_po: @test -z "$(GETTEXT_LANGUAGES)" || \ for lang in $(GETTEXT_LANGUAGES)""; do ( \ - echo "uninstalling $(localedir)/$$lang/LC_MESSAGES.." && \ - rm $(localedir)/$$lang/LC_MESSAGES/$(CATALOG_NAME).mo && \ - rmdir $(localedir)/$$lang/LC_MESSAGES || exit 1 \ + echo "uninstalling $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES.." && \ + rm $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(CATALOG_NAME).mo && \ + rmdir $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES || exit 1 \ ) done else diff --git a/makefiles/gmake/install.mk b/makefiles/gmake/install.mk index ac6d49d..ac8090b 100644 --- a/makefiles/gmake/install.mk +++ b/makefiles/gmake/install.mk @@ -13,10 +13,10 @@ DESTDIR= prefix=/usr # standard directories following FHS -execdir=$(DESTDIR)$(prefix) +execdir=$(prefix) bindir=$(execdir)/bin sbindir=$(execdir)/sbin -libdir=$(execdir)/lib +libdir=$(execdir)/$(LIBDIR) sysconfdir=$(execdir)/etc includedir=$(execdir)/include datadir=$(execdir)/share @@ -29,20 +29,20 @@ install_recursive: (set -e; $(MAKE) -C $$d install || exit 1); done) install: install_recursive local_install install_po - @test -d "$(libdir)" || mkdir -p "$(libdir)" + @test -d "$(DESTDIR)$(libdir)/$(PACKAGE_NAME)" || mkdir -p "$(DESTDIR)$(libdir)/$(PACKAGE_NAME)" @test -z "$(STATIC_LIB)" || ( \ - $(INSTALL) -m 644 $(STATIC_LIB) $(libdir)/$(STATIC_LIB) ) + $(INSTALL) -m 644 $(STATIC_LIB) $(DESTDIR)$(libdir)/$(PACKAGE_NAME)/$(STATIC_LIB) ) @test -z "$(DYNAMIC_LIB)" || ( \ $(INSTALL) -m 755 $(DYNAMIC_LIB).$(DYNAMIC_LIB_MAJOR).$(DYNAMIC_LIB_MINOR).$(DYNAMIC_LIB_PATCH) \ - $(libdir)/$(DYNAMIC_LIB).$(DYNAMIC_LIB_MAJOR).$(DYNAMIC_LIB_MINOR).$(DYNAMIC_LIB_PATCH) ) + $(DESTDIR)$(libdir)/$(PACKAGE_NAME)/$(DYNAMIC_LIB).$(DYNAMIC_LIB_MAJOR).$(DYNAMIC_LIB_MINOR).$(DYNAMIC_LIB_PATCH) ) @test -z "$(DYNAMIC_LIB)" || ( \ - rm -f "$(libdir)/$(DYNAMIC_LIB).$(DYNAMIC_LIB_MAJOR)" && \ + rm -f "$(DESTDIR)$(libdir)/$(PACKAGE_NAME)/$(DYNAMIC_LIB).$(DYNAMIC_LIB_MAJOR)" && \ ln -s "$(DYNAMIC_LIB).$(DYNAMIC_LIB_MAJOR).$(DYNAMIC_LIB_MINOR).$(DYNAMIC_LIB_PATCH)" \ - "$(libdir)/$(DYNAMIC_LIB).$(DYNAMIC_LIB_MAJOR)" ) + "$(DESTDIR)$(libdir)/$(PACKAGE_NAME)/$(DYNAMIC_LIB).$(DYNAMIC_LIB_MAJOR)" ) @test -z "$(DYNAMIC_LIB)" || ( \ - rm -f "$(libdir)/$(DYNAMIC_LIB)" && \ + rm -f "$(DESTDIR)$(libdir)/$(PACKAGE_NAME)/$(DYNAMIC_LIB)" && \ ln -s "$(DYNAMIC_LIB).$(DYNAMIC_LIB_MAJOR).$(DYNAMIC_LIB_MINOR).$(DYNAMIC_LIB_PATCH)" \ - "$(libdir)/$(DYNAMIC_LIB)" ) + "$(DESTDIR)$(libdir)/$(PACKAGE_NAME)/$(DYNAMIC_LIB)" ) .PHONY: uninstall_recursive uninstall local_uninstall @@ -51,14 +51,14 @@ uninstall_recursive: (set -e; $(MAKE) -C $$d uninstall || exit 1); done) uninstall: uninstall_recursive local_uninstall uninstall_po - test -z "$(DYNAMIC_LIB)" || ( \ - test ! -f "$(libdir)/$(DYNAMIC_LIB).$(DYNAMIC_LIB_MAJOR).$(DYNAMIC_LIB_MINOR).$(DYNAMIC_LIB_PATCH)" || \ - rm "$(libdir)/$(DYNAMIC_LIB).$(DYNAMIC_LIB_MAJOR).$(DYNAMIC_LIB_MINOR).$(DYNAMIC_LIB_PATCH)" ) - test -z "$(DYNAMIC_LIB)" || ( \ - test ! -h "$(libdir)/$(DYNAMIC_LIB).$(DYNAMIC_LIB_MAJOR)" || \ - rm "$(libdir)/$(DYNAMIC_LIB).$(DYNAMIC_LIB_MAJOR)" ) - test -z "$(DYNAMIC_LIB)" || ( \ - test ! -h "$(libdir)/$(DYNAMIC_LIB)" || \ - rm "$(libdir)/$(DYNAMIC_LIB)" ) - test -z "$(STATIC_LIB)" || ( \ - test ! -f "$(libdir)/$(STATIC_LIB)" || rm "$(libdir)/$(STATIC_LIB)" ) + @test -z "$(DYNAMIC_LIB)" || ( \ + test ! -f "$(DESTDIR)$(libdir)/$(PACKAGE_NAME)/$(DYNAMIC_LIB).$(DYNAMIC_LIB_MAJOR).$(DYNAMIC_LIB_MINOR).$(DYNAMIC_LIB_PATCH)" || \ + rm "$(DESTDIR)$(libdir)/$(PACKAGE_NAME)/$(DYNAMIC_LIB).$(DYNAMIC_LIB_MAJOR).$(DYNAMIC_LIB_MINOR).$(DYNAMIC_LIB_PATCH)" ) + @test -z "$(DYNAMIC_LIB)" || ( \ + test ! -h "$(DESTDIR)$(libdir)/$(PACKAGE_NAME)/$(DYNAMIC_LIB).$(DYNAMIC_LIB_MAJOR)" || \ + rm "$(DESTDIR)$(libdir)/$(PACKAGE_NAME)/$(DYNAMIC_LIB).$(DYNAMIC_LIB_MAJOR)" ) + @test -z "$(DYNAMIC_LIB)" || ( \ + test ! -h "$(DESTDIR)$(libdir)/$(PACKAGE_NAME)/$(DYNAMIC_LIB)" || \ + rm "$(DESTDIR)$(libdir)/$(PACKAGE_NAME)/$(DYNAMIC_LIB)" ) + @test -z "$(STATIC_LIB)" || ( \ + test ! -f "$(DESTDIR)$(libdir)/$(PACKAGE_NAME)/$(STATIC_LIB)" || rm "$(DESTDIR)$(libdir)/$(PACKAGE_NAME)/$(STATIC_LIB)" ) diff --git a/makefiles/gmake/libs.mk b/makefiles/gmake/libs.mk index 08899c3..ada9853 100644 --- a/makefiles/gmake/libs.mk +++ b/makefiles/gmake/libs.mk @@ -3,39 +3,67 @@ # requires: # - STATIC_LIB: name of the static library # - DYNAMIC_LIB: soname and versions of the shared library +# - DYNAMIC_MODULE: loadable module (for dlopen) +# # - all others like OBJS, CPP_OBJS, LIBS, SH_OBJS, SHPP_OBJS, LDFLAGS # # provides: # - targets to build the static and dynamic version of the project's library +# - targets to build the loadable module (no soname and funny installation +# rules here) # +# the soname of the shared library +ifneq "$(DYNAMIC_LIB)" "" +SONAME=$(DYNAMIC_LIB).$(DYNAMIC_LIB_MAJOR) +endif + +# SONAME_FLAGS to indicate to the platform linker, we want to fiddle in the +# ELF header (more plaform/linker dependant than compiler dependant) + ifeq "$(PLATFORM)" "LINUX" -SO_FLAGS = -shared -Wl,-soname,$(DYNAMIC_LIB).$(DYNAMIC_LIB_MAJOR) +SONAME_FLAGS=-Wl,-soname,$(SONAME) endif ifeq "$(PLATFORM)" "SUNOS" -ifeq "$(COMPILER)" "gcc" -SO_FLAGS = -shared -Wl,-h,$(DYNAMIC_LIB).$(DYNAMIC_LIB_MAJOR) +ifeq "$(COMPILER)" "gcc" +SONAME_FLAGS=-Wl,-h,$(SONAME) endif ifeq "$(COMPILER)" "spro" -SO_FLAGS = -G -h $(DYNAMIC_LIB).$(DYNAMIC_LIB_MAJOR) +SONAME_FLAGS=-h $(SONAME) endif endif ifeq "$(PLATFORM)" "FREEBSD" -SO_FLAGS = -shared -Wl,-x,-soname,$(DYNAMIC_LIB).$(DYNAMIC_LIB_MAJOR) +SONAME_FLAGS=-Wl,-x,-soname,$(SONAME) endif ifeq "$(PLATFORM)" "OPENBSD" -SO_FLAGS = -shared -Wl,-soname,$(DYNAMIC_LIB).$(DYNAMIC_LIB_MAJOR) +SONAME_FLAGS=-Wl,-soname,$(SONAME) endif ifeq "$(PLATFORM)" "NETBSD" -SO_FLAGS = -shared -Wl,-soname,$(DYNAMIC_LIB).$(DYNAMIC_LIB_MAJOR) +SONAME_FLAGS=-Wl,-soname,$(SONAME) endif ifeq "$(PLATFORM)" "CYGWIN" -SO_FLAGS = -shared -Wl,-soname,$(DYNAMIC_LIB).$(DYNAMIC_LIB_MAJOR) +SONAME_FLAGS=-Wl,-soname,$(SONAME) +endif + +# no soname and versioning for loadable modules, just dynamic linking +ifneq "$(DYNAMIC_MODULE)" "" +SONAME_FLAGS= +endif + +# indicate we want to link shared, depends actually on the compiler more +# than on the platform +ifeq "$(COMPILER)" "gcc" +SO_LIB_FLAGS = -shared $(SONAME_FLAGS) +SO_MOD_FLAGS = -shared +endif +ifeq "$(COMPILER)" "spro" +SO_LIB_FLAGS = -G $(SONAME_FLAGS) +SO_MOD_FLAGS = -G endif ifneq "$(STATIC_LIB)" "" @@ -47,7 +75,24 @@ endif ifneq "$(DYNAMIC_LIB)" "" $(DYNAMIC_LIB).$(DYNAMIC_LIB_MAJOR).$(DYNAMIC_LIB_MINOR).$(DYNAMIC_LIB_PATCH) : $(SH_OBJS) $(SHPP_OBJS) - $(CCPP_LINK) $(SO_FLAGS) -o $@ $(LDFLAGS) $(SH_OBJS) $(SHPP_OBJS) $(LIBS) + $(CXX_LINK) $(SO_LIB_FLAGS) -o $@ $(ALL_LDFLAGS) $(SH_OBJS) $(SHPP_OBJS) $(LIBS) +$(DYNAMIC_LIB).$(DYNAMIC_LIB_MAJOR) : $(DYNAMIC_LIB).$(DYNAMIC_LIB_MAJOR).$(DYNAMIC_LIB_MINOR).$(DYNAMIC_LIB_PATCH) + @test -z "$(DYNAMIC_LIB)" || ( \ + rm -f "$(DYNAMIC_LIB).$(DYNAMIC_LIB_MAJOR)" && \ + ln -s "$(DYNAMIC_LIB).$(DYNAMIC_LIB_MAJOR).$(DYNAMIC_LIB_MINOR).$(DYNAMIC_LIB_PATCH)" \ + "$(DYNAMIC_LIB).$(DYNAMIC_LIB_MAJOR)" ) +$(DYNAMIC_LIB) : $(DYNAMIC_LIB).$(DYNAMIC_LIB_MAJOR).$(DYNAMIC_LIB_MINOR).$(DYNAMIC_LIB_PATCH) + @test -z "$(DYNAMIC_LIB)" || ( \ + rm -f "$(DYNAMIC_LIB)" && \ + ln -s "$(DYNAMIC_LIB).$(DYNAMIC_LIB_MAJOR).$(DYNAMIC_LIB_MINOR).$(DYNAMIC_LIB_PATCH)" \ + "$(DYNAMIC_LIB)" ) else $(DYNAMIC_LIB).$(DYNAMIC_LIB_MAJOR).$(DYNAMIC_LIB_MINOR).$(DYNAMIC_LIB_PATCH) : endif + +ifneq "$(DYNAMIC_MODULE)" "" +$(DYNAMIC_MODULE) : $(SH_OBJS) $(SHPP_OBJS) + $(CXX_LINK) $(SO_MOD_FLAGS) -o $@ $(ALL_LDFLAGS) $(SH_OBJS) $(SHPP_OBJS) $(LIBS) +else +$(DYNAMIC_MODULE) : +endif diff --git a/makefiles/gmake/platform.mk b/makefiles/gmake/platform.mk index 452c9e1..6ad041e 100644 --- a/makefiles/gmake/platform.mk +++ b/makefiles/gmake/platform.mk @@ -16,17 +16,81 @@ # # author: Andreas Baumann, abaumann at yahoo dot com +-include $(HOME)/config.mk -include $(TOPDIR)/makefiles/gmake/platform.mk.vars -PLATFORM ?= $(shell $(SHELL) $(TOPDIR)/makefiles/gmake/guess_env --platform $(CC) "$(CURDIR)" $(TOPDIR)) -OS_MAJOR_VERSION ?= $(shell $(SHELL) $(TOPDIR)/makefiles/gmake/guess_env --os-major-version $(CC) "$(CURDIR)" $(TOPDIR)) -OS_MINOR_VERSION ?= $(shell $(SHELL) $(TOPDIR)/makefiles/gmake/guess_env --os-minor-version $(CC) "$(CURDIR)" $(TOPDIR)) -COMPILER ?= $(shell $(SHELL) $(TOPDIR)/makefiles/gmake/guess_env --compiler $(CC) "$(CURDIR)" $(TOPDIR)) -ifeq "$(PLATFORM)" "LINUX" -LINUX_DIST ?= $(shell $(SHELL) $(TOPDIR)/makefiles/gmake/guess_env --linux-dist $(CC) "$(CURDIR)" $(TOPDIR)) -LINUX_REV ?= $(shell $(SHELL) $(TOPDIR)/makefiles/gmake/guess_env --linux-rev $(CC) "$(CURDIR)" $(TOPDIR)) +# set up defaults for the build switches +WITH_SSL ?= 0 +WITH_LUA ?= 0 +WITH_SASL ?= 0 +WITH_PAM ?= 0 +WITH_SYSTEM_SQLITE3 ?= 0 +WITH_LOCAL_SQLITE3 ?= 0 +WITH_PGSQL ?= 0 +WITH_LIBXML2 ?= 0 +WITH_LIBXSLT ?= 0 +WITH_SYSTEM_LIBHPDF ?= 0 +WITH_LOCAL_LIBHPDF ?= 0 +WITH_QT ?= 0 +WITH_LIBGMP ?= 0 +WITH_EXAMPLES ?= 1 +ENABLE_NLS ?= 1 +RUN_TESTS ?= 1 + +# variables guessed by 'guess_env' +PLATFORM ?= $(shell $(SHELL) $(TOPDIR)/makefiles/gmake/guess_env --platform "$(CC)" "$(CURDIR)" $(TOPDIR)) +OS_MAJOR_VERSION ?= $(shell $(SHELL) $(TOPDIR)/makefiles/gmake/guess_env --os-major-version "$(CC)" "$(CURDIR)" $(TOPDIR)) +OS_MINOR_VERSION ?= $(shell $(SHELL) $(TOPDIR)/makefiles/gmake/guess_env --os-minor-version "$(CC)" "$(CURDIR)" $(TOPDIR)) +COMPILER ?= $(shell $(SHELL) $(TOPDIR)/makefiles/gmake/guess_env --compiler "$(CC)" "$(CURDIR)" $(TOPDIR)) +ifeq "$(PLATFORM)" "LINUX" +LINUX_DIST ?= $(shell $(SHELL) $(TOPDIR)/makefiles/gmake/guess_env --linux-dist "$(CC)" "$(CURDIR)" $(TOPDIR)) +LINUX_REV ?= $(shell $(SHELL) $(TOPDIR)/makefiles/gmake/guess_env --linux-rev "$(CC)" "$(CURDIR)" $(TOPDIR)) +endif + +# set library path on Intel/AMD + +ifeq "$(PLATFORM)" "LINUX" +ifeq "$(ARCH)" "x86" +ifeq "$(LINUX_DIST)" "arch" +LIBDIR=lib32 +else +LIBDIR=lib +endif +else +LIBDIR=lib +endif +ifeq "$(ARCH)" "x86_64" +ifeq "$(LINUX_DIST)" "arch" +LIBDIR=lib +else +LIBDIR=lib64 +endif +else +LIBDIR=lib +endif +endif + +ifeq "$(PLATFORM)" "FREEBSD" +LIBDIR=lib endif +ifeq "$(PLATFORM)" "OPENBSD" +LIBDIR=lib +endif + +ifeq "$(PLATFORM)" "NETBSD" +LIBDIR=lib +endif + +# Sparc or Intel, always 'lib' +ifeq "$(PLATFORM)" "SUNOS" +LIBDIR=lib +endif + + +# default location of system libraries per architecture +SYSTEM_LIBDIR=/usr/$(LIBDIR) + # platform specific flags ######################### @@ -53,12 +117,14 @@ SO = .so # name if the installation program # (TODO: use the MIT or openradio install-sh script instead?) +ifndef INSTALL INSTALL = $(shell $(SHELL) $(TOPDIR)/makefiles/gmake/guess_env --install) ifeq "$(PLATFORM)" "SUNOS" INSTALL = /usr/ucb/install else INSTALL = install endif +endif # dynamic linker ################ @@ -72,12 +138,25 @@ else LIBS_DL = endif +# Note for dlopen to work (at least on FreeBSD) with rtti information we have to export all symbols +# in the binary and in the modules (see http://stackoverflow.com/questions/2351786/dynamic-cast-fails-when-used-with-dlopen-dlsym) +LDFLAGS_DL = +ifeq "$(PLATFORM)" "LINUX" +LDFLAGS_DL = -Wl,-E +endif +ifeq "$(PLATFORM)" "FREEBSD" +LDFLAGS_DL = -Wl,-E +endif +ifeq "$(PLATFORM)" "OPENBSD" +LDFLAGS_DL = -Wl,-E +endif +ifeq "$(PLATFORM)" "NETBSD" +LDFLAGS_DL = -Wl,-E +endif + # i18n, gettext/libintl ####################### -# enable or disable internationalization code -ENABLE_NLS = 1 - ifeq "$(ENABLE_NLS)" "1" # we relly only on the GNU version, other versions (e.g. Solaris) are not @@ -95,8 +174,9 @@ LIBS_LT = endif ifeq "$(PLATFORM)" "SUNOS" -INCLUDE_FLAGS_LT = -I/usr/local/include -LDFLAGS_LT = -L/usr/local/lib +LIBLT_DIR ?= /usr/local +INCLUDE_FLAGS_LT = -I$(LIBLT_DIR)/include +LDFLAGS_LT = -L$(LIBLT_DIR)/lib LIBS_LT = -lintl endif @@ -112,13 +192,13 @@ LDFLAGS_LT = -L/usr/local/lib LIBS_LT = -lintl -liconv endif -ifeq "$(PLATFORM)" "CYGWIN" +ifeq "$(PLATFORM)" "NETBSD" INCLUDE_FLAGS_LT = LDFLAGS_LT = LIBS_LT = -lintl endif -ifeq "$(PLATFORM)" "NETBSD" +ifeq "$(PLATFORM)" "CYGWIN" INCLUDE_FLAGS_LT = LDFLAGS_LT = LIBS_LT = -lintl @@ -192,44 +272,3 @@ endif PLATFORM_COMPILE_FLAGS += $(INCLUDE_FLAGS_NET) -# sqlite3 -######### - -# the GNU internationalization support is sometimes in separate libarries -ifeq "$(PLATFORM)" "LINUX" -INCLUDE_FLAGS_SQLITE3 = -I/usr/include -LDFLAGS_SQLITE3 = -L/usr/lib -LIBS_SQLITE3 = -lsqlite3 -endif - -ifeq "$(PLATFORM)" "SUNOS" -INCLUDE_FLAGS_SQLITE3 = -LDFLAGS_SQLITE3 = -LIBS_SQLITE3 = -lsqlite3 -endif - -ifeq "$(PLATFORM)" "FREEBSD" -INCLUDE_FLAGS_SQLITE3 = -LDFLAGS_SQLITE3 = -LIBS_SQLITE3 = -lsqlite3 -endif - -ifeq "$(PLATFORM)" "OPENBSD" -INCLUDE_FLAGS_SQLITE3 = -LDFLAGS_SQLITE3 = -LIBS_SQLITE3 = -lsqlite3 -endif - -ifeq "$(PLATFORM)" "CYGWIN" -INCLUDE_FLAGS_SQLITE3 = -LDFLAGS_SQLITE3 = -LIBS_SQLITE3 = -lsqlite3 -endif - -ifeq "$(PLATFORM)" "NETBSD" -INCLUDE_FLAGS_SQLITE3 = -I/usr/pkg/include -LDFLAGS_SQLITE3 = -L/usr/pkg/lib -LIBS_SQLITE3 = -lsqlite3 -endif - -PLATFORM_COMPILE_FLAGS += $(INCLUDE_FLAGS_SQLITE3) diff --git a/makefiles/gmake/sub.mk b/makefiles/gmake/sub.mk index 962c63f..5e4bf63 100644 --- a/makefiles/gmake/sub.mk +++ b/makefiles/gmake/sub.mk @@ -11,16 +11,23 @@ -include $(TOPDIR)/makefiles/gmake/platform.mk -include $(TOPDIR)/makefiles/gmake/compiler.mk -.PHONY: all $(SUBDIRS) local_all -all: $(OBJS) $(CPPOBJS) $(BIN_OBJS) $(CPP_BIN_OBJS) $(BINS) $(CPP_BINS) $(CMODULES) $(CPPMODULES) $(STATIC_LIB) $(DYNAMIC_LIB).$(DYNAMIC_LIB_MAJOR).$(DYNAMIC_LIB_MINOR).$(DYNAMIC_LIB_PATCH) local_all all_po - @test -z "$(SUBDIRS)" || ( set -e; for d in $(SUBDIRS)""; do \ - (set -e; $(MAKE) -C $$d all || exit 1); done) +.PHONY: all subdirs $(SUBDIRS) local_all +all: subdirs depend $(BINS) $(CPP_BINS) $(STATIC_LIB) $(DYNAMIC_LIB).$(DYNAMIC_LIB_MAJOR).$(DYNAMIC_LIB_MINOR).$(DYNAMIC_LIB_PATCH) $(DYNAMIC_LIB).$(DYNAMIC_LIB_MAJOR) $(DYNAMIC_LIB) $(DYNAMIC_MODULE) local_all all_po +subdirs: $(SUBDIRS) + +$(SUBDIRS): + $(MAKE) -C $@ all .PHONY: test local_test -test: $(OBJS) $(TEST_OBJS) $(CPPOBJS) $(BIN_OBJS) $(BINS) $(CPP_BINS) $(TEST_BIN_OBJS) $(TEST_BINS) $(TEST_CPP_BINS) $(CMODULES) $(CPPMODULES) $(STATIC_LIB) local_test +test: all local_test @test -z "$(SUBDIRS)" || ( set -e; for d in $(SUBDIRS)""; do \ (set -e; $(MAKE) -C $$d test || exit 1); done) +.PHONY: longtest local_longtest +longtest: test local_longtest + @test -z "$(SUBDIRS)" || ( set -e; for d in $(SUBDIRS)""; do \ + (set -e; $(MAKE) -C $$d longtest || exit 1); done) + -include $(TOPDIR)/makefiles/gmake/depend.mk -include $(TOPDIR)/makefiles/gmake/clean.mk -include $(TOPDIR)/makefiles/gmake/install.mk diff --git a/makefiles/gmake/top.mk b/makefiles/gmake/top.mk index 810bedc..fd31b11 100644 --- a/makefiles/gmake/top.mk +++ b/makefiles/gmake/top.mk @@ -14,6 +14,7 @@ # - target 'help' # - target 'install' # - target 'uninstall' +# - target 'config' -include makefiles/gmake/platform.mk @@ -26,13 +27,15 @@ all: clean: @test -z "$(SUBDIRS)" || ( set -e; for d in $(SUBDIRS)""; do \ (set -e; $(MAKE) -C $$d clean || exit 1); done) - @-rm $(TOPDIR)/makefiles/gmake/platform.mk.vars + @-test ! -f $(TOPDIR)/makefiles/gmake/platform.mk.vars && rm $(TOPDIR)/makefiles/gmake/platform.mk.vars + @-test ! -f $(TOPDIR)/makefiles/gmake/platform.vars || rm $(TOPDIR)/makefiles/gmake/platform.vars .PHONY: distclean distclean: @test -z "$(SUBDIRS)" || ( set -e; for d in $(SUBDIRS)""; do \ (set -e; $(MAKE) -C $$d distclean || exit 1); done) - @-rm $(TOPDIR)/makefiles/gmake/platform.mk.vars + @-test ! -f $(TOPDIR)/makefiles/gmake/platform.mk.vars || rm $(TOPDIR)/makefiles/gmake/platform.mk.vars + @-test ! -f $(TOPDIR)/makefiles/gmake/platform.vars || rm $(TOPDIR)/makefiles/gmake/platform.vars .PHONY: install install: @@ -46,16 +49,69 @@ uninstall: .PHONY: test test: all - @$(MAKE) -C tests test + @test -z "$(SUBDIRS)" || ( set -e; for d in $(SUBDIRS)""; do \ + (set -e; $(MAKE) -C $$d test || exit 1); done) -.PHONY: doc -doc: - cd docs; $(MAKE) doc +.PHONY: longtest +longtest: test + @test -z "$(SUBDIRS)" || ( set -e; for d in $(SUBDIRS)""; do \ + (set -e; $(MAKE) -C $$d longtest || exit 1); done) .PHONY: help help: @cat $(TOPDIR)/makefiles/gmake/help.mk +.PHONY: config +config: + @echo "Build Configuration for CrawlingWolf" + @echo "------------------------------------" + @echo + @echo "Operating system: $(PLATFORM), $(OS_MAJOR_VERSION).$(OS_MINOR_VERSION)" + @echo "Architecture: $(ARCH)" + @echo "System library directory: $(LIBDIR)" +ifeq "$(PLATFORM)" "LINUX" + @echo "Linux distribution: $(LINUX_DIST) $(LINUX_REV)" +endif + @echo "C++ Compiler: $(COMPILER)" + @echo + @echo "Optional Dependencies:" +ifeq ($(WITH_SQLITE3),1) +ifeq ($(WITH_SYSTEM_SQLITE3),1) + @echo + @echo "SQLITE3_DIR: $(SQLITE3_DIR)" + @echo "SQLITE3_INCLUDE_DIR: $(SQLITE3_INCLUDE_DIR)" + @echo "SQLITE3_LIB_DIR: $(SQLITE3_LIB_DIR)" + @echo "SQLITE3_LIBS: $(SQLITE3_LIBS)" +endif +ifeq ($(WITH_LOCAL_SQLITE3),1) + @echo + @echo "using local Sqlite3 amalgamation sources.." +endif +endif +ifeq ($(WITH_PGSQL),1) + @echo + @echo "PGSQL_DIR: $(PGSQL_DIR)" + @echo "PGSQL_INCLUDE_DIRS: $(PGSQL_INCLUDE_DIRS)" + @echo "PGSQL_LIB_DIRS: $(PGSQL_LIB_DIRS)" + @echo "PGSQL_LIBS: $(PGSQL_LIBS)" +endif +ifeq ($(WITH_LIBXML2),1) + @echo + @echo "LIBXML2_DIR: $(LIBXML2_DIR)" + @echo "LIBXML2_INCLUDE_DIRS: $(LIBXML2_INCLUDE_DIRS)" + @echo "LIBXML2_LIB_DIRS: $(LIBXML2_LIB_DIRS)" + @echo "LIBXML2_LIBS: $(LIBXML2_LIBS)" +endif + @echo + @echo "Additional build options:" + @echo +ifeq ($(ENABLE_NLS),0) + @echo "NLS support is disabled" +else + @echo "NLS support is enabled" +endif + @echo + .PHONY: init-po init-po: @test -z "$(SUBDIRS)" || ( set -e; for d in $(SUBDIRS)""; do \ |