From: Patrik Gornicz Date: Mon, 8 Jun 2009 04:13:38 +0000 (-0400) Subject: changed how flags are set for targets, fixed deps incflag hack X-Git-Tag: libbear-premerge~67 X-Git-Url: http://gitweb.pgornicz.com/gitweb.cgi?a=commitdiff_plain;h=4cf4e1ca49fa62e187208357653ebfa9c893cf95;p=libbear.git changed how flags are set for targets, fixed deps incflag hack --- diff --git a/lib/dir.mk b/lib/dir.mk index 4a35efd..60bf8c9 100644 --- a/lib/dir.mk +++ b/lib/dir.mk @@ -4,12 +4,14 @@ CURDIR := lib/ include ${CURDIR}${VARSMK} -# steps on variables -include ${SRCSDIR}${DIRMK} +include ${CURDIR}pre-${DIRMK} + # steps on variables + include ${SRCSDIR}${DIRMK} -# Restore variables -CURDIR := lib/ -#SRCPATH := # Not used at this level + # Restore variables + CURDIR := lib/ + #SRCPATH := # Not used at this level +include ${CURDIR}post-${DIRMK} include ${CURDIR}${RULESMK} diff --git a/lib/post-dir.mk b/lib/post-dir.mk new file mode 100644 index 0000000..671ba1f --- /dev/null +++ b/lib/post-dir.mk @@ -0,0 +1,11 @@ + +INCFLAGS := $(addprefix -I, ${INCDIRS}) + +# add flags specific to the library target and all prerequisites +${OBJS}: CXXFLAGS += -fPIC +${OBJS}: INCFLAGS := ${INCFLAGS} + +${TARGET}: LNKFLAGS += -shared -Wl,-soname,${SONAME} + +${DEPS}: INCFLAGS := ${INCFLAGS} + diff --git a/lib/pre-dir.mk b/lib/pre-dir.mk new file mode 100644 index 0000000..df03279 --- /dev/null +++ b/lib/pre-dir.mk @@ -0,0 +1,12 @@ + +# lists populated by dir.mk files in subdirectories +SRCS := # := start +OBJS := # := start +DEPS := # := start + +BLDDIRS := # := start + +BLDDIRS += ${OBJSDIR} +BLDDIRS += ${DEPSDIR} +BLDDIRS += ${WORKINGDIR} + diff --git a/lib/rules.mk b/lib/rules.mk index efd74f5..5e1fed4 100644 --- a/lib/rules.mk +++ b/lib/rules.mk @@ -14,14 +14,17 @@ uninstall: rm /usr/lib/${LINKERNAME} rm /usr/lib/${SONAME} + +${LIB}: ${TARGET} +${LIB_OBJS}: ${OBJS} +${LIB_DEPS}: ${DEPS} + + # how to link the main target ${TARGETTMP}: ${OBJS} | $${@D} ${Q1}${PRNTFMT} "${CXX}" "$@" ${Q2}${CXX} ${CXXFLAGS} ${LNKFLAGS} -o $@ $^ ${LIBS} -# TARGET will be built by default -all: ${TARGET} - # rule to copy tmp target to working directory ${TARGET}: ${TARGETTMP} | $${@D} ${Q1}${PRNTFMT} "cp" "$@" diff --git a/lib/vars.mk b/lib/vars.mk index 5911177..2ba9c2e 100644 --- a/lib/vars.mk +++ b/lib/vars.mk @@ -58,23 +58,4 @@ includedir := ${prefix}/include libdir := ${exec_prefix}/lib INSTALL := install -# HACK needed for deps -INCFLAGS := $(addprefix -I, ${INCDIRS}) - -# add flags specific to the library target and all prerequisites -${TARGET}: CXXFLAGS += -fPIC -${TARGET}: INCFLAGS += $(addprefix -I, ${INCDIRS}) -${TARGET}: LNKFLAGS += -shared -Wl,-soname,${SONAME} - - -# lists populated by dir.mk files in subdirectories -SRCS := # := start -OBJS := # := start -DEPS := # := start - -BLDDIRS := # := start - -BLDDIRS += ${OBJSDIR} -BLDDIRS += ${DEPSDIR} -BLDDIRS += ${WORKINGDIR} diff --git a/targets.mk b/targets.mk index 72b77c6..059a67a 100644 --- a/targets.mk +++ b/targets.mk @@ -3,11 +3,11 @@ LIB := lib .PHONY: ${LIB} -#LIB_OBJS := lib-objs -#.PHONY: ${LIB_OBJS} +LIB_OBJS := lib-objs +.PHONY: ${LIB_OBJS} -#LIB_DEPS := lib-deps -#.PHONY: ${LIB_DEPS} +LIB_DEPS := lib-deps +.PHONY: ${LIB_DEPS} # TESTS: build all of the tests TESTS := tests