Update README.linux
[deliverable/titan.core.git] / Makefile.genrules
1 ###############################################################################
2 # Copyright (c) 2000-2014 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 %.o: %.cc
83 $(V_CXX)$(CXX) -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@
84
85 # Preprocess C/C++ files
86 %.i: %.c
87 $(CC) -E $(CPPFLAGS) $(CCFLAGS) \
88 $< > $@
89
90 %.ii: %.cc
91 $(CXX) -E $(CPPFLAGS) $(CXXFLAGS) \
92 $< > $@
93
94 # General rules to create the dependency file.
95
96 %.d: %.c
97 $(V_DEP)set -e; $(CC) $(CCDEPFLAG) $(CPPFLAGS) $< \
98 | sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' > $@; \
99 [ -s $@ ] || rm -f $@
100
101 %.d: %.cc
102 $(V_DEP)set -e; $(CXX) $(CXXDEPFLAG) $(CPPFLAGS) $< \
103 | sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' > $@; \
104 [ -s $@ ] || rm -f $@
105
106 ifdef DEPFILES
107 ifndef MAKECMDGOALS
108 DEPFILES_NEEDED := yes
109 else
110 DEPFILES_NEEDED := $(filter-out clean distclean, $(MAKECMDGOALS))
111 endif
112 ifdef DEPFILES_NEEDED
113 DEPFILES_INCLUDE := $(filter-out $(MAKECMDGOALS), $(DEPFILES))
114 ifdef DEPFILES_INCLUDE
115 ifeq (,$(findstring n,$(MAKEFLAGS)))
116 # -n was *not* given to make
117 -include $(DEPFILES_INCLUDE)
118 endif
119 endif
120 endif
121 endif
122
123 # Building PDFs from man pages (for MinGW)
124 %.pdf: %.1
125 man2pdf ./$< $@
126 # The "./" prefix is important, it tells man that the input is a filename,
127 # so it shouldn't search through MANPATH.
128
129 # List of fake targets:
130 .PHONY: all install tags dep clean distclean
131
132 # Disable all built-in suffix rules of make
133 .SUFFIXES:
134
135 # Do not delete generated headers while building .d files
136 # (.PRECIOUS would also keep them if make is killed)
137 .SECONDARY: $(GENERATED_HEADERS)
138
139 ifdef SRCDIR
140
141 REQUIRED_MAKE_VERSION = 3.81
142 # 3.80 is known not to work; 3.82 does work
143 REAL_MAKE_VERSION = $(firstword $(MAKE_VERSION))
144 EARLIER_MAKE_VERSION = $(firstword $(sort $(REAL_MAKE_VERSION) $(REQUIRED_MAKE_VERSION)))
145 ifeq "$(REQUIRED_MAKE_VERSION)" "$(EARLIER_MAKE_VERSION)"
146
147 # Declare a search path for every source.
148 # "vpath %.cc $(ABS_SRC)" would lump in generated .cc files,
149 # potentially picking up generated files laying around in the source dir
150 # instead of generating them in the build dir.
151 $(foreach src, $(STATIC_SOURCES) $(ORIGINATORS), $(eval vpath $(src) $(ABS_SRC)))
152
153 else
154
155 # alas, make 3.80 can't cope with the "foreach/eval vpath" above
156 #$(warning no OOBE with make $(MAKE_VERSION))
157
158 endif
159
160 endif
This page took 0.035024 seconds and 5 git commands to generate.