1 ###############################################################################
2 # Copyright (c) 2000-2015 Ericsson Telecom AB
3 # All rights reserved. This program and the accompanying materials
4 # are made available under the terms of the Eclipse Public License v1.0
5 # which accompanies this distribution, and is available at
6 # http://www.eclipse.org/legal/epl-v10.html
7 ###############################################################################
8 # General stuff (to be included at the end of makefiles). The
9 # following variables are used: DEPFILES, SUBDIRS...
13 @for i in $(SUBDIRS) ; do \
14 (cd $$i && $(MAKE) tags) || exit 1; \
17 etags --members *.hh *.h *.c *.cc
21 @for i in $(SUBDIRS) ; do \
22 (cd $$i && $(MAKE) dep) || exit 1; \
31 @for i in $(SUBDIRS) ; do \
32 (cd $$i && $(MAKE) clean) || exit 1; \
35 $(RM) $(TARGETS) $(OBJECTS) $(TOBECLEANED)
39 @for i in $(SUBDIRS) ; do \
40 (cd $$i && $(MAKE) distclean) || exit 1; \
43 $(RM) $(TARGETS) $(OBJECTS) $(TOBECLEANED) \
44 $(GENERATED_HEADERS) $(GENERATED_SOURCES) \
46 $(DEPFILES) TAGS *.gcno *.gcda
48 # This target allows us to "make ../clean"
49 ../% $(foreach dir, $(SUBDIRS), $(dir)/%):
50 cd $(dir $@) && $(MAKE) $(notdir $@)
52 # General rules to compile C(++) files.
54 # These macros implement "silent" rules during building.
55 # Define the V make variable or environment variable to a nonzero value to get
56 # the exact call to the compiler: e.g. make V=1
58 # Define the VD variable to get the exact (verbose) action while
59 # generating dependencies.
62 SPACE := ${NULL} ${NULL}
67 V_CC_0 = @echo " (CC) " $<;$(SPACE)
68 V_CXX_0 = @echo " (C++) " $<;$(SPACE)
69 V_DEP_0 = @echo " (dep) " $<;$(SPACE)
71 V_CC_ = $(V_CC_$(DEF_V))
72 V_CXX_ = $(V_CXX_$(DEF_V))
73 V_DEP_ = $(V_DEP_$(DEF_VD))
77 V_DEP = $(V_DEP_$(VD))
80 $(V_CC)$(CC) -c $(CPPFLAGS) $(CCFLAGS) $< -o $@
82 # Special rule for building profmerge files
84 $(V_CXX)$(CXX) -c -DPROF_MERGE $(CPPFLAGS) $(CXXFLAGS) $< -o $@
87 $(V_CXX)$(CXX) -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@
89 # Preprocess C/C++ files
91 $(CC) -E $(CPPFLAGS) $(CCFLAGS) \
95 $(CXX) -E $(CPPFLAGS) $(CXXFLAGS) \
98 # General rules to create the dependency file.
101 $(V_DEP)set -e; $(CC) $(CCDEPFLAG) $(CPPFLAGS) $< \
102 | sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' > $@; \
103 [ -s $@ ] || rm -f $@
106 $(V_DEP)set -e; $(CXX) $(CXXDEPFLAG) $(CPPFLAGS) $< \
107 | sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' > $@; \
108 [ -s $@ ] || rm -f $@
112 DEPFILES_NEEDED := yes
114 DEPFILES_NEEDED := $(filter-out clean distclean, $(MAKECMDGOALS))
116 ifdef DEPFILES_NEEDED
117 DEPFILES_INCLUDE := $(filter-out $(MAKECMDGOALS), $(DEPFILES))
118 ifdef DEPFILES_INCLUDE
119 ifeq (,$(findstring n,$(MAKEFLAGS)))
120 # -n was *not* given to make
121 -include $(DEPFILES_INCLUDE)
127 # Building PDFs from man pages (for MinGW)
130 # The "./" prefix is important, it tells man that the input is a filename,
131 # so it shouldn't search through MANPATH.
133 # List of fake targets:
134 .PHONY: all install tags dep clean distclean
136 # Disable all built-in suffix rules of make
139 # Do not delete generated headers while building .d files
140 # (.PRECIOUS would also keep them if make is killed)
141 .SECONDARY: $(GENERATED_HEADERS)
145 REQUIRED_MAKE_VERSION = 3.81
146 # 3.80 is known not to work; 3.82 does work
147 REAL_MAKE_VERSION = $(firstword $(MAKE_VERSION))
148 EARLIER_MAKE_VERSION = $(firstword $(sort $(REAL_MAKE_VERSION) $(REQUIRED_MAKE_VERSION)))
149 ifeq "$(REQUIRED_MAKE_VERSION)" "$(EARLIER_MAKE_VERSION)"
151 # Declare a search path for every source.
152 # "vpath %.cc $(ABS_SRC)" would lump in generated .cc files,
153 # potentially picking up generated files laying around in the source dir
154 # instead of generating them in the build dir.
155 $(foreach src, $(STATIC_SOURCES) $(ORIGINATORS), $(eval vpath $(src) $(ABS_SRC)))
159 # alas, make 3.80 can't cope with the "foreach/eval vpath" above
160 #$(warning no OOBE with make $(MAKE_VERSION))