forked from szberes/titan.core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.genrules
174 lines (144 loc) · 4.44 KB
/
Makefile.genrules
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
##############################################################################
# Copyright (c) 2000-2016 Ericsson Telecom AB
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at
# http://www.eclipse.org/legal/epl-v10.html
#
# Contributors:
# Balasko, Jeno
# Baranyi, Botond
# Forstner, Matyas
# Kovacs, Ferenc
# Pandi, Krisztian
# Raduly, Csaba
# Szabo, Janos Zoltan – initial implementation
#
##############################################################################
# General stuff (to be included at the end of makefiles). The
# following variables are used: DEPFILES, SUBDIRS...
tags: $(SOURCES)
ifdef SUBDIRS
@for i in $(SUBDIRS) ; do \
(cd $$i && $(MAKE) tags) || exit 1; \
done
endif
etags --members *.hh *.h *.c *.cc
dep:
ifdef SUBDIRS
@for i in $(SUBDIRS) ; do \
(cd $$i && $(MAKE) dep) || exit 1; \
done
endif
ifdef DEPFILES
$(MAKE) $(DEPFILES)
endif
clean:
ifdef SUBDIRS
@for i in $(SUBDIRS) ; do \
(cd $$i && $(MAKE) clean) || exit 1; \
done
endif
$(RM) $(TARGETS) $(OBJECTS) $(TOBECLEANED)
distclean:
ifdef SUBDIRS
@for i in $(SUBDIRS) ; do \
(cd $$i && $(MAKE) distclean) || exit 1; \
done
endif
$(RM) $(TARGETS) $(OBJECTS) $(TOBECLEANED) \
$(GENERATED_HEADERS) $(GENERATED_SOURCES) \
$(GENERATED_OTHERS) \
$(DEPFILES) TAGS *.gcno *.gcda
# This target allows us to "make ../clean"
../% $(foreach dir, $(SUBDIRS), $(dir)/%):
cd $(dir $@) && $(MAKE) $(notdir $@)
# General rules to compile C(++) files.
#
# These macros implement "silent" rules during building.
# Define the V make variable or environment variable to a nonzero value to get
# the exact call to the compiler: e.g. make V=1
#
# Define the VD variable to get the exact (verbose) action while
# generating dependencies.
#
NULL :=
SPACE := ${NULL} ${NULL}
DEF_V := 0
DEF_VD:= 0
V_CC_0 = @echo " (CC) " $<;$(SPACE)
V_CXX_0 = @echo " (C++) " $<;$(SPACE)
V_DEP_0 = @echo " (dep) " $<;$(SPACE)
V_CC_ = $(V_CC_$(DEF_V))
V_CXX_ = $(V_CXX_$(DEF_V))
V_DEP_ = $(V_DEP_$(DEF_VD))
V_CC = $(V_CC_$(V))
V_CXX = $(V_CXX_$(V))
V_DEP = $(V_DEP_$(VD))
%.o: %.c
$(V_CC)$(CC) -c $(CPPFLAGS) $(CCFLAGS) $< -o $@
# Special rule for building profmerge files
%.profmerge.o: %.cc
$(V_CXX)$(CXX) -c -DPROF_MERGE $(CPPFLAGS) $(CXXFLAGS) $< -o $@
%.o: %.cc
$(V_CXX)$(CXX) -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@
# Preprocess C/C++ files
%.i: %.c
$(CC) -E $(CPPFLAGS) $(CCFLAGS) \
$< > $@
%.ii: %.cc
$(CXX) -E $(CPPFLAGS) $(CXXFLAGS) \
$< > $@
# General rules to create the dependency file.
%.d: %.c
$(V_DEP)set -e; $(CC) $(CCDEPFLAG) $(CPPFLAGS) $< \
| sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' > $@; \
[ -s $@ ] || rm -f $@
%.d: %.cc
$(V_DEP)set -e; $(CXX) $(CXXDEPFLAG) $(CPPFLAGS) $< \
| sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' > $@; \
[ -s $@ ] || rm -f $@
ifdef DEPFILES
ifndef MAKECMDGOALS
DEPFILES_NEEDED := yes
else
DEPFILES_NEEDED := $(filter-out clean distclean, $(MAKECMDGOALS))
endif
ifdef DEPFILES_NEEDED
DEPFILES_INCLUDE := $(filter-out $(MAKECMDGOALS), $(DEPFILES))
ifdef DEPFILES_INCLUDE
ifeq (,$(findstring n,$(MAKEFLAGS)))
# -n was *not* given to make
-include $(DEPFILES_INCLUDE)
endif
endif
endif
endif
# Building PDFs from man pages (for MinGW)
%.pdf: %.1
man2pdf ./$< $@
# The "./" prefix is important, it tells man that the input is a filename,
# so it shouldn't search through MANPATH.
# List of fake targets:
.PHONY: all install tags dep clean distclean
# Disable all built-in suffix rules of make
.SUFFIXES:
# Do not delete generated headers while building .d files
# (.PRECIOUS would also keep them if make is killed)
.SECONDARY: $(GENERATED_HEADERS)
ifdef SRCDIR
REQUIRED_MAKE_VERSION = 3.81
# 3.80 is known not to work; 3.82 does work
REAL_MAKE_VERSION = $(firstword $(MAKE_VERSION))
EARLIER_MAKE_VERSION = $(firstword $(sort $(REAL_MAKE_VERSION) $(REQUIRED_MAKE_VERSION)))
ifeq "$(REQUIRED_MAKE_VERSION)" "$(EARLIER_MAKE_VERSION)"
# Declare a search path for every source.
# "vpath %.cc $(ABS_SRC)" would lump in generated .cc files,
# potentially picking up generated files laying around in the source dir
# instead of generating them in the build dir.
$(foreach src, $(STATIC_SOURCES) $(ORIGINATORS), $(eval vpath $(src) $(ABS_SRC)))
else
# alas, make 3.80 can't cope with the "foreach/eval vpath" above
#$(warning no OOBE with make $(MAKE_VERSION))
endif
endif