Good friday all, I took a few couple hour to toy with Poul-Henning build framework and see if I could make it non-recursive (yes, I do have strange obsessions). I attached the result as a git patch in order to get some feedback and see if it may be an interesting direction.
A non-recursive solution allows for very efficient parallel builds and clean dependency handling. The first point may not be very important as varnish is rather small and builds are fast, but the second one is essential regarding consistency. However, if you want to do it without generating makefiles (like autools do), while still being able to run from subdirs, and having readable makefiles, well, it gets a bit complicated. And I'm wondering if the gain is worth the complexity. And since we are considering a new framework, I think it's the right time to look at this possibility. A few words about the patch attached: - run "sh config.phk" once first, then "make -f master.gq" - only supports all, clean, varnishd, varnishtest,... for goals (no check, doc, install yet) - dependencies are correctly handled (touching a vgz header will rebuild .o depending on it as well as ar'ing the lib, and varnishd link, for example), and no need to order the subdirs to compile in the right order. - only runs from the top directory, but the plan is to be able to run from subdirectories as well - for those interested, the main part of the code is in master.gq and footer.gq (GNUMake rookies, beware) - I had to touch Makefile.phks and config.phk a wee bit, but not that much As said, feedback is more than welcome. -- Guillaume Quintard
>From bb258e3104b5f8fe330eebed34ef42feb8abe6ba Mon Sep 17 00:00:00 2001 From: Guillaume Quintard <[email protected]> Date: Fri, 10 Jan 2014 13:20:13 +0100 Subject: [PATCH] first commit --- bin/varnishadm/Makefile.phk | 11 ++-- bin/varnishd/Makefile.phk | 32 ++++++----- bin/varnishhist/Makefile.phk | 9 ++-- bin/varnishlog/Makefile.phk | 14 +++-- bin/varnishncsa/Makefile.phk | 15 +++--- bin/varnishreplay/Makefile.phk | 10 ++-- bin/varnishstat/Makefile.phk | 10 ++-- bin/varnishtest/Makefile.phk | 11 ++-- bin/varnishtop/Makefile.phk | 10 ++-- config.phk | 4 +- footer.gq | 51 ++++++++++++++++++ header.gq | 13 +++++ lib/libvarnish/Makefile.phk | 6 +-- lib/libvarnishapi/Makefile.phk | 11 ++-- lib/libvarnishtools/Makefile.phk | 6 +-- lib/libvcc/Makefile.phk | 12 +++-- lib/libvgz/Makefile.phk | 9 ++-- lib/libvmod_debug/Makefile.phk | 6 +-- lib/libvmod_directors/Makefile.phk | 6 +-- lib/libvmod_std/Makefile.phk | 6 +-- master.gq | 107 +++++++++++++++++++++++++++++++++++++ 21 files changed, 277 insertions(+), 82 deletions(-) create mode 100644 footer.gq create mode 100644 header.gq create mode 100644 master.gq diff --git a/bin/varnishadm/Makefile.phk b/bin/varnishadm/Makefile.phk index 6d6cb2a..49fd9f5 100644 --- a/bin/varnishadm/Makefile.phk +++ b/bin/varnishadm/Makefile.phk @@ -1,12 +1,15 @@ +include $(ACTIVEDIR)../../master.gq +$(HEADER) + PROG_SRC = varnishadm.c -LD_ADD += ${LIB_VARNISHAPI} -LD_ADD += ${LIB_VARNISH} +PROG_LIBS += ${LIB_VARNISHAPI} +PROG_LIBS += ${LIB_VARNISH} LD_ADD += ${LIB_PCRE} LD_ADD += ${LIB_READLINE} LD_ADD += -lm RST_MAN += $(TOPDIR)/doc/sphinx/reference/varnishadm.rst -TOPDIR = $(CURDIR)/../.. -include $(TOPDIR)/Makefile.inc.phk + +$(FOOTER) diff --git a/bin/varnishd/Makefile.phk b/bin/varnishd/Makefile.phk index d0ee858..12d3e04 100644 --- a/bin/varnishd/Makefile.phk +++ b/bin/varnishd/Makefile.phk @@ -1,4 +1,5 @@ -VPATH += cache common mgt waiter storage hash +include $(ACTIVEDIR)../../master.gq +$(HEADER) PROG_SRC += cache/cache_acceptor.c PROG_SRC += cache/cache_backend.c @@ -86,11 +87,11 @@ PROG_SRC += waiter/mgt_waiter.c USE_THREADS = YES USE_DLOPEN = YES -LD_ADD += ${LIB_VARNISH} -LD_ADD += ${LIB_VCC} +PROG_LIBS += ${LIB_VARNISH} +PROG_LIBS += ${LIB_VCC} +PROG_LIBS += ${LIB_VGZ} LD_ADD += ${LIB_PCRE} LD_ADD += ${LIB_EXECINFO} -LD_ADD += ${LIB_VGZ} LD_ADD += -lm RST_MAN += $(TOPDIR)/doc/sphinx/reference/varnishd.rst @@ -99,20 +100,21 @@ MADE_FILES += default_vcl.h TODO_INSTALL += install_etc -TOPDIR = $(CURDIR)/../.. -include $(TOPDIR)/Makefile.inc.phk +#TOPDIR = $(CURDIR)/../.. +#include $(TOPDIR)/Makefile.inc.phk # # Turn the default.vcl file into a C-string we can include in the program. # -default_vcl.h: default.vcl - echo '/*' > $@ - echo ' * NB: This file is machine generated, DO NOT EDIT!' >> $@ - echo ' *' >> $@ - echo ' * Edit default.vcl instead and run make' >> $@ - echo ' *' >> $@ - echo ' */' >> $@ - echo '' >> $@ +$(ACTIVEDIR)default_vcl.h: $(ACTIVEDIR)default.vcl + cd $(dir $@); \ + echo '/*' > $@; \ + echo ' * NB: This file is machine generated, DO NOT EDIT!' >> $@ ; \ + echo ' *' >> $@ ; \ + echo ' * Edit default.vcl instead and run make' >> $@; \ + echo ' *' >> $@; \ + echo ' */' >> $@; \ + echo '' >> $@; \ sed -e 's/"/\\"/g' \ -e 's/$$/\\n"/' \ -e 's/^/ "/' default.vcl >> $@ @@ -120,3 +122,5 @@ default_vcl.h: default.vcl .PHONY: install_etc install_etc: default_vcl.h @cp default_vcl.h $(INSTALL_BASE)/etc/ + +$(FOOTER) diff --git a/bin/varnishhist/Makefile.phk b/bin/varnishhist/Makefile.phk index 145414d..f83b360 100644 --- a/bin/varnishhist/Makefile.phk +++ b/bin/varnishhist/Makefile.phk @@ -1,7 +1,8 @@ +include $(ACTIVEDIR)../../master.gq +$(HEADER) PROG_SRC = varnishhist.c -LD_ADD += ${LIB_VARNISH} -LD_ADD += ${LIB_VARNISHAPI} +PROG_LIBS += ${LIB_VARNISH} +PROG_LIBS += ${LIB_VARNISHAPI} -TOPDIR = $(CURDIR)/../.. -include $(TOPDIR)/Makefile.inc.phk +$(FOOTER) diff --git a/bin/varnishlog/Makefile.phk b/bin/varnishlog/Makefile.phk index 5f0de52..bfc3951 100644 --- a/bin/varnishlog/Makefile.phk +++ b/bin/varnishlog/Makefile.phk @@ -1,15 +1,19 @@ +include $(ACTIVEDIR)../../master.gq +$(HEADER) + PROG_SRC = varnishlog.c PROG_SRC = varnishlog_options.c -LD_ADD += ${LIB_VARNISHTOOLS} -LD_ADD += ${LIB_VARNISHAPI} -LD_ADD += ${LIB_VARNISH} +PROG_LIBS += ${LIB_VARNISHTOOLS} +PROG_LIBS += ${LIB_VARNISHAPI} +PROG_LIBS += ${LIB_VARNISH} LD_ADD += ${LIB_PCRE} LD_ADD += -lm TODO_ALL += build_man -TOPDIR = $(CURDIR)/../.. -include $(TOPDIR)/Makefile.inc.phk +#TOPDIR = $(CURDIR)/../.. +#include $(TOPDIR)/Makefile.inc.phk .PHONY: build_man +$(FOOTER) diff --git a/bin/varnishncsa/Makefile.phk b/bin/varnishncsa/Makefile.phk index 10fd638..fb2499e 100644 --- a/bin/varnishncsa/Makefile.phk +++ b/bin/varnishncsa/Makefile.phk @@ -1,16 +1,17 @@ +include $(ACTIVEDIR)../../master.gq +$(HEADER) + PROG_SRC += base64.c PROG_SRC += varnishncsa.c PROG_SRC += varnishncsa_options.c -LD_ADD += ${LIB_VARNISHTOOLS} -LD_ADD += ${LIB_VARNISHAPI} -LD_ADD += ${LIB_VARNISH} +PROG_LIBS += ${LIB_VARNISHTOOLS} +PROG_LIBS += ${LIB_VARNISHAPI} +PROG_LIBS += ${LIB_VARNISH} LD_ADD += ${LIB_PCRE} LD_ADD += -lm TODO_ALL += build_man - -TOPDIR = $(CURDIR)/../.. -include $(TOPDIR)/Makefile.inc.phk - .PHONY: build_man + +$(FOOTER) diff --git a/bin/varnishreplay/Makefile.phk b/bin/varnishreplay/Makefile.phk index d69f03e..e7f456c 100644 --- a/bin/varnishreplay/Makefile.phk +++ b/bin/varnishreplay/Makefile.phk @@ -1,7 +1,9 @@ +include $(ACTIVEDIR)../../master.gq +$(HEADER) + PROG_SRC = varnishreplay.c -LD_ADD += ${LIB_VARNISH} -LD_ADD += ${LIB_VARNISHAPI} +PROG_LIBS += ${LIB_VARNISH} +PROG_LIBS += ${LIB_VARNISHAPI} -TOPDIR = $(CURDIR)/../.. -include $(TOPDIR)/Makefile.inc.phk +$(FOOTER) diff --git a/bin/varnishstat/Makefile.phk b/bin/varnishstat/Makefile.phk index 3a89de7..e135b56 100644 --- a/bin/varnishstat/Makefile.phk +++ b/bin/varnishstat/Makefile.phk @@ -1,13 +1,15 @@ +include $(ACTIVEDIR)../../master.gq +$(HEADER) + PROG_SRC += varnishstat.c PROG_SRC += varnishstat_curses.c -LD_ADD += ${LIB_VARNISHAPI} -LD_ADD += ${LIB_VARNISH} +PROG_LIBS += ${LIB_VARNISHAPI} +PROG_LIBS += ${LIB_VARNISH} LD_ADD += ${LIB_PCRE} LD_ADD += ${LIB_CURSES} LD_ADD += -lm RST_MAN += $(TOPDIR)/doc/sphinx/reference/varnishstat.rst -TOPDIR = $(CURDIR)/../.. -include $(TOPDIR)/Makefile.inc.phk +$(FOOTER) diff --git a/bin/varnishtest/Makefile.phk b/bin/varnishtest/Makefile.phk index 748977e..f922ee8 100644 --- a/bin/varnishtest/Makefile.phk +++ b/bin/varnishtest/Makefile.phk @@ -1,3 +1,5 @@ +include $(ACTIVEDIR)../../master.gq +$(HEADER) PROG_SRC += vtc.c PROG_SRC += vtc_client.c PROG_SRC += vtc_http.c @@ -8,8 +10,8 @@ PROG_SRC += vtc_sema.c PROG_SRC += vtc_server.c PROG_SRC += vtc_varnish.c -LD_ADD += ${LIB_VARNISHAPI} -LD_ADD += ${LIB_VARNISH} +PROG_LIBS += ${LIB_VARNISHAPI} +PROG_LIBS += ${LIB_VARNISH} LD_ADD += ${LIB_PCRE} LD_ADD += ${LIB_VGZ} LD_ADD += -lm @@ -20,10 +22,9 @@ RST_MAN += $(TOPDIR)/doc/sphinx/reference/varnishtest.rst TODO_TEST += all_tests -TOPDIR = $(CURDIR)/../.. -include $(TOPDIR)/Makefile.inc.phk - .PHONY: all_tests all_tests: ./varnishtest -i -j 4 tests/*.vtc + +$(FOOTER) diff --git a/bin/varnishtop/Makefile.phk b/bin/varnishtop/Makefile.phk index 1b922f3..43d7c29 100644 --- a/bin/varnishtop/Makefile.phk +++ b/bin/varnishtop/Makefile.phk @@ -1,9 +1,11 @@ +include $(ACTIVEDIR)../../master.gq +$(HEADER) + PROG_SRC = varnishtop.c -LD_ADD += ${LIB_VARNISH} -LD_ADD += ${LIB_VARNISHAPI} +PROG_LIBS += ${LIB_VARNISH} +PROG_LIBS += ${LIB_VARNISHAPI} LD_ADD += ${LIB_PCRE} LD_ADD += ${LIB_CURSES} -TOPDIR = $(CURDIR)/../.. -include $(TOPDIR)/Makefile.inc.phk +$(FOOTER) diff --git a/config.phk b/config.phk index aa6856f..d3486aa 100644 --- a/config.phk +++ b/config.phk @@ -140,8 +140,8 @@ fi ask_compiler() { a=`echo "$2" | ${CC-cc} -E - -DWARNS=${WARNS-1} | - sed -e '/^#/d' -e '/^$/d' -e 's/"//g' -e 's/~/"/g' ` - echo "$1='" $a "'" >> _.cache + sed -e '/^#/d' -e '/^$/d' -e 's/"//g' -e 's/~/"/g' | tr -d '\n'` + echo "$1= $a " >> _.cache } # Warning flags diff --git a/footer.gq b/footer.gq new file mode 100644 index 0000000..99eac63 --- /dev/null +++ b/footer.gq @@ -0,0 +1,51 @@ +# we've be given variables, let's process them! +ifdef USE_THREADS +PROG_CFLAGS += -pthread -D_THREAD_SAFE -g -O2 +PROG_LDFLAGS += -lpthread +SHLIB_CFLAGS += -pthread -D_THREAD_SAFE -g -O2 +SHLIB_LDFLAGS += -lpthread +endif + +ifdef USE_DLOPEN +PROG_LDFLAGS += -Wl,-E $(CFG_LIBDL) +endif + +# PROG/LIB/SHLIB follow the same pattern +# - get the name of the target, with path +# - add prefix path to the sources +# - add libs dependencies, if any +# - define the intermediary objects +# - fill target specific variables +# - add a short target, e.g. to type make varnishd to get bin/varnishd/varnishd +ifdef PROG_SRC +PROG_NAME := $(ACTIVEDIR)$(notdir $(ACTIVEDIR:%/=%)) +PROG_SRC_ := $(addprefix $(ACTIVEDIR), $(PROG_SRC)) + +$(PROG_NAME) : $(PROG_SRC_:%.c=%.o) $(PROG_LIBS) +$(PROG_NAME) : PROG_LDFLAGS := $(LD_ADD) $(PROG_LDFLAGS) + +$(PROG_SRC_:%.c=%.o) : %.o : %.c $(addprefix $(ACTIVEDIR), $(MADE_FILES)) +$(PROG_SRC_:%.c=%.o) : CFLAGS := $(CFLAGS) $(PROG_CFLAGS) -I$(ACTIVEDIR) + +DEPS += $(PROG_SRC_:%.c=%.d) +PROGS += $(PROG_NAME) +PROGOBJS += $(PROG_SRC_:%.c=%.o) +TOCLEAN += $(PROGNAME) $(PROGOBJS) $(addprefix $(ACTIVEDIR), $(MADE_FILES)) +$(notdir $(PROG_NAME)): $(PROG_NAME) +all : $(notdir $(PROG_NAME)) +endif + +ifdef LIB_SRC +LIBNAME := $(ACTIVEDIR)$(notdir $(ACTIVEDIR:%/=%)).a +LIB_SRC_ := $(addprefix $(ACTIVEDIR), $(LIB_SRC)) + +$(LIBNAME): $(LIB_SRC_:%.c=%.o) + +$(LIB_SRC_:%.c=%.o) : %.o : %.c $(addprefix $(ACTIVEDIR), $(MADE_FILES)) +$(LIB_SRC_:%.c=%.o) : LIB_CFLAGS += -I$(ACTIVEDIR) + +DEPS += $(LIB_SRC_:%.c=%.d) +LIBS += $(LIBNAME) +LIBOBJS += $(LIB_SRC_:%.c=%.o) +TOCLEAN += $(LIBNAME) $(LIBOBJS) $(addprefix $(ACTIVEDIR), $(MADE_FILES)) +endif diff --git a/header.gq b/header.gq new file mode 100644 index 0000000..35c3752 --- /dev/null +++ b/header.gq @@ -0,0 +1,13 @@ +# simply clean the prog/lib specific variables +PROG_SRC := +PROG_NAME := +PROG_CFLAGS := +PROG_LIBS := +PROG_LDFLAGS := +MAN_NAME := +MADE_FILES := +SHLIB_CFLAGS := +SHLIB_LDFLAGS := +LD_ADD := +LIBNAME := +LIB_SRC := diff --git a/lib/libvarnish/Makefile.phk b/lib/libvarnish/Makefile.phk index 677e687..9d46d88 100644 --- a/lib/libvarnish/Makefile.phk +++ b/lib/libvarnish/Makefile.phk @@ -1,3 +1,5 @@ +include $(ACTIVEDIR)../../master.gq +$(HEADER) LIB_SRC += binary_heap.c LIB_SRC += cli_auth.c @@ -25,6 +27,4 @@ LIB_SRC += vsub.c LIB_SRC += vtcp.c LIB_SRC += vtim.c -TOPDIR= $(CURDIR)/../.. -include $(TOPDIR)/Makefile.inc.phk - +$(FOOTER) \ No newline at end of file diff --git a/lib/libvarnishapi/Makefile.phk b/lib/libvarnishapi/Makefile.phk index 8e86df4..e98b2f9 100644 --- a/lib/libvarnishapi/Makefile.phk +++ b/lib/libvarnishapi/Makefile.phk @@ -1,3 +1,5 @@ +include $(ACTIVEDIR)../../master.gq +$(HEADER) LIB_SRC += vsc.c LIB_SRC += vsl.c @@ -28,10 +30,7 @@ SHLIB_SRC += vtim.c MADE_FILES += vxp_fixed_token.c vxp_tokens.h -TOPDIR= $(CURDIR)/../.. -include $(TOPDIR)/Makefile.inc.phk - -$(MADE_FILES): generate.py - python generate.py - +$(addprefix $(ACTIVEDIR),$(MADE_FILES)): $(ACTIVEDIR)generate.py + cd $(dir $@); $(PYTHON) generate.py +$(FOOTER) diff --git a/lib/libvarnishtools/Makefile.phk b/lib/libvarnishtools/Makefile.phk index 366a04d..b0f3782 100644 --- a/lib/libvarnishtools/Makefile.phk +++ b/lib/libvarnishtools/Makefile.phk @@ -1,7 +1,7 @@ +include $(ACTIVEDIR)../../master.gq +$(HEADER) LIB_SRC += opt2rst.c LIB_SRC += vut.c -TOPDIR= $(CURDIR)/../.. -include $(TOPDIR)/Makefile.inc.phk - +$(FOOTER) \ No newline at end of file diff --git a/lib/libvcc/Makefile.phk b/lib/libvcc/Makefile.phk index 131f850..41b197b 100644 --- a/lib/libvcc/Makefile.phk +++ b/lib/libvcc/Makefile.phk @@ -1,3 +1,5 @@ +include $(ACTIVEDIR)../../master.gq +$(HEADER) LIB_SRC += vcc_acl.c LIB_SRC += vcc_action.c @@ -15,12 +17,14 @@ LIB_SRC += vcc_vmod.c LIB_SRC += vcc_xref.c MADE_FILES += vcc_fixed_token.c vcc_obj.c vcc_token_defs.h +LIB_SRC += vcc_fixed_token.c +LIB_SRC += vcc_obj.c CLEAN_FILES += $(MADE_FILES) -TOPDIR= $(CURDIR)/../.. -include $(TOPDIR)/Makefile.inc.phk -$(MADE_FILES): generate.py - $(PYTHON) generate.py +$(addprefix $(ACTIVEDIR),$(MADE_FILES)): $(ACTIVEDIR)generate.py + cd $(dir $@); $(PYTHON) generate.py + +$(FOOTER) diff --git a/lib/libvgz/Makefile.phk b/lib/libvgz/Makefile.phk index b938312..fb1ec73 100644 --- a/lib/libvgz/Makefile.phk +++ b/lib/libvgz/Makefile.phk @@ -1,3 +1,6 @@ +include $(ACTIVEDIR)../../master.gq +$(HEADER) + LIB_SRC += adler32.c LIB_SRC += compress.c LIB_SRC += crc32.c @@ -10,8 +13,6 @@ LIB_SRC += trees.c LIB_SRC += uncompr.c LIB_SRC += zutil.c -CFLAGS += -DZLIB_CONST -D_LARGEFILE64_SOURCE=1 - -TOPDIR= $(CURDIR)/../.. -include $(TOPDIR)/Makefile.inc.phk +PROG_CFLAGS += -DZLIB_CONST -D_LARGEFILE64_SOURCE=1 +$(FOOTER) diff --git a/lib/libvmod_debug/Makefile.phk b/lib/libvmod_debug/Makefile.phk index 98e52e7..c9a3a2d 100644 --- a/lib/libvmod_debug/Makefile.phk +++ b/lib/libvmod_debug/Makefile.phk @@ -1,7 +1,7 @@ +include $(ACTIVEDIR)../../master.gq +$(HEADER) VMOD_SRC += vmod_debug.c VMOD_SRC += vmod_debug_obj.c -TOPDIR= $(CURDIR)/../.. -include $(TOPDIR)/Makefile.inc.phk - +$(FOOTER) \ No newline at end of file diff --git a/lib/libvmod_directors/Makefile.phk b/lib/libvmod_directors/Makefile.phk index 424a275..0fab75b 100644 --- a/lib/libvmod_directors/Makefile.phk +++ b/lib/libvmod_directors/Makefile.phk @@ -1,3 +1,5 @@ +include $(ACTIVEDIR)../../master.gq +$(HEADER) VMOD_SRC += fall_back.c VMOD_SRC += hash.c @@ -5,6 +7,4 @@ VMOD_SRC += random.c VMOD_SRC += round_robin.c VMOD_SRC += vdir.c -TOPDIR= $(CURDIR)/../.. -include $(TOPDIR)/Makefile.inc.phk - +$(FOOTER) \ No newline at end of file diff --git a/lib/libvmod_std/Makefile.phk b/lib/libvmod_std/Makefile.phk index ca093a0..d27db15 100644 --- a/lib/libvmod_std/Makefile.phk +++ b/lib/libvmod_std/Makefile.phk @@ -1,8 +1,8 @@ +include $(ACTIVEDIR)../../master.gq +$(HEADER) VMOD_SRC += vmod_std.c VMOD_SRC += vmod_std_conversions.c VMOD_SRC += vmod_std_fileread.c -TOPDIR= $(CURDIR)/../.. -include $(TOPDIR)/Makefile.inc.phk - +$(FOOTER) \ No newline at end of file diff --git a/master.gq b/master.gq new file mode 100644 index 0000000..b3d3d4a --- /dev/null +++ b/master.gq @@ -0,0 +1,107 @@ +# include me only once +ifneq ($(MASTER_INCLUDED),yes) +MASTER_INCLUDED=yes +# all is the default target +all: + +# top dir is the one containing this makefile +TOPDIR=$(realpath $(dir $(lastword $(MAKEFILE_LIST)))) + +# set of simply expanded variables () +PROGS := +LIBS := +PROGOBJS := +DEPS := +TOCLEAN := +#FATHER = $(realpath $(lastword $(filter-out $(lastword $(MAKEFILE_LIST)), $(MAKEFILE_LIST)))) + +# including avoid eval jungles +define HEADER +$(eval include $(TOPDIR)/header.gq) +endef + +define FOOTER +$(eval include $(TOPDIR)/footer.gq) +endef + +# not used yet +define FINALIZER +endef + +# load the config (in the future, generate it) +include $(TOPDIR)/_.cache + +# global flags +CFLAGS += $(CF_CFLAGS) $(CF_CWFLAGS) +CFLAGS += -I$(TOPDIR) +CFLAGS += -I$(TOPDIR)/phk_hack +CFLAGS += -I$(TOPDIR)/include +CFLAGS += -I$(TOPDIR)/lib/libvgz +CFLAGS += -I/usr/local/include + +# our own libs are given directly, system ones use -l/-L +LIB_VARNISH = $(TOPDIR)/lib/libvarnish/libvarnish.a +LIB_VARNISHAPI = $(TOPDIR)/lib/libvarnishapi/libvarnishapi.a +LIB_VARNISHTOOLS = $(TOPDIR)/lib/libvarnishtools/libvarnishtools.a +LIB_VCC = $(TOPDIR)/lib/libvcc/libvcc.a +LIB_VGZ = $(TOPDIR)/lib/libvgz/libvgz.a +LIB_PCRE = -L /usr/local/lib -lpcre +LIB_EXECINFO = ${CFG_EXECINFO} +LIB_CURSES = -lcurses +LIB_READLINE = ${CFG_LINEDISC} + +SHLIB_LDFLAGS += -shared -Wl,-x -Wl,--fatal-warnings -Wl,--warn-shared-textrel +VMOD_LDFLAGS += ${SHLIB_LDFLAGS} + +# dirs containing makefiles to look at +DIRS = bin/varnishd \ + bin/varnishlog \ + bin/varnishadm \ + bin/varnishtest \ + bin/varnishstat \ + bin/varnishncsa \ + lib/libvmod_std \ + lib/libvmod_debug \ + lib/libvmod_directors \ + lib/libvarnishapi \ + lib/libvcc \ + lib/libvarnishtools \ + lib/libvarnish \ + lib/libvgz +# don't work yet +DIRS_ = bin/varnishtop bin/varnishreplay \ + bin/varnishhist + +# get absolute, normalized paths +EXPANDED_DIRS = $(realpath $(DIRS:%=$(TOPDIR)/%)) + +# include each Makefile, they all begin with header, and end with footer +$(foreach dir, $(EXPANDED_DIRS), \ + $(eval ACTIVEDIR=$(dir)/) \ + $(eval include $(ACTIVEDIR)/Makefile.phk)) + +WARNS ?= 1 + +# generic rules +.PHONY: all clean +all: + +$(PROGS) : + $(CC) -o $@ $^ $(PROG_LDFLAGS) $(PROG_LIBS) + +$(PROGOBJS): + $(CC) -c $< -o $@ $(CFLAGS) $(PROG_CFLAGS) -MMD + +$(LIBBJS): + $(CC) -c $< -o $@ $(CFLAGS) $(LIB_CFLAGS) -MMD + +$(LIBS): + $(AR) -rc $@ $^ + ranlib $@ + +clean: + rm -f $(TOCLEAN) $(DEPS) + +# include .d files if possible +-include $(DEPS) +endif -- 1.8.4.rc3
_______________________________________________ varnish-dev mailing list [email protected] https://www.varnish-cache.org/lists/mailman/listinfo/varnish-dev
