chicken-hackers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Chicken-hackers] separate build directory support for Chicken


From: Ivan Shmakov
Subject: [Chicken-hackers] separate build directory support for Chicken
Date: Sun, 13 Jan 2008 02:41:29 +0600
User-agent: Gnus/5.110006 (No Gnus v0.6) Emacs/21.4 (gnu/linux)

        The following patch implements the support for building in a
        separate directory, like:

$ mkdir +build-1 
$ cd +build-1/ 
$ make -f ../Makefile srcdir=.. PLATFORM=linux

        It's a quite convenient approach, since if you've made a
        mistake, or have found that you need different build options,
        you can just discard the build directory and start afresh:

$ rm +build-1/ -rf 
$ 

        Besides, you could perform several builds using the same source
        tree (even at the same time):

$ mkdir +build-2 
$ cd +build-2/ 
$ make -f ../Makefile srcdir=.. PLATFORM=linux ONE-SET-OF-PARAMETERS...
...
$ cd ..
$ mkdir +build-3 
$ cd +build-3/ 
$ make -f ../Makefile srcdir=.. PLATFORM=linux ANOTHER-SET-OF-PARAMETERS...
...
$ 

        This patch shouldn't break building in the source directory.
        (Note, however, that using the same source tree for both the
        separate build directory builds and the traditional ones isn't
        well supported as yet.)

        I've tried to build Chicken with both embedded PCRE and the host
        one with this patch applied, and it succeed:

$ mkdir +build-with-embedded-pcre 
$ cd +build-with-embedded-pcre/ 
$ LC_ALL=C nohup time make -f ../Makefile srcdir=.. PLATFORM=linux \
      [...] USE_HOST_PCRE= bootstrap &
...
$ LC_ALL=C nohup time make -f ../Makefile srcdir=.. PLATFORM=linux \
      [...] USE_HOST_PCRE=yes -j 4 bootstrap &
...
$ wait
$ tail -n2 +build*/nohup.out 
==> +build-with-embedded-pcre/nohup.out <==
make[1]: Leaving directory `.../+build-with-embedded-pcre'
333.39user 6.31system 5:39.97elapsed 99%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (0major+1594645minor)pagefaults 0swaps

==> +build-with-host-pcre/nohup.out <==
make[1]: Leaving directory `.../+build-with-host-pcre'
324.92user 6.17system 1:29.90elapsed 368%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (0major+1467046minor)pagefaults 0swaps
$ 

        The patch is as follows.

diff --git a/Makefile b/Makefile
index bab3f9c..cdfed13 100644
--- a/Makefile
+++ b/Makefile
@@ -32,12 +32,15 @@
 # 37130 Gleichen
 # Germany
 
+STANDARD_TARGETS \
+       = all clean distclean spotless install uninstall confclean check \
+         fullcheck dist libs install-libs bootstrap
+srcdir = .
 
-.PHONY: all clean distclean spotless install uninstall confclean check dist \
-       libs install-libs fullcheck bootstrap
+.PHONY: $(STANDARD_TARGETS)
 
 ifndef PLATFORM
-all clean spotless distclean install uninstall:
+$(STANDARD_TARGETS):
        @echo "no PLATFORM given."
        @echo ""
        @echo "Please select your target platform by running one of the 
following commands:"
@@ -54,31 +57,13 @@ all clean spotless distclean install uninstall:
        @echo "For more information, consult the README file."
        @exit 1
 else
-all:
-       $(MAKE) -f Makefile.$(PLATFORM) all
-clean:
-       $(MAKE) -f Makefile.$(PLATFORM) clean
-distclean:
-       $(MAKE) -f Makefile.$(PLATFORM) distclean
-spotless:
-       $(MAKE) -f Makefile.$(PLATFORM) spotless
-install:
-       $(MAKE) -f Makefile.$(PLATFORM) install
-uninstall:
-       $(MAKE) -f Makefile.$(PLATFORM) uninstall
-confclean:
-       $(MAKE) -f Makefile.$(PLATFORM) confclean
-check:
-       $(MAKE) -f Makefile.$(PLATFORM) check
-fullcheck:
-       $(MAKE) -f Makefile.$(PLATFORM) fullcheck
+$(filter-out dist,$(STANDARD_TARGETS)):
+ifneq ($(srcdir), .)
+       -test -d pcre || mkdir pcre
+endif
+       $(MAKE) -f $(srcdir)/Makefile.$(PLATFORM) $@
+
 dist:
-       $(MAKE) -f Makefile.$(PLATFORM) distfiles
+       $(MAKE) -f $(srcdir)/Makefile.$(PLATFORM) distfiles
        csi -s misc/makedist.scm
-libs:
-       $(MAKE) -f Makefile.$(PLATFORM) libs
-install-libs:
-       $(MAKE) -f Makefile.$(PLATFORM) install-libs
-bootstrap:
-       $(MAKE) -f Makefile.$(PLATFORM) bootstrap
 endif
diff --git a/Makefile.bsd b/Makefile.bsd
index 4d8e3f2..7bc3337 100644
--- a/Makefile.bsd
+++ b/Makefile.bsd
@@ -33,6 +33,9 @@
 # Germany
 
 
+srcdir = .
+VPATH  = $(srcdir)
+
 # platform configuration
 
 ARCH = $(shell sh config-arch.sh)
@@ -55,7 +58,7 @@ CHICKEN_CONFIG_H = chicken-config.h
 
 # select default and internal settings
 
-include defaults.make
+include $(srcdir)/defaults.make
 
 chicken-config.h: chicken-defaults.h
        echo "#define HAVE_DIRENT_H 1" >>$@
@@ -97,4 +100,4 @@ ifdef HACKED_APPLY
 endif
        cat chicken-defaults.h >>$@
 
-include rules.make
+include $(srcdir)/rules.make
diff --git a/Makefile.cross-linux-mingw b/Makefile.cross-linux-mingw
index 265d675..5158729 100644
--- a/Makefile.cross-linux-mingw
+++ b/Makefile.cross-linux-mingw
@@ -33,6 +33,9 @@
 # Germany
 
 
+srcdir = .
+VPATH  = $(srcdir)
+
 # platform configuration
 
 DLLSINPATH = 1
@@ -80,7 +83,7 @@ POSIXFILE = posixwin
 
 # select default and internal settings
 
-include defaults.make
+include $(srcdir)/defaults.make
 
 # main target
 
@@ -130,4 +133,4 @@ endif
        echo "#define C_HACKED_APPLY" >>$@
        cat chicken-defaults.h >>$@
 
-include rules.make
+include $(srcdir)/rules.make
diff --git a/Makefile.cygwin b/Makefile.cygwin
index c0a5b2a..79a24e2 100644
--- a/Makefile.cygwin
+++ b/Makefile.cygwin
@@ -33,6 +33,9 @@
 # Germany
 
 
+srcdir = .
+VPATH  = $(srcdir)
+
 # platform configuration
 
 ARCH = x86
@@ -87,7 +90,7 @@ APPLY_HACK_OBJECT = apply-hack.$(ARCH)$(O)
 # select default and internal settings
 
 CUSTOM_CHICKEN_DEFAULTS=1
-include defaults.make
+include $(srcdir)/defaults.make
 
 chicken-config.h: chicken-defaults.h
        echo "#define HAVE_DIRENT_H 1" >>$@
@@ -230,4 +233,4 @@ chicken-defaults.h:
        echo "# define C_CHICKEN_BUG_PROGRAM \"$(CHICKEN_BUG_PROGRAM)\"" >>$@
        echo "#endif" >>$@
 
-include rules.make
+include $(srcdir)/rules.make
diff --git a/Makefile.linux b/Makefile.linux
index d1ae665..be280bd 100644
--- a/Makefile.linux
+++ b/Makefile.linux
@@ -33,6 +33,9 @@
 # Germany
 
 
+srcdir = .
+VPATH  = $(srcdir)
+
 # platform configuration
 
 ARCH = $(shell sh config-arch.sh)
@@ -58,7 +61,7 @@ CHICKEN_CONFIG_H = chicken-config.h
 
 # select default and internal settings
 
-include defaults.make
+include $(srcdir)/defaults.make
 
 chicken-config.h: chicken-defaults.h
        echo "#define HAVE_DIRENT_H 1" >>$@
@@ -105,4 +108,4 @@ ifneq ($(USE_HOST_PCRE),)
 endif
        cat chicken-defaults.h >>$@
 
-include rules.make
+include $(srcdir)/rules.make
diff --git a/Makefile.macosx b/Makefile.macosx
index 9feeb49..800113b 100644
--- a/Makefile.macosx
+++ b/Makefile.macosx
@@ -33,6 +33,9 @@
 # Germany
 
 
+srcdir = .
+VPATH  = $(srcdir)
+
 # platform configuration
 
 ARCH = $(shell sh config-arch.sh)
@@ -69,7 +72,7 @@ APPLY_HACK_OBJECT = apply-hack.$(ARCH)$(O)
 
 # select default and internal settings
 
-include defaults.make
+include $(srcdir)/defaults.make
 
 chicken-config.h: chicken-defaults.h
        echo "#define HAVE_DIRENT_H 1" >>$@
@@ -110,4 +113,4 @@ endif
        echo "#define C_HACKED_APPLY" >>$@
        cat chicken-defaults.h >>$@
 
-include rules.make
+include $(srcdir)/rules.make
diff --git a/Makefile.mingw b/Makefile.mingw
index 691a0a8..eb248dd 100644
--- a/Makefile.mingw
+++ b/Makefile.mingw
@@ -33,6 +33,9 @@
 # Germany
 
 
+srcdir = .
+VPATH  = $(srcdir)
+
 # platform configuration
 
 DLLSINPATH = 1
@@ -78,7 +81,7 @@ POSIXFILE = posixwin
 
 CUSTOM_CHICKEN_DEFAULTS=1
 
-include defaults.make
+include $(srcdir)/defaults.make
 
 # main target
 
@@ -210,4 +213,4 @@ chicken-defaults.h:
        echo # define C_TARGET_STATIC_LIB_HOME "$(TARGET_PREFIX)/lib" >>$@
        echo #endif >>$@
 
-include rules.make
+include $(srcdir)/rules.make
diff --git a/Makefile.mingw-msys b/Makefile.mingw-msys
index ae7ed25..89137a0 100644
--- a/Makefile.mingw-msys
+++ b/Makefile.mingw-msys
@@ -33,6 +33,9 @@
 # Germany
 
 
+srcdir = .
+VPATH  = $(srcdir)
+
 # platform configuration
 
 DLLSINPATH = 1
@@ -75,7 +78,7 @@ POSIXFILE = posixwin
 
 # select default and internal settings
 
-include defaults.make
+include $(srcdir)/defaults.make
 
 # main target
 
@@ -125,4 +128,4 @@ endif
        echo "#define C_HACKED_APPLY" >>$@
        cat chicken-defaults.h >>$@
 
-include rules.make
+include $(srcdir)/rules.make
diff --git a/Makefile.solaris b/Makefile.solaris
index f634ade..ae38649 100644
--- a/Makefile.solaris
+++ b/Makefile.solaris
@@ -33,6 +33,9 @@
 # Germany
 
 
+srcdir = .
+VPATH  = $(srcdir)
+
 # platform configuration
 
 ARCH = $(shell sh config-arch.sh)
@@ -55,7 +58,7 @@ CHICKEN_CONFIG_H = chicken-config.h
 
 # select default and internal settings
 
-include defaults.make
+include $(srcdir)/defaults.make
 
 chicken-config.h: chicken-defaults.h
        echo "#define HAVE_DIRENT_H 1" >>$@
@@ -97,4 +100,4 @@ ifdef HACKED_APPLY
 endif
        cat chicken-defaults.h >>$@
 
-include rules.make
+include $(srcdir)/rules.make
diff --git a/defaults.make b/defaults.make
index d2266dc..5b3078a 100644
--- a/defaults.make
+++ b/defaults.make
@@ -42,6 +42,9 @@ CROSS_CHICKEN ?= 0
 
 # directories
 
+srcdir = .
+VPATH  = $(srcdir)
+
 DESTDIR =
 ifeq ($(PLATFORM),mingw)
 PREFIX ?= c:/devtools
@@ -156,7 +159,7 @@ endif
 ifndef NOPTABLES
 C_COMPILER_PTABLES_OPTIONS = -DC_ENABLE_PTABLES
 endif
-INCLUDES ?= -I.
+INCLUDES ?= -I. -I$(srcdir)
 C_COMPILER_COMPILE_OPTION ?= -c
 C_COMPILER_OUTPUT_OPTION ?= -o
 ifdef DEBUGBUILD
@@ -250,7 +253,9 @@ CHICKEN = $(PREFIX)/bin/chicken$(EXE)
 
 # Scheme compiler flags
 
-CHICKEN_OPTIONS = -quiet -no-trace -optimize-level 2 -include-path .
+CHICKEN_OPTIONS = \
+       -quiet -no-trace -optimize-level 2 \
+       -include-path . -include-path $(srcdir)
 CHICKEN_LIBRARY_OPTIONS = $(CHICKEN_OPTIONS) -explicit-use
 CHICKEN_PROGRAM_OPTIONS = $(CHICKEN_OPTIONS) -no-lambda-info
 CHICKEN_COMPILER_OPTIONS = $(CHICKEN_PROGRAM_OPTIONS) -extend 
private-namespace.scm
diff --git a/rules.make b/rules.make
index 67e8826..a35b449 100644
--- a/rules.make
+++ b/rules.make
@@ -1031,11 +1031,11 @@ compiler-check:
 .PHONY: bootstrap bootstrap.tar.gz
 
 bootstrap:
-       gzip -d -c bootstrap.tar.gz | tar xvf -
+       tar zxvf $(srcdir)/bootstrap.tar.gz
        touch *.c
-       $(MAKE) -f Makefile.$(PLATFORM) STATICBUILD=1 chicken
+       $(MAKE) -f $(srcdir)/Makefile.$(PLATFORM) STATICBUILD=1 chicken
        touch *.scm
-       $(MAKE) CHICKEN=./chicken all
+       $(MAKE) -f $(srcdir)/Makefile CHICKEN=./chicken all
 
 bootstrap.tar.gz:
-       tar cfz bootstrap.tar.gz $(LIBCHICKEN_OBJECTS_1:=.c) 
$(COMPILER_OBJECTS_1:=.c)
+       tar cfz $@ $(LIBCHICKEN_OBJECTS_1:=.c) $(COMPILER_OBJECTS_1:=.c)





reply via email to

[Prev in Thread] Current Thread [Next in Thread]