]> mj.ucw.cz Git - libucw.git/commitdiff
Rewritten Makefiles to support separated source and object trees.
authorMartin Mares <mj@ucw.cz>
Mon, 11 Apr 2005 22:02:48 +0000 (22:02 +0000)
committerMartin Mares <mj@ucw.cz>
Mon, 11 Apr 2005 22:02:48 +0000 (22:02 +0000)
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
build/check-customs
charset/Makefile
lib/Makefile
lib/perl/Makefile
lib/perl/Ulimit/.cvsignore [deleted file]
lib/perl/Ulimit/Makefile
lib/perl/Ulimit/Makefile.PL
lib/regex/Makefile
lib/shell/Makefile

index 4544625ad4e798aefb1bbff6c8747f3c8143030a..0e06791c0dc75daba5226b9084bd3027cf879112 100644 (file)
@@ -2,4 +2,4 @@
 
 DIRS+=build
 
-obj/build/genhash: obj/build/genhash.o
+$(o)/build/genhash: $(o)/build/genhash.o
index 4a654c68612ec1418879d369eaf94df26196455a..3c471df585b4aa066d9ce0c5db472eaa218c5d6a 100755 (executable)
@@ -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
index 115b0bb1abb8a20a7ef84407cfd5d7e01fa81afb..64a8119e4baae0fb623bf74a88c9b3e677be8ffc 100644 (file)
@@ -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-*
index b8150ec160813f838b82054631a7cdcf7b2aeb26..a17efb2e56d5ccd1158e05fd2512ef90e11a1240 100644 (file)
@@ -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
index 8b23992fe2af66b41e8eeb357734a581a5fa7f19..8de911408bf3f79562e0b6f009c72a16ce570a52 100644 (file)
@@ -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 (file)
index d5f8ca3..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-Makefile.tmp
-Ulimit.bs
-Ulimit.c
-arch
-lib
-pm_to_blib
index a610ad6720087e40716120f3d7f33f7aa96cf71c..4ca72d30157287636346156c24380d0e1b7804cf 100644 (file)
@@ -1,22 +1,18 @@
 # Makefile for the Ulimit Perl module  (c) 2003 Tomas Valla <tom@ucw.cz>
 
 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 $^ $@
index fe1e00d7c1548d8382add588ffcd01175f7469be..37d0bdf34e1732393f33f85159836053d3f3809a 100644 (file)
@@ -3,7 +3,6 @@
 use ExtUtils::MakeMaker;
 WriteMakefile(
     'NAME'             => 'Sherlock::Ulimit',
-    'MAKEFILE'         => 'Makefile.tmp',
     'VERSION_FROM'     => 'Ulimit.pm',
     'INST_LIB'         => 'lib',
     'INST_ARCHLIB'     => 'arch',
index 56e93d5a0b49aa45d50330fb0818b3fd53d08745..730b2498b7d98c09a5e2ada106f86c95b5ee7d57 100644 (file)
@@ -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=
index 14e4901380091ff0a89941391edd07a0488d9ce9..2e58399ef5dd5f6cd8d329f9a4135bf8c4be6872 100644 (file)
@@ -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)