1 ##############################################################################
2 # Copyright (c) 2000-2016 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
15 # Szabo, Janos Zoltan – initial implementation
17 ##############################################################################
18 # General stuff (to be included at the end of makefiles). The
19 # following variables are used: DEPFILES, SUBDIRS...
23 @for i in $(SUBDIRS) ; do \
24 (cd $$i && $(MAKE) tags) || exit 1; \
27 etags --members *.hh *.h *.c *.cc
31 @for i in $(SUBDIRS) ; do \
32 (cd $$i && $(MAKE) dep) || exit 1; \
41 @for i in $(SUBDIRS) ; do \
42 (cd $$i && $(MAKE) clean) || exit 1; \
45 $(RM) $(TARGETS) $(OBJECTS) $(TOBECLEANED)
49 @for i in $(SUBDIRS) ; do \
50 (cd $$i && $(MAKE) distclean) || exit 1; \
53 $(RM) $(TARGETS) $(OBJECTS) $(TOBECLEANED) \
54 $(GENERATED_HEADERS) $(GENERATED_SOURCES) \
56 $(DEPFILES) TAGS *.gcno *.gcda
58 # This target allows us to "make ../clean"
59 ../% $(foreach dir, $(SUBDIRS), $(dir)/%):
60 cd $(dir $@) && $(MAKE) $(notdir $@)
62 # General rules to compile C(++) files.
64 # These macros implement "silent" rules during building.
65 # Define the V make variable or environment variable to a nonzero value to get
66 # the exact call to the compiler: e.g. make V=1
68 # Define the VD variable to get the exact (verbose) action while
69 # generating dependencies.
72 SPACE := ${NULL} ${NULL}
77 V_CC_0 = @echo " (CC) " $<;$(SPACE)
78 V_CXX_0 = @echo " (C++) " $<;$(SPACE)
79 V_DEP_0 = @echo " (dep) " $<;$(SPACE)
81 V_CC_ = $(V_CC_$(DEF_V))
82 V_CXX_ = $(V_CXX_$(DEF_V))
83 V_DEP_ = $(V_DEP_$(DEF_VD))
87 V_DEP = $(V_DEP_$(VD))
90 $(V_CC)$(CC) -c $(CPPFLAGS) $(CCFLAGS) $< -o $@
92 # Special rule for building profmerge files
94 $(V_CXX)$(CXX) -c -DPROF_MERGE $(CPPFLAGS) $(CXXFLAGS) $< -o $@
97 $(V_CXX)$(CXX) -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@
99 # Preprocess C/C++ files
101 $(CC) -E $(CPPFLAGS) $(CCFLAGS) \
105 $(CXX) -E $(CPPFLAGS) $(CXXFLAGS) \
108 # General rules to create the dependency file.
111 $(V_DEP)set -e; $(CC) $(CCDEPFLAG) $(CPPFLAGS) $< \
112 | sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' > $@; \
113 [ -s $@ ] || rm -f $@
116 $(V_DEP)set -e; $(CXX) $(CXXDEPFLAG) $(CPPFLAGS) $< \
117 | sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' > $@; \
118 [ -s $@ ] || rm -f $@
122 DEPFILES_NEEDED := yes
124 DEPFILES_NEEDED := $(filter-out clean distclean, $(MAKECMDGOALS))
126 ifdef DEPFILES_NEEDED
127 DEPFILES_INCLUDE := $(filter-out $(MAKECMDGOALS), $(DEPFILES))
128 ifdef DEPFILES_INCLUDE
129 ifeq (,$(findstring n,$(MAKEFLAGS)))
130 # -n was *not* given to make
131 -include $(DEPFILES_INCLUDE)
137 # Building PDFs from man pages (for MinGW)
140 # The "./" prefix is important, it tells man that the input is a filename,
141 # so it shouldn't search through MANPATH.
143 # List of fake targets:
144 .PHONY: all install tags dep clean distclean
146 # Disable all built-in suffix rules of make
149 # Do not delete generated headers while building .d files
150 # (.PRECIOUS would also keep them if make is killed)
151 .SECONDARY: $(GENERATED_HEADERS)
155 REQUIRED_MAKE_VERSION = 3.81
156 # 3.80 is known not to work; 3.82 does work
157 REAL_MAKE_VERSION = $(firstword $(MAKE_VERSION))
158 EARLIER_MAKE_VERSION = $(firstword $(sort $(REAL_MAKE_VERSION) $(REQUIRED_MAKE_VERSION)))
159 ifeq "$(REQUIRED_MAKE_VERSION)" "$(EARLIER_MAKE_VERSION)"
161 # Declare a search path for every source.
162 # "vpath %.cc $(ABS_SRC)" would lump in generated .cc files,
163 # potentially picking up generated files laying around in the source dir
164 # instead of generating them in the build dir.
165 $(foreach src, $(STATIC_SOURCES) $(ORIGINATORS), $(eval vpath $(src) $(ABS_SRC)))
169 # alas, make 3.80 can't cope with the "foreach/eval vpath" above
170 #$(warning no OOBE with make $(MAKE_VERSION))