Merge pull request #10 from egerpil/master
[deliverable/titan.core.git] / Makefile.genrules
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...
10
11 tags: $(SOURCES)
12 ifdef SUBDIRS
13 @for i in $(SUBDIRS) ; do \
14 (cd $$i && $(MAKE) tags) || exit 1; \
15 done
16 endif
17 etags --members *.hh *.h *.c *.cc
18
19 dep:
20 ifdef SUBDIRS
21 @for i in $(SUBDIRS) ; do \
22 (cd $$i && $(MAKE) dep) || exit 1; \
23 done
24 endif
25 ifdef DEPFILES
26 $(MAKE) $(DEPFILES)
27 endif
28
29 clean:
30 ifdef SUBDIRS
31 @for i in $(SUBDIRS) ; do \
32 (cd $$i && $(MAKE) clean) || exit 1; \
33 done
34 endif
35 $(RM) $(TARGETS) $(OBJECTS) $(TOBECLEANED)
36
37 distclean:
38 ifdef SUBDIRS
39 @for i in $(SUBDIRS) ; do \
40 (cd $$i && $(MAKE) distclean) || exit 1; \
41 done
42 endif
43 $(RM) $(TARGETS) $(OBJECTS) $(TOBECLEANED) \
44 $(GENERATED_HEADERS) $(GENERATED_SOURCES) \
45 $(GENERATED_OTHERS) \
46 $(DEPFILES) TAGS *.gcno *.gcda
47
48 # This target allows us to "make ../clean"
49 ../% $(foreach dir, $(SUBDIRS), $(dir)/%):
50 cd $(dir $@) && $(MAKE) $(notdir $@)
51
52 # General rules to compile C(++) files.
53 #
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
57 #
58 # Define the VD variable to get the exact (verbose) action while
59 # generating dependencies.
60 #
61 NULL :=
62 SPACE := ${NULL} ${NULL}
63
64 DEF_V := 0
65 DEF_VD:= 0
66
67 V_CC_0 = @echo " (CC) " $<;$(SPACE)
68 V_CXX_0 = @echo " (C++) " $<;$(SPACE)
69 V_DEP_0 = @echo " (dep) " $<;$(SPACE)
70
71 V_CC_ = $(V_CC_$(DEF_V))
72 V_CXX_ = $(V_CXX_$(DEF_V))
73 V_DEP_ = $(V_DEP_$(DEF_VD))
74
75 V_CC = $(V_CC_$(V))
76 V_CXX = $(V_CXX_$(V))
77 V_DEP = $(V_DEP_$(VD))
78
79 %.o: %.c
80 $(V_CC)$(CC) -c $(CPPFLAGS) $(CCFLAGS) $< -o $@
81
82 # Special rule for building profmerge files
83 %.profmerge.o: %.cc
84 $(V_CXX)$(CXX) -c -DPROF_MERGE $(CPPFLAGS) $(CXXFLAGS) $< -o $@
85
86 %.o: %.cc
87 $(V_CXX)$(CXX) -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@
88
89 # Preprocess C/C++ files
90 %.i: %.c
91 $(CC) -E $(CPPFLAGS) $(CCFLAGS) \
92 $< > $@
93
94 %.ii: %.cc
95 $(CXX) -E $(CPPFLAGS) $(CXXFLAGS) \
96 $< > $@
97
98 # General rules to create the dependency file.
99
100 %.d: %.c
101 $(V_DEP)set -e; $(CC) $(CCDEPFLAG) $(CPPFLAGS) $< \
102 | sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' > $@; \
103 [ -s $@ ] || rm -f $@
104
105 %.d: %.cc
106 $(V_DEP)set -e; $(CXX) $(CXXDEPFLAG) $(CPPFLAGS) $< \
107 | sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' > $@; \
108 [ -s $@ ] || rm -f $@
109
110 ifdef DEPFILES
111 ifndef MAKECMDGOALS
112 DEPFILES_NEEDED := yes
113 else
114 DEPFILES_NEEDED := $(filter-out clean distclean, $(MAKECMDGOALS))
115 endif
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)
122 endif
123 endif
124 endif
125 endif
126
127 # Building PDFs from man pages (for MinGW)
128 %.pdf: %.1
129 man2pdf ./$< $@
130 # The "./" prefix is important, it tells man that the input is a filename,
131 # so it shouldn't search through MANPATH.
132
133 # List of fake targets:
134 .PHONY: all install tags dep clean distclean
135
136 # Disable all built-in suffix rules of make
137 .SUFFIXES:
138
139 # Do not delete generated headers while building .d files
140 # (.PRECIOUS would also keep them if make is killed)
141 .SECONDARY: $(GENERATED_HEADERS)
142
143 ifdef SRCDIR
144
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)"
150
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)))
156
157 else
158
159 # alas, make 3.80 can't cope with the "foreach/eval vpath" above
160 #$(warning no OOBE with make $(MAKE_VERSION))
161
162 endif
163
164 endif
This page took 0.036041 seconds and 5 git commands to generate.