summaryrefslogtreecommitdiff
path: root/examples/subprojects
diff options
context:
space:
mode:
authorAndrew Shadura <andrew@shadura.me>2015-07-25 14:44:37 +0200
committerAndrew Shadura <andrew@shadura.me>2015-07-25 14:44:37 +0200
commit6ec061aabc159e3f37591e92fa1df407cdca6246 (patch)
tree25e11a31b402c65581e0b342c3afb6d405a83206 /examples/subprojects
parentaba913436a8521abe405a04ed71388989e1d646f (diff)
Imported Upstream version 0.26.0
Diffstat (limited to 'examples/subprojects')
-rw-r--r--examples/subprojects/Makefile46
-rw-r--r--examples/subprojects/expect.out51
-rw-r--r--examples/subprojects/libhello1/linkme.mk2
-rw-r--r--examples/subprojects/libhello2/linkme.mk2
-rw-r--r--examples/subprojects/test.mk26
5 files changed, 123 insertions, 4 deletions
diff --git a/examples/subprojects/Makefile b/examples/subprojects/Makefile
index 68c291e..10c642c 100644
--- a/examples/subprojects/Makefile
+++ b/examples/subprojects/Makefile
@@ -10,6 +10,52 @@ MKC_REQD = 0.11.0
_THISDIR_ =
.export _THISDIR_
+# A simpliest way to build debug and release version is to specify
+# appropriate targets like the following.
+.PHONY: debug release
+debug:
+ set -e; \
+ COPTS='${COPTS} -O0 -g'; LDFLAGS='${LDFLAGS} -g'; \
+ MAKEOBJDIR=${.CURDIR}/debug; MKRELOBJDIR=yes; \
+ export COPTS LDFLAGS MAKEOBJDIR MKRELOBJDIR; \
+ mkdir -p $$MAKEOBJDIR;\
+ ${MAKE} ${MAKEFLAGS} all
+release:
+ set -e; \
+ COPTS='${COPTS} -O'; \
+ MAKEOBJDIR=${.CURDIR}/release; MKRELOBJDIR=yes; \
+ export COPTS MAKEOBJDIR MKRELOBJDIR; \
+ mkdir -p $$MAKEOBJDIR;\
+ ${MAKE} ${MAKEFLAGS} all
+.if make(debug) || make(release)
+MKCHECKS = no
+.endif
+
+# Alternatively (and better!) one can introduce special variable for
+# this purpose like the following
+.include <mkc.init.mk> # we need ${MKDIR}
+
+.if defined(BM) # BuildMode
+. if ${BM} == "release"
+COPTS += -O
+MAKEOBJDIR = ${.CURDIR}/obj/release
+. elif ${BM} == "debug"
+COPTS += -O0 -g
+LDFLAGS += -g
+MAKEOBJDIR = ${.CURDIR}/obj/debug
+. elif ${BM} == "profile"
+COPTS += -O0 -g -pg
+LDFLAGS += -pg
+MAKEOBJDIR = ${.CURDIR}/obj/profile
+. else
+.error "Unsupported value of BM"
+. endif
+.OBJDIR = ${MAKEOBJDIR}
+MKRELOBJDIR = yes
+fake != ${MKDIR} -p ${MAKEOBJDIR}; echo # ${MAKEOBJDIR} must exist
+.export COPTS LDFLAGS
+.endif # defined(BM)
+
#
.include "test.mk"
.include "version.mk"
diff --git a/examples/subprojects/expect.out b/examples/subprojects/expect.out
index d26c974..b42cb16 100644
--- a/examples/subprojects/expect.out
+++ b/examples/subprojects/expect.out
@@ -248,6 +248,57 @@ GEN: hello_subprojects2
/objdir/subprojects.test.out.tmp
/objdir/test.mk
/objdir/version.mk
+======= debug/release =======
+/objdir/debug/hello/hello_subprojects
+/objdir/debug/hello/hello_subprojects.1
+/objdir/debug/hello/hello_subprojects.cat1
+/objdir/debug/hello/hello_subprojects.o
+/objdir/debug/hello/hello_subprojects2
+/objdir/debug/libhello1/hello1.o
+/objdir/debug/libhello1/hello1.os
+/objdir/debug/libhello1/libhello1.a
+/objdir/debug/libhello1/libhello1.so.1.0
+/objdir/debug/libhello2/hello2.cat3
+/objdir/debug/libhello2/hello2.o
+/objdir/debug/libhello2/libhello2.a
+/objdir/release/hello/hello_subprojects
+/objdir/release/hello/hello_subprojects.1
+/objdir/release/hello/hello_subprojects.cat1
+/objdir/release/hello/hello_subprojects.o
+/objdir/release/hello/hello_subprojects2
+/objdir/release/libhello1/hello1.o
+/objdir/release/libhello1/hello1.os
+/objdir/release/libhello1/libhello1.a
+/objdir/release/libhello1/libhello1.so.1.0
+/objdir/release/libhello2/hello2.cat3
+/objdir/release/libhello2/hello2.o
+/objdir/release/libhello2/libhello2.a
+======= drp =======
+/objdir/obj/debug/hello/hello_subprojects
+/objdir/obj/debug/hello/hello_subprojects.1
+/objdir/obj/debug/hello/hello_subprojects.cat1
+/objdir/obj/debug/hello/hello_subprojects.o
+/objdir/obj/debug/hello/hello_subprojects2
+/objdir/obj/debug/libhello1/hello1.o
+/objdir/obj/debug/libhello1/hello1.os
+/objdir/obj/debug/libhello1/libhello1.a
+/objdir/obj/debug/libhello1/libhello1.so.1.0
+/objdir/obj/debug/libhello2/hello2.cat3
+/objdir/obj/debug/libhello2/hello2.o
+/objdir/obj/debug/libhello2/libhello2.a
+=======
+/objdir/obj/release/hello/hello_subprojects
+/objdir/obj/release/hello/hello_subprojects.1
+/objdir/obj/release/hello/hello_subprojects.cat1
+/objdir/obj/release/hello/hello_subprojects.o
+/objdir/obj/release/hello/hello_subprojects2
+/objdir/obj/release/libhello1/hello1.o
+/objdir/obj/release/libhello1/hello1.os
+/objdir/obj/release/libhello1/libhello1.a
+/objdir/obj/release/libhello1/libhello1.so.1.0
+/objdir/obj/release/libhello2/hello2.cat3
+/objdir/obj/release/libhello2/hello2.o
+/objdir/obj/release/libhello2/libhello2.a
======= library dependencies =======
Hello1
Hello v.1.2.3
diff --git a/examples/subprojects/libhello1/linkme.mk b/examples/subprojects/libhello1/linkme.mk
index b585dd2..731ac90 100644
--- a/examples/subprojects/libhello1/linkme.mk
+++ b/examples/subprojects/libhello1/linkme.mk
@@ -2,4 +2,4 @@ PATH.hello1 := ${.PARSEDIR}
CPPFLAGS += -I${PATH.hello1}
DPLIBDIRS += ${PATH.hello1}
-LDADD += -lhello1
+LDADD0 += -lhello1
diff --git a/examples/subprojects/libhello2/linkme.mk b/examples/subprojects/libhello2/linkme.mk
index a7d2da7..135ad9e 100644
--- a/examples/subprojects/libhello2/linkme.mk
+++ b/examples/subprojects/libhello2/linkme.mk
@@ -2,4 +2,4 @@ PATH.hello2 := ${.PARSEDIR}
CPPFLAGS += -I${PATH.hello2}/include
DPLIBDIRS += ${PATH.hello2}
-LDADD += -lhello2
+LDADD0 += -lhello2
diff --git a/examples/subprojects/test.mk b/examples/subprojects/test.mk
index d3b88cc..46ac375 100644
--- a/examples/subprojects/test.mk
+++ b/examples/subprojects/test.mk
@@ -1,3 +1,5 @@
+next_level != expr ${.MAKE.LEVEL} + 1
+
.PHONY : test_output
test_output :
@set -e; \
@@ -18,8 +20,7 @@ test_output :
\
echo ===== all SHRTOUT=yes ======; \
${MAKE} ${MAKEFLAGS} clean > /dev/null; \
- env SHRTOUT=YES \
- ${MAKE} ${MAKEFLAGS} all 2>&1 | \
+ ${MAKE} ${MAKEFLAGS} all SHRTOUT=YES 2>&1 | \
mkc_test_helper_paths; \
\
echo ========= installdirs ==========; \
@@ -72,6 +73,27 @@ test_output :
\
${MAKE} ${MAKEFLAGS} distclean DESTDIR=${.OBJDIR} > /dev/null; \
\
+ echo ======= debug/release =======; \
+ ${MAKE} ${MAKEFLAGS} cleandir > /dev/null; \
+ env init_make_level=${next_level} ${MAKE} ${MAKEFLAGS} -j3 debug 1>&2; \
+ env init_make_level=${next_level} ${MAKE} ${MAKEFLAGS} -j3 release 1>&2; \
+ find ${.CURDIR}/release ${.CURDIR}/debug -type f | \
+ mkc_test_helper "${PREFIX}" "${.CURDIR}"; \
+ rm -rf ${.CURDIR}/release ${.CURDIR}/debug; \
+ \
+ echo ======= drp =======; \
+ env BM=debug init_make_level=${next_level} \
+ ${MAKE} ${MAKEFLAGS} -j3 all 1>&2; \
+ find ${.CURDIR}/obj -type f | \
+ mkc_test_helper "${PREFIX}" "${.CURDIR}"; \
+ rm -rf ${.CURDIR}/obj; \
+ echo =======; \
+ env BM=release init_make_level=${next_level} \
+ ${MAKE} ${MAKEFLAGS} -j3 all 1>&2; \
+ find ${.CURDIR}/obj -type f | \
+ mkc_test_helper "${PREFIX}" "${.CURDIR}"; \
+ rm -rf ${.CURDIR}/obj; \
+ \
echo ======= library dependencies =======; \
PREFIX=${.CURDIR}/usr; export PREFIX; \
${MAKE} ${MAKEFLAGS} all installdirs install -j3 >&2; \