Merge pull request #47 from ctiller/makeclean

Cleanup makefiles
pull/68/head
Nicolas Noble 10 years ago
commit db2963e7fd
  1. 2818
      Makefile
  2. 138
      templates/Makefile.template

2818
Makefile

File diff suppressed because one or more lines are too long

@ -237,16 +237,19 @@ endif
LDLIBS_SECURE += $(addprefix -l, $(LIBS_SECURE))
ifneq ($(DEP_MISSING),)
NO_DEPS = true
endif
ifneq ($(MAKECMDGOALS),clean)
ifeq ($(MAKECMDGOALS),clean)
NO_DEPS = true
endif
.SECONDARY = %.pb.h %.pb.cc
PROTOC_PLUGINS=\
% for tgt in targets:
% if tgt.build == 'protoc':
bins/$(CONFIG)/${tgt.name}\
% endif
% endfor
ifeq ($(DEP_MISSING),)
all: static shared\
% for tgt in targets:
@ -330,7 +333,7 @@ libs/$(CONFIG)/openssl/libssl.a:
static: static_c static_cxx
static_c: dep_c\
static_c: \
% for lib in libs:
% if lib.build == 'all' and not lib.get('c++', False):
libs/$(CONFIG)/lib${lib.name}.a\
@ -338,7 +341,7 @@ static_c: dep_c\
% endfor
static_cxx: dep_cxx\
static_cxx: \
% for lib in libs:
% if lib.build == 'all' and lib.get('c++', False):
libs/$(CONFIG)/lib${lib.name}.a\
@ -348,7 +351,7 @@ static_cxx: dep_cxx\
shared: shared_c shared_cxx
shared_c: dep_c\
shared_c: \
% for lib in libs:
% if lib.build == 'all' and not lib.get('c++', False):
libs/$(CONFIG)/lib${lib.name}.$(SHARED_EXT)\
@ -356,7 +359,7 @@ shared_c: dep_c\
% endfor
shared_cxx: dep_cxx\
shared_cxx: \
% for lib in libs:
% if lib.build == 'all' and lib.get('c++', False):
libs/$(CONFIG)/lib${lib.name}.$(SHARED_EXT)\
@ -366,7 +369,7 @@ shared_cxx: dep_cxx\
privatelibs: privatelibs_c privatelibs_cxx
privatelibs_c: dep_c\
privatelibs_c: \
% for lib in libs:
% if lib.build == 'private' and not lib.get('c++', False):
libs/$(CONFIG)/lib${lib.name}.a\
@ -374,7 +377,7 @@ privatelibs_c: dep_c\
% endfor
privatelibs_cxx: dep_cxx\
privatelibs_cxx: \
% for lib in libs:
% if lib.build == 'private' and lib.get('c++', False):
libs/$(CONFIG)/lib${lib.name}.a\
@ -384,7 +387,7 @@ privatelibs_cxx: dep_cxx\
buildtests: buildtests_c buildtests_cxx
buildtests_c: bins_dep_c privatelibs_c\
buildtests_c: privatelibs_c\
% for tgt in targets:
% if tgt.build == 'test' and not tgt.get('c++', False):
bins/$(CONFIG)/${tgt.name}\
@ -392,7 +395,7 @@ buildtests_c: bins_dep_c privatelibs_c\
% endfor
buildtests_cxx: bins_dep_cxx privatelibs_cxx\
buildtests_cxx: privatelibs_cxx\
% for tgt in targets:
% if tgt.build == 'test' and tgt.get('c++', False):
bins/$(CONFIG)/${tgt.name}\
@ -428,14 +431,6 @@ tools: privatelibs\
% endfor
protoc_plugins:\
% for tgt in targets:
% if tgt.build == 'protoc':
bins/$(CONFIG)/${tgt.name}\
% endif
% endfor
buildbenchmarks: privatelibs\
% for tgt in targets:
% if tgt.build == 'benchmark':
@ -493,79 +488,32 @@ strip-shared_cxx: shared_cxx
% endfor
% for p in protos:
deps/$(CONFIG)/gens/${p}.pb.dep:
$(Q) mkdir -p `dirname $@`
$(Q) touch $@
gens/${p}.pb.cc: ${p}.proto protoc_plugins
gens/${p}.pb.cc: ${p}.proto $(PROTOC_PLUGINS)
$(E) "[PROTOC] Generating protobuf CC file from $<"
$(Q) mkdir -p `dirname $@`
$(Q) $(PROTOC) --cpp_out=gens --grpc_out=gens --plugin=protoc-gen-grpc=bins/$(CONFIG)/cpp_plugin $<
% endfor
deps/$(CONFIG)/%.dep : %.c
$(E) "[DEP] Generating dependencies for $<"
$(Q) mkdir -p `dirname $@`
$(Q) $(CC) $(CFLAGS) $(CPPFLAGS_NO_ARCH) -MG -M $< > $@
deps/$(CONFIG)/%.dep : %.cc
$(E) "[DEP] Generating dependencies for $<"
$(Q) mkdir -p `dirname $@`
$(Q) $(CXX) $(CXXFLAGS) $(CPPFLAGS_NO_ARCH) -MG -M $< > $@
objs/$(CONFIG)/%.o : %.c
$(E) "[C] Compiling $<"
$(Q) mkdir -p `dirname $@`
$(Q) $(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<
$(Q) $(CC) $(CFLAGS) $(CPPFLAGS) -MMD -MF $(addsuffix .dep, $(basename $@)) -c -o $@ $<
objs/$(CONFIG)/%.o : gens/%.pb.cc
$(E) "[CXX] Compiling $<"
$(Q) mkdir -p `dirname $@`
$(Q) $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c -o $@ $<
$(Q) $(CXX) $(CXXFLAGS) $(CPPFLAGS) -MMD -MF $(addsuffix .dep, $(basename $@)) -c -o $@ $<
objs/$(CONFIG)/src/compiler/%.o : src/compiler/%.cc
$(E) "[HOSTCXX] Compiling $<"
$(Q) mkdir -p `dirname $@`
$(Q) $(HOST_CXX) $(HOST_CXXFLAGS) $(HOST_CPPFLAGS) -c -o $@ $<
$(Q) $(HOST_CXX) $(HOST_CXXFLAGS) $(HOST_CPPFLAGS) -MMD -MF $(addsuffix .dep, $(basename $@)) -c -o $@ $<
objs/$(CONFIG)/%.o : %.cc
$(E) "[CXX] Compiling $<"
$(Q) mkdir -p `dirname $@`
$(Q) $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c -o $@ $<
dep: dep_c dep_cxx
dep_c:\
% for lib in libs:
% if not lib.get('c++', False):
deps_lib${lib.name}\
% endif
% endfor
bins_dep_c:\
% for tgt in targets:
% if not tgt.get('c++', False):
deps_${tgt.name}\
% endif
% endfor
dep_cxx:\
% for lib in libs:
% if lib.get('c++', False):
deps_lib${lib.name}\
% endif
% endfor
bins_dep_cxx:\
% for tgt in targets:
% if tgt.get('c++', False):
deps_${tgt.name}\
% endif
% endfor
$(Q) $(CXX) $(CXXFLAGS) $(CPPFLAGS) -MMD -MF $(addsuffix .dep, $(basename $@)) -c -o $@ $<
install: install_c install_cxx
@ -654,15 +602,8 @@ ifneq ($(SYSTEM),Darwin)
endif
endif
clean:\
% for lib in libs:
clean_lib${lib.name}\
% endfor
% for tgt in targets:
clean_${tgt.name}\
% endfor
$(Q) $(RM) -r deps objs libs bins gens
clean:
$(Q) $(RM) -rf objs libs bins gens
# The various libraries
@ -701,7 +642,6 @@ PUBLIC_HEADERS_C += \\
% endif
LIB${lib.name.upper()}_OBJS = $(addprefix objs/$(CONFIG)/, $(addsuffix .o, $(basename $(LIB${lib.name.upper()}_SRC))))
LIB${lib.name.upper()}_DEPS = $(addprefix deps/$(CONFIG)/, $(addsuffix .dep, $(basename $(LIB${lib.name.upper()}_SRC))))
% if lib.get('secure', True):
ifeq ($(NO_SECURE),true)
@ -788,13 +728,11 @@ endif
endif
% endif
deps_lib${lib.name}: $(LIB${lib.name.upper()}_DEPS)
% if lib.get('secure', True):
ifneq ($(NO_SECURE),true)
% endif
ifneq ($(NO_DEPS),true)
-include $(LIB${lib.name.upper()}_DEPS)
-include $(LIB${lib.name.upper()}_OBJS:.o=.dep)
endif
% if lib.get('secure', True):
endif
@ -811,13 +749,6 @@ objs/$(CONFIG)/${os.path.splitext(src)[0]}.o: \
% endif
% endfor
clean_lib${lib.name}:
$(E) "[CLEAN] Cleaning lib${lib.name} files"
$(Q) $(RM) $(LIB${lib.name.upper()}_OBJS)
$(Q) $(RM) $(LIB${lib.name.upper()}_DEPS)
$(Q) $(RM) libs/$(CONFIG)/lib${lib.name}.a
$(Q) $(RM) libs/$(CONFIG)/lib${lib.name}.$(SHARED_EXT)
</%def>
<%def name="maketarget(tgt)">
@ -829,7 +760,6 @@ ${tgt.name.upper()}_SRC = \\
% endfor
${tgt.name.upper()}_OBJS = $(addprefix objs/$(CONFIG)/, $(addsuffix .o, $(basename $(${tgt.name.upper()}_SRC))))
${tgt.name.upper()}_DEPS = $(addprefix deps/$(CONFIG)/, $(addsuffix .dep, $(basename $(${tgt.name.upper()}_SRC))))
% if tgt.get('secure', True):
ifeq ($(NO_SECURE),true)
@ -896,23 +826,17 @@ objs/$(CONFIG)/${os.path.splitext(src)[0]}.o: \
% endfor
deps_${tgt.name}: $(${tgt.name.upper()}_DEPS)
deps_${tgt.name}: $(${tgt.name.upper()}_OBJS:.o=.dep)
% if tgt.get('secure', True):
ifneq ($(NO_SECURE),true)
% endif
ifneq ($(NO_DEPS),true)
-include $(${tgt.name.upper()}_DEPS)
-include $(${tgt.name.upper()}_OBJS:.o=.dep)
endif
% if tgt.get('secure', True):
endif
% endif
clean_${tgt.name}:
$(E) "[CLEAN] Cleaning ${tgt.name} files"
$(Q) $(RM) $(${tgt.name.upper()}_OBJS)
$(Q) $(RM) $(${tgt.name.upper()}_DEPS)
$(Q) $(RM) bins/$(CONFIG)/${tgt.name}
</%def>
.PHONY: all strip tools \
@ -926,12 +850,6 @@ install-static install-static_c install-static_cxx \
strip strip-shared strip-static \
strip_c strip-shared_c strip-static_c \
strip_cxx strip-shared_cxx strip-static_cxx \
clean \
dep_c dep_cxx bins_dep_c bins_dep_cxx\
% for lib in libs:
deps_lib${lib.name} clean_lib${lib.name}\
% endfor
% for tgt in targets:
deps_${tgt.name} clean_${tgt.name}\
% endfor
dep_c dep_cxx bins_dep_c bins_dep_cxx \
clean

Loading…
Cancel
Save