[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 5/7] Makeconf: simplify the directory logic
From: |
Jeremie Koenig |
Subject: |
[PATCH 5/7] Makeconf: simplify the directory logic |
Date: |
Mon, 16 Aug 2010 13:51:25 +0200 |
* Replace $(..)foo with $(top_builddir)/foo for the sake of consistency.
* Define default values for $({top_,}{build,src}dir) and let individual
makefiles handle the special cases (namely, the top Makefile and the ones
which configure generates in the build directory).
* Replace the $(INCLUDES) hack with a (hopefully) simpler one. Also, include
paths are moved after the extra definitions so that the latter are grouped
with the ones from config.make (this is purely cosmetic).
Signed-off-by: Jeremie Koenig <jk@jk.fr.eu.org>
---
Makeconf | 67 ++++++++++++++++++++++---------------------------------------
Makefile | 1 +
2 files changed, 25 insertions(+), 43 deletions(-)
diff --git a/Makeconf b/Makeconf
index 6f7af87..1a333ac 100644
--- a/Makeconf
+++ b/Makeconf
@@ -31,6 +31,13 @@
# installhdrs (header files that should be installed in /include)
# installhdrsubdir (the subdirectory they should go in, default `hurd')
# and must not define $(targets).
+
+# Generated makefiles in a separate build directory should pre-define
+# srcdir (the source directory being built)
+# top_srcdir (the top-level source directory)
+
+# Top-level makefiles should pre-define
+# top_builddir (the top-level build directory, ie. ".")
# Put this first so it's the default
all:
@@ -38,28 +45,17 @@ all:
# What version of the Hurd is this?
hurd-version := 0.3
-# Figure out how to locate the parent directory from here.
-ifeq (.,$(dir))
-.. =
-else
-.. = ../
-endif
+# Figure out how to locate the directories we need.
+builddir ?= .
+top_builddir ?= ..
-ifndef srcdir
-# We are building in the source directory itself.
-srcdir = .
-ifeq (.,$(dir))
-top_srcdir = .
-else
-top_srcdir = ..
-endif
-endif
+# At this point, for in-tree builds, $(srcdir) still expands to nothing.
+bothdirs := $(builddir) $(srcdir)
+top_bothdirs := $(top_builddir) $(top_srcdir)
-INCLUDES = -I. $(srcdirinc)
-ifneq (.,$(dir))
-INCLUDES += -I.. $(top_srcdirinc)
-endif
-INCLUDES += -I$(..)include -I$(top_srcdir)/include
+# But in that case, we redefine it to be identical to the build directory.
+srcdir ?= $(builddir)
+top_srcdir ?= $(top_builddir)
# Include the configure-generated file of parameters.
# This sets up variables for build tools and installation directories.
@@ -71,9 +67,10 @@ endif
# Complement the configured values.
CFLAGS := -std=gnu99 $(gnu89-inline-CFLAGS) $(CFLAGS) $($*-CFLAGS)
-CPPFLAGS += $(INCLUDES) \
- -D_GNU_SOURCE -D_IO_MTSAFE_IO -D_FILE_OFFSET_BITS=64 \
- $($*-CPPFLAGS)
+CPPFLAGS += -D_GNU_SOURCE -D_IO_MTSAFE_IO -D_FILE_OFFSET_BITS=64 \
+ $(patsubst %,-I%, $(bothdirs) $(top_bothdirs)) \
+ $(patsubst %,-I%/include, $(top_bothdirs)) \
+ $($*-CPPFLAGS)
# If we're not configured, don't do deps; then `make TAGS' and such can work.
ifndef configured
@@ -85,24 +82,8 @@ ifeq (no,$(build-profiled))
no_prof = t
endif
-
-# Flags for compilation.
-# It is important to have this inclusion first; that picks up our
-# library header files locally rather than from installed copies.
-# Append to any value set by the specific Makefile or by configure.
-ifeq ($(srcdir),.)
-srcdirinc=
-else
-srcdirinc=-I$(srcdir)
-endif
-ifeq ($(top_srcdir),..)
-top_srcdirinc=
-else
-top_srcdirinc=-I$(top_srcdir)
-endif
-
# More useful version of HURDLIBS
-library_deps=$(foreach lib,$(HURDLIBS),$(..)lib$(lib)/lib$(lib).so)
+library_deps=$(foreach lib,$(HURDLIBS),$(top_builddir)/lib$(lib)/lib$(lib).so)
# Local programs:
MKINSTALLDIRS = $(top_srcdir)/mkinstalldirs
@@ -200,7 +181,7 @@ endif
# This is a hack to give all hurd utilities a default bug-reporting
# address (defined in libhurdbugaddr/bugaddr.c).
-BUGADDR = $(..)libhurdbugaddr/libhurdbugaddr.a
+BUGADDR = $(top_builddir)/libhurdbugaddr/libhurdbugaddr.a
BUGADDR_REF = -uargp_program_bug_address
# Standard targets
@@ -375,8 +356,8 @@ endif
endif # makemode != misc
-directory-depend: $(..)$(dir).d
-$(..)$(dir).d: $(srcdir)/Makefile
+directory-depend: $(top_builddir)/$(dir).d
+$(top_builddir)/$(dir).d: $(srcdir)/Makefile
rm -f $@
echo $(dir): $(hurd-bug-addr-dir-dep) $(addprefix lib,$(HURDLIBS)) > $@
diff --git a/Makefile b/Makefile
index 3194473..3f46fdc 100644
--- a/Makefile
+++ b/Makefile
@@ -17,6 +17,7 @@
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
dir := .
+top_builddir := .
makemode := misc
include ./Makeconf
--
1.7.1
[PATCH 6/7] Makeconf: let config.make define $(configured), Jeremie Koenig, 2010/08/16
[PATCH 5/7] Makeconf: simplify the directory logic,
Jeremie Koenig <=
[PATCH 3/7] Update ./configure, Jeremie Koenig, 2010/08/16