From 136c4f2fe9e1b7df2929c240e5a94973f596a259 Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Mon, 11 Apr 2005 22:02:48 +0000 Subject: [PATCH] Rewritten Makefiles to support separated source and object trees. The source tree is now strictly read-only, which simplified several things, but also let me struggle for 4 hours with GNU make bugs and misfeatures. --- build/Makefile | 2 +- build/check-customs | 39 ++++++++++------------- charset/Makefile | 16 +++++----- lib/Makefile | 62 ++++++++++++++++++------------------- lib/perl/Makefile | 4 +-- lib/perl/Ulimit/.cvsignore | 6 ---- lib/perl/Ulimit/Makefile | 22 ++++++------- lib/perl/Ulimit/Makefile.PL | 1 - lib/regex/Makefile | 2 +- lib/shell/Makefile | 6 ++-- 10 files changed, 71 insertions(+), 89 deletions(-) delete mode 100644 lib/perl/Ulimit/.cvsignore diff --git a/build/Makefile b/build/Makefile index 4544625a..0e06791c 100644 --- a/build/Makefile +++ b/build/Makefile @@ -2,4 +2,4 @@ DIRS+=build -obj/build/genhash: obj/build/genhash.o +$(o)/build/genhash: $(o)/build/genhash.o diff --git a/build/check-customs b/build/check-customs index 4a654c68..3c471df5 100755 --- a/build/check-customs +++ b/build/check-customs @@ -9,8 +9,9 @@ TEST=0 function try { TEST=$(($TEST+1)) - LOG=test$TEST.log - echo "### Test $TEST: $@ ###" | tee $LOG + TDIR=tests/$TEST + mkdir $TDIR + echo "### Test $TEST: $@ ###" | tee $TDIR/log CUST=$1 shift @@ -26,25 +27,22 @@ function try fi shift done - rm -rf custom - cp -a $CUST custom - sed "$SUBST;p;d" <$CUST/config.mk >custom/config.mk - echo $APP | tr ! '\n' >>custom/config.mk - make clean >>$LOG 2>&1 - rm -f run/cf/* - if ! make >>$LOG 2>&1 ; then - echo " FAILED" - exit 1 - fi - echo " PASSED" + ( + cd $TDIR + cp -a ../../$CUST custom + sed "$SUBST;p;d" <../../$CUST/config.mk >custom/config.mk + echo $APP | tr ! '\n' >>custom/config.mk + if ! make -f ../../Makefile s=../.. >>log 2>&1 ; then + echo " FAILED" + exit 1 + fi + echo " PASSED" + ) } -if [ -e custom -a ! -e custom.old ] ; then - mv custom custom.old -fi - -rm -f test*.log +rm -rf tests +mkdir tests if [ -n "$1" ] ; then try "$@" else @@ -59,8 +57,3 @@ else try debug/custom CONFIG_SHARED=1 # debugging configuration with shared libs try debug/custom # debugging configuration fi - -rm -rf custom -if [ -e custom.old ] ; then - mv custom.old custom -fi diff --git a/charset/Makefile b/charset/Makefile index 115b0bb1..64a8119e 100644 --- a/charset/Makefile +++ b/charset/Makefile @@ -5,16 +5,16 @@ DIRS+=charset LIBCHARSET_MODS=toupper tolower tocat toligatures unaccent charconv setnames fb-charconv LIBCHARSET_INCLUDES=charconv.h unicat.h fb-charconv.h -obj/charset/libcharset.a: $(addsuffix .o,$(addprefix obj/charset/,$(LIBCHARSET_MODS))) -obj/charset/libcharset.so: $(addsuffix .oo,$(addprefix obj/charset/,$(LIBCHARSET_MODS))) +$(o)/charset/libcharset.a: $(addsuffix .o,$(addprefix $(o)/charset/,$(LIBCHARSET_MODS))) +$(o)/charset/libcharset.so: $(addsuffix .oo,$(addprefix $(o)/charset/,$(LIBCHARSET_MODS))) -INCLUDES+=obj/charset/.include-stamp -obj/charset/.include-stamp: $(addprefix charset/,$(LIBCHARSET_INCLUDES)) - build/install-includes charset run/include/charset $(?F) - touch obj/charset/.include-stamp +INCLUDES+=$(o)/charset/.include-stamp +$(o)/charset/.include-stamp: $(addprefix $(s)/charset/,$(LIBCHARSET_INCLUDES)) + $(s)/build/install-includes $(s)/charset run/include/charset $(?F) + touch $(o)/charset/.include-stamp build_charsets: - cd charset && sh misc/generate + cd $(s)/charset && sh misc/generate clean:: - rm -f charset/misc/u-* + rm -f $(s)/charset/misc/u-* diff --git a/lib/Makefile b/lib/Makefile index b8150ec1..a17efb2e 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -3,7 +3,7 @@ DIRS+=lib ifdef CONFIG_UCW_DBTOOL -PROGS+=obj/lib/db-tool +PROGS+=$(o)/lib/db-tool endif LIBUCW_MODS= \ @@ -51,46 +51,46 @@ LIBUCW_INCLUDES= \ qache.h ifdef CONFIG_OWN_REGEX -include lib/regex/Makefile +include $(s)/lib/regex/Makefile endif -LIBUCW=obj/lib/libucw.$(LS) -LIBUCW_MOD_PATHS=$(addprefix obj/lib/,$(LIBUCW_MODS)) +LIBUCW=$(o)/lib/libucw.$(LS) +LIBUCW_MOD_PATHS=$(addprefix $(o)/lib/,$(LIBUCW_MODS)) -obj/lib/libucw.a: $(addsuffix .o,$(LIBUCW_MOD_PATHS)) -obj/lib/libucw.so: $(addsuffix .oo,$(LIBUCW_MOD_PATHS)) +$(o)/lib/libucw.a: $(addsuffix .o,$(LIBUCW_MOD_PATHS)) +$(o)/lib/libucw.so: $(addsuffix .oo,$(LIBUCW_MOD_PATHS)) -obj/lib/hashfunc.o obj/lib/hashfunc.oo: CFLAGS += -funroll-loops -obj/lib/lizard.o: CFLAGS += -O6 -funroll-loops +$(o)/lib/hashfunc.o $(o)/lib/hashfunc.oo: CFLAGS += -funroll-loops +$(o)/lib/lizard.o: CFLAGS += -O6 -funroll-loops -obj/lib/db-test: obj/lib/db-test.o $(LIBUCW) -obj/lib/db-tool: obj/lib/db-tool.o $(LIBUCW) -obj/lib/conf-test: obj/lib/conf-test.o $(LIBUCW) -obj/lib/sort-test: obj/lib/sort-test.o $(LIBUCW) -obj/lib/lfs-test: obj/lib/lfs-test.o $(LIBUCW) -obj/lib/hash-test: obj/lib/hash-test.o $(LIBUCW) -obj/lib/str-test: obj/lib/str-test.o $(LIBUCW) -obj/lib/asort-test: obj/lib/asort-test.o $(LIBUCW) -obj/lib/redblack-test: obj/lib/redblack-test.o $(LIBUCW) -obj/lib/binheap-test: obj/lib/binheap-test.o $(LIBUCW) -obj/lib/lizard-test: obj/lib/lizard-test.o $(LIBUCW) +$(o)/lib/db-test: $(o)/lib/db-test.o $(LIBUCW) +$(o)/lib/db-tool: $(o)/lib/db-tool.o $(LIBUCW) +$(o)/lib/conf-test: $(o)/lib/conf-test.o $(LIBUCW) +$(o)/lib/sort-test: $(o)/lib/sort-test.o $(LIBUCW) +$(o)/lib/lfs-test: $(o)/lib/lfs-test.o $(LIBUCW) +$(o)/lib/hash-test: $(o)/lib/hash-test.o $(LIBUCW) +$(o)/lib/str-test: $(o)/lib/str-test.o $(LIBUCW) +$(o)/lib/asort-test: $(o)/lib/asort-test.o $(LIBUCW) +$(o)/lib/redblack-test: $(o)/lib/redblack-test.o $(LIBUCW) +$(o)/lib/binheap-test: $(o)/lib/binheap-test.o $(LIBUCW) +$(o)/lib/lizard-test: $(o)/lib/lizard-test.o $(LIBUCW) -TESTS+=$(addprefix obj/lib/,regex.test unicode-utf8.test hash-test.test mempool.test stkstring.test) -obj/lib/regex.test: obj/lib/regex-t -obj/lib/unicode-utf8.test: obj/lib/unicode-utf8-t -obj/lib/hash-test.test: obj/lib/hash-test -obj/lib/mempool.test: obj/lib/mempool-fmt-t obj/lib/mempool-str-t -obj/lib/stkstring.test: obj/lib/stkstring-t +TESTS+=$(addprefix $(o)/lib/,regex.test unicode-utf8.test hash-test.test mempool.test stkstring.test) +$(o)/lib/regex.test: $(o)/lib/regex-t +$(o)/lib/unicode-utf8.test: $(o)/lib/unicode-utf8-t +$(o)/lib/hash-test.test: $(o)/lib/hash-test +$(o)/lib/mempool.test: $(o)/lib/mempool-fmt-t $(o)/lib/mempool-str-t +$(o)/lib/stkstring.test: $(o)/lib/stkstring-t -INCLUDES+=obj/lib/.include-stamp -obj/lib/.include-stamp: $(addprefix lib/,$(LIBUCW_INCLUDES)) - build/install-includes lib run/include/lib $(?F) - touch obj/lib/.include-stamp +INCLUDES+=$(o)/lib/.include-stamp +$(o)/lib/.include-stamp: $(addprefix $(s)/lib/,$(LIBUCW_INCLUDES)) + $(s)/build/install-includes $(s)/lib run/include/lib $(?F) + touch $(o)/lib/.include-stamp ifdef CONFIG_UCW_PERL -include lib/perl/Makefile +include $(s)/lib/perl/Makefile endif ifdef CONFIG_UCW_SHELL_UTILS -include lib/shell/Makefile +include $(s)/lib/shell/Makefile endif diff --git a/lib/perl/Makefile b/lib/perl/Makefile index 8b23992f..8de91140 100644 --- a/lib/perl/Makefile +++ b/lib/perl/Makefile @@ -1,8 +1,8 @@ # Perl modules DIRS+=lib/perl -PROGS+=$(addprefix obj/lib/perl/,Config.pm) +PROGS+=$(addprefix $(o)/lib/perl/,Config.pm) ifdef CONFIG_UCW_PERL_ULIMIT -include lib/perl/Ulimit/Makefile +include $(s)/lib/perl/Ulimit/Makefile endif diff --git a/lib/perl/Ulimit/.cvsignore b/lib/perl/Ulimit/.cvsignore deleted file mode 100644 index d5f8ca3d..00000000 --- a/lib/perl/Ulimit/.cvsignore +++ /dev/null @@ -1,6 +0,0 @@ -Makefile.tmp -Ulimit.bs -Ulimit.c -arch -lib -pm_to_blib diff --git a/lib/perl/Ulimit/Makefile b/lib/perl/Ulimit/Makefile index a610ad67..4ca72d30 100644 --- a/lib/perl/Ulimit/Makefile +++ b/lib/perl/Ulimit/Makefile @@ -1,22 +1,18 @@ # Makefile for the Ulimit Perl module (c) 2003 Tomas Valla DIRS+=lib/perl/Ulimit/arch/auto/Sherlock/Ulimit - - ULIMIT_DIR=lib/perl/Ulimit -PROGS+=obj/lib/perl/Ulimit/Ulimit.pm -DATAFILES+=obj/lib/perl/Ulimit/arch/auto/Sherlock/Ulimit/Ulimit.so - - -lib/perl/Ulimit/arch/auto/Sherlock/Ulimit/Ulimit.so: $(ULIMIT_DIR)/Ulimit.xs $(ULIMIT_DIR)/Ulimit.pm $(ULIMIT_DIR)/Makefile.tmp - cd $(ULIMIT_DIR) && $(MAKE) -f Makefile.tmp - -$(ULIMIT_DIR)/Makefile.tmp: $(ULIMIT_DIR)/Makefile.PL - cd $(ULIMIT_DIR) && perl Makefile.PL +PROGS+=$(o)/lib/perl/Ulimit/Ulimit.pm +extras:: $(o)/lib/perl/Ulimit/arch/auto/Sherlock/Ulimit/Ulimit.so -clean:: - cd $(ULIMIT_DIR) && if [ -f Makefile.tmp ]; then $(MAKE) -f Makefile.tmp distclean; fi && rm -rf lib arch +$(o)/lib/perl/Ulimit/arch/auto/Sherlock/Ulimit/Ulimit.so: $(o)/$(ULIMIT_DIR)/Ulimit.xs $(o)/$(ULIMIT_DIR)/Ulimit.pm $(o)/$(ULIMIT_DIR)/Makefile + cd $(o)/$(ULIMIT_DIR) && $(MAKE) -f Makefile + cp $@ run/$(DATADIR)/ +$(o)/$(ULIMIT_DIR)/Makefile: $(o)/$(ULIMIT_DIR)/Makefile.PL + cd $(o)/$(ULIMIT_DIR) && perl Makefile.PL +$(o)/$(ULIMIT_DIR)/%: $(s)/$(ULIMIT_DIR)/% + cp $^ $@ diff --git a/lib/perl/Ulimit/Makefile.PL b/lib/perl/Ulimit/Makefile.PL index fe1e00d7..37d0bdf3 100644 --- a/lib/perl/Ulimit/Makefile.PL +++ b/lib/perl/Ulimit/Makefile.PL @@ -3,7 +3,6 @@ use ExtUtils::MakeMaker; WriteMakefile( 'NAME' => 'Sherlock::Ulimit', - 'MAKEFILE' => 'Makefile.tmp', 'VERSION_FROM' => 'Ulimit.pm', 'INST_LIB' => 'lib', 'INST_ARCHLIB' => 'arch', diff --git a/lib/regex/Makefile b/lib/regex/Makefile index 56e93d5a..730b2498 100644 --- a/lib/regex/Makefile +++ b/lib/regex/Makefile @@ -4,4 +4,4 @@ DIRS+=lib/regex LIBUCW_MODS+=regex/regex -obj/lib/regex/regex.o obj/lib/regex/regex.oo: CWARNS= +$(o)/lib/regex/regex.o $(o)/lib/regex/regex.oo: CWARNS= diff --git a/lib/shell/Makefile b/lib/shell/Makefile index 14e49013..2e58399e 100644 --- a/lib/shell/Makefile +++ b/lib/shell/Makefile @@ -1,7 +1,7 @@ # Support routines for shell scripts DIRS+=lib/shell -PROGS+=obj/lib/shell/config obj/lib/shell/logger +PROGS+=$(o)/lib/shell/config $(o)/lib/shell/logger -obj/lib/shell/config: obj/lib/shell/config.o $(LIBSH) -obj/lib/shell/logger: obj/lib/shell/logger.o $(LIBSH) +$(o)/lib/shell/config: $(o)/lib/shell/config.o $(LIBSH) +$(o)/lib/shell/logger: $(o)/lib/shell/logger.o $(LIBSH) -- 2.39.2