# but by explicly setting the BUILD variable. Make is invoked from
# within the source itself which is much more compatible with compilation
# environments.
+.SILENT:
-ifndef BUILD
-BUILD=$(BASE)/build
+# Search for the build directory
+ifdef BUILD
+BUILD_POSSIBLE = $(BUILD)
+else
+BUILD_POSSIBLE = $(BASE) $(BASE)/build
+endif
+
+BUILD:= $(foreach i,$(BUILD_POSSIBLE),$(wildcard $(i)/environment.mak))
+BUILD:= $(patsubst %/,%,$(firstword $(dir $(BUILD))))
+
+ifeq ($(words $(BUILD)),0)
+error-all:
+ echo Can't find the build directory in $(BUILD_POSSIBLE) -- use BUILD=
endif
# Base definitions
INCLUDE := $(BUILD)/include
BIN := $(BUILD)/bin
LIB := $(BIN)
-OBJ := $(BUILD)/obj
+OBJ := $(BUILD)/obj/$(SUBDIR)
DEP := $(OBJ)
DOC := $(BUILD)/doc
LIBRARY_H = $(BASE)/buildlib/library.mak
DEBIANDOC_H = $(BASE)/buildlib/debiandoc.mak
MANPAGE_H = $(BASE)/buildlib/manpage.mak
+PROGRAM_H = $(BASE)/buildlib/program.mak
# Source location control
# SUBDIRS specifies sub components of the module that
HEADER_TARGETDIRS+=
# Options
-CXX = c++
-CC = cc
+include $(BUILD)/environment.mak
CPPFLAGS+= -I$(INCLUDE)
-CXXFLAGS+= -Wall -g -fno-implicit-templates -fno-exceptions
-PICFLAGS+= -fPIC -DPIC
-LFLAGS+=
-INLINEDEPFLAG = -MD
-DEBIANDOC_HTML = yes
-DEBIANDOC_TEXT = yes
+LDFLAGS+= -L$(LIB)
# Phony rules. Other things hook these by appending to the dependency
# list
.PHONY: headers library clean veryclean all binary program doc
all: binary doc
binary: library program
-maintainer-clean dist-clean: veryclean
+maintainer-clean dist-clean distclean pristine sanity: veryclean
headers library clean veryclean program:
# Header file control. We want all published interface headers to go
# makedep program that can be called after compiling, that's illistrated
# by the DEPFLAG case.
# Compile rules are expected to call this macro after calling the compiler
- ifdef INLINEDEPFLAG
+ifdef INLINEDEPFLAG
define DoDep
sed -e "1s/.*:/$(subst /,\\/,$@):/" $(basename $(@F)).d > $(DEP)/$(basename $(@F)).d
-rm -f $(basename $(@F)).d