Merge remote-tracking branch 'redux/master' into sh4-pool
[tamarin-stm.git] / build / config.mk
blobddc4911a6090133f7419b1e6044a67e8dca59905
1 # ***** BEGIN LICENSE BLOCK *****
2 # Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 # The contents of this file are subject to the Mozilla Public License Version
5 # 1.1 (the "License"); you may not use this file except in compliance with
6 # the License. You may obtain a copy of the License at
7 # http://www.mozilla.org/MPL/
9 # Software distributed under the License is distributed on an "AS IS" basis,
10 # WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11 # for the specific language governing rights and limitations under the
12 # License.
14 # The Original Code is [Open Source Virtual Machine].
16 # The Initial Developer of the Original Code is
17 # Adobe System Incorporated.
18 # Portions created by the Initial Developer are Copyright (C) 2005-2006
19 # the Initial Developer. All Rights Reserved.
21 # Contributor(s):
23 # Alternatively, the contents of this file may be used under the terms of
24 # either the GNU General Public License Version 2 or later (the "GPL"), or
25 # the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
26 # in which case the provisions of the GPL or the LGPL are applicable instead
27 # of those above. If you wish to allow use of your version of this file only
28 # under the terms of either the GPL or the LGPL, and not to allow others to
29 # use your version of this file under the terms of the MPL, indicate your
30 # decision by deleting the provisions above and replace them with the notice
31 # and other provisions required by the GPL or the LGPL. If you do not delete
32 # the provisions above, a recipient may use your version of this file under
33 # the terms of any one of the MPL, the GPL or the LGPL.
35 # ***** END LICENSE BLOCK *****
37 GARBAGE :=
39 VPATH = $(topsrcdir)
41 curdir := .
42 srcdir := $(topsrcdir)
44 COMPILE_CPPFLAGS = $(CPPFLAGS) $(APP_CPPFLAGS)
45 COMPILE_CXXFLAGS = $(CXXFLAGS) $(APP_CXXFLAGS)
46 COMPILE_CFLAGS = $(CFLAGS) $(APP_CFLAGS)
48 ifdef ENABLE_DEBUG
49 COMPILE_CPPFLAGS += $(DEBUG_CPPFLAGS)
50 COMPILE_CXXFLAGS += $(DEBUG_CXXFLAGS)
51 COMPILE_CFLAGS += $(DEBUG_CFLAGS)
52 LDFLAGS += $(DEBUG_LDFLAGS)
53 else
54 COMPILE_CPPFLAGS += $(OPT_CPPFLAGS)
55 COMPILE_CXXFLAGS += $(OPT_CXXFLAGS)
56 COMPILE_CFLAGS += $(OPT_CFLAGS)
57 endif
59 ifdef MACOSX_DEPLOYMENT_TARGET
60 export MACOSX_DEPLOYMENT_TARGET
61 endif
63 GLOBAL_DEPS := Makefile
65 all::
67 # Usage: from within RECURSE_DIRS
68 # Variables:
69 # $(1) = $(curdir)
70 # $(2) = subdirectory
71 # Note: positional parameters passed to $(call) are expanded "early". This is
72 # the magic that sets and revert $(curdir) and $(srcdir) properly.
73 define RECURSE_DIR
74 # Bug 632086: Generate paths without "./"; closer to canonical form make needs.
75 curdir := $(subst ./,,$(1)/$(2))
76 srcdir := $(topsrcdir)/$$(curdir)
77 include $(topsrcdir)/$$(curdir)/manifest.mk
78 curdir := $(1)
79 endef
81 # Usage: $(call REAL_RECURSE_DIRS,$(DIRS),$(curdir))
82 define REAL_RECURSE_DIRS
83 $(foreach dir,$(1),$(eval $(call RECURSE_DIR,$(2),$(dir))))
84 endef
86 # Usage: $(call RECURSE_DIRS,$(DIRS)))
87 define RECURSE_DIRS
88 $(call REAL_RECURSE_DIRS,$(1),$(curdir))
89 endef
91 # Usage: $(eval $(call THING_SRCS,$(thingname)))
92 define THING_SRCS
93 $(1)_CPPFLAGS ?= $(COMPILE_CPPFLAGS)
94 $(1)_CXXFLAGS ?= $(COMPILE_CXXFLAGS)
95 $(1)_CFLAGS ?= $(COMPILE_CFLAGS)
96 $(1)_CPPFLAGS += $($(1)_EXTRA_CPPFLAGS)
97 $(1)_CXXFLAGS += $($(1)_EXTRA_CXXFLAGS)
98 $(1)_CFLAGS += $($(1)_EXTRA_CFLAGS)
99 $(1)_INCLUDES += $(INCLUDES)
100 $(1)_DEFINES += $(DEFINES)
102 $(1)_CXXOBJS = $$($(1)_CXXSRCS:%.cpp=%.$(OBJ_SUFFIX))
104 $(1)_COBJS = $$($(1)_CSRCS:%.c=%.$(OBJ_SUFFIX))
106 $(1)_ASMOBJS = $$($(1)_ASMSRCS:%.armasm=%.$(OBJ_SUFFIX))
108 $(1)_MASMOBJS = $$($(1)_MASMSRCS:%.asm=%.$(OBJ_SUFFIX))
110 GARBAGE += \
111 $$($(1)_CXXOBJS) \
112 $$($(1)_COBJS) \
113 $$($(1)_ASMOBJS) \
114 $$($(1)_MASMOBJS) \
115 $$($(1)_CXXOBJS:.$(OBJ_SUFFIX)=.$(II_SUFFIX)) \
116 $$($(1)_CXXOBJS:.$(OBJ_SUFFIX)=.deps) \
117 $$($(1)_COBJS:.$(OBJ_SUFFIX)=.$(II_SUFFIX)) \
118 $$($(1)_COBJS:.$(OBJ_SUFFIX)=.deps) \
119 $(NULL)
121 $$($(1)_CXXOBJS:.$(OBJ_SUFFIX)=.$(II_SUFFIX)): %.$(II_SUFFIX): %.cpp $$(GLOBAL_DEPS)
122 @test -d $$(dir $$@) || mkdir -p $$(dir $$@)
123 @echo "Preprocessing $$*"
124 @$(CXX) -E $$($(1)_CPPFLAGS) $$($(1)_CXXFLAGS) $$($(1)_DEFINES) $$($(1)_INCLUDES) $$< > $$@
125 @$(PYTHON) $(topsrcdir)/build/dependparser.py $$*.deps $$< < $$@ > /dev/null
127 $$($(1)_CXXOBJS): %.$(OBJ_SUFFIX): %.$(II_SUFFIX) $$(GLOBAL_DEPS)
128 @echo "Compiling $$*"
129 @$(CXX) $(OUTOPTION)$$@ $$($(1)_CPPFLAGS) $$($(1)_CXXFLAGS) $$($(1)_DEFINES) $$($(1)_INCLUDES) -c $$<
131 $$($(1)_COBJS:.$(OBJ_SUFFIX)=.$(I_SUFFIX)): %.$(I_SUFFIX): %.c $$(GLOBAL_DEPS)
132 @test -d $$(dir $$@) || mkdir -p $$(dir $$@)
133 @echo "Preprocessing $$*"
134 @$(CC) -E $$($(1)_CPPFLAGS) $$($(1)_CFLAGS) $$($(1)_DEFINES) $$($(1)_INCLUDES) $$< > $$@
135 @$(PYTHON) $(topsrcdir)/build/dependparser.py $$*.deps $$< < $$@ > /dev/null
137 $$($(1)_COBJS): %.$(OBJ_SUFFIX): %.$(I_SUFFIX) $$(GLOBAL_DEPS)
138 @echo "Compiling $$*"
139 @$(CC) $(OUTOPTION)$$@ $$($(1)_CPPFLAGS) $$($(1)_CFLAGS) $$($(1)_DEFINES) $$($(1)_INCLUDES) -c $$<
141 $$($(1)_ASMOBJS): %.$(OBJ_SUFFIX): %.armasm $$(GLOBAL_DEPS)
142 $(ASM) -o $$@ $$($(1)_ASMFLAGS) $$<
144 $$($(1)_MASMOBJS): %.$(OBJ_SUFFIX): %.asm $$(GLOBAL_DEPS)
145 $(MASM) -Fo $$@ $$($(1)_MASMFLAGS) $$<
147 $(1).thing.pp: FORCE
148 @$(PYTHON) $(topsrcdir)/build/calcdepends.py $$@ $$($(1)_CXXOBJS:.$(OBJ_SUFFIX)=.$(II_SUFFIX)) $$($(1)_COBJS:.$(OBJ_SUFFIX)=.$(I_SUFFIX))
150 include $(1).thing.pp
152 endef # THINGS_SRCS
154 # Usage: $(eval $(call STATIC_LIBRARY_RULES,$(static_library_thingname)))
155 define STATIC_LIBRARY_RULES
156 $(1)_BASENAME ?= $(1)
157 $(1)_NAME = $(LIB_PREFIX)$$($(1)_BASENAME).$(LIB_SUFFIX)
159 $$($(1)_DIR)$$($(1)_NAME): $$($(1)_CXXOBJS) $$($(1)_COBJS) $$($(1)_ASMOBJS) $$($(1)_MASMOBJS)
160 @echo "Library $$*"
161 $(call MKSTATICLIB,$$@) $$($(1)_CXXOBJS) $$($(1)_COBJS) $$($(1)_ASMOBJS) $$($(1)_MASMOBJS)
163 GARBAGE += $$($(1)_DIR)$$($(1)_NAME)
165 ifdef $(1)_BUILD_ALL
166 all:: $$($(1)_DIR)$$($(1)_NAME)
167 endif
169 endef
171 # Usage: $(eval $(call DLL_RULES,$(dll_thingname)))
172 define DLL_RULES
173 $(1)_BASENAME ?= $(1)
174 $(1)_NAME = $(LIB_PREFIX)$$($(1)_BASENAME).$(DLL_SUFFIX)
175 $(1)_DEPS = \
176 $$($(1)_EXTRA_DEPS) \
177 $$(foreach lib,$$($(1)_STATIC_LIBRARIES) $$($(1)_DLLS),$$($$(lib)_NAME)) \
178 $$(GLOBAL_DEPS) \
179 $(NULL)
180 $(1)_LDFLAGS = \
181 $$(LDFLAGS) \
182 $$($(1)_EXTRA_LDFLAGS) \
183 $$(foreach lib,$$(OS_LIBS),$(call EXPAND_LIBNAME,$$(lib))) \
184 $$(OS_LDFLAGS) \
185 $(NULL)
187 $$($(1)_DIR)$$($(1)_NAME): $$($(1)_CXXOBJS) $$($(1)_COBJS) $$($(1)_DEPS)
188 $(call MKDLL,$$@) $$($(1)_CXXOBJS) $$($(1)_COBJS) \
189 $(LIBPATH). $$(foreach lib,$$($(1)_STATIC_LIBRARIES),$$(call EXPAND_LIBNAME,$$(lib))) \
190 $$(foreach lib,$$($(1)_DLLS),$$(call EXPAND_DLLNAME,$$(lib))) \
191 $$($(1)_LDFLAGS)
193 GARBAGE += $$($(1)_DIR)$$($(1)_NAME)
195 ifdef $(1)_BUILD_ALL
196 all:: $$($(1)_DIR)$$($(1)_NAME)
197 endif
199 endef
201 # Usage: $(eval $(call PROGRAM_RULES,$(program_thingnaame)))
202 define PROGRAM_RULES
203 $(1)_BASENAME ?= $(1)
204 $(1)_NAME ?= $$($(1)_BASENAME)$(PROGRAM_SUFFIX)
205 $(1)_DEPS = \
206 $$($(1)_EXTRA_DEPS) \
207 $$(foreach lib,$$($(1)_STATIC_LIBRARIES) $$($(1)_DLLS),$$($$(lib)_NAME)) \
208 $$(GLOBAL_DEPS) \
209 $(NULL)
210 $(1)_LDFLAGS = \
211 $$(LDFLAGS) \
212 $$($(1)_EXTRA_LDFLAGS) \
213 $$(foreach lib,$$(OS_LIBS),$(call EXPAND_LIBNAME,$$(lib))) \
214 $$(OS_LDFLAGS) \
215 $(NULL)
217 $$($(1)_DIR)$$($(1)_NAME): $$($(1)_CXXOBJS) $$($(1)_DEPS)
218 @echo "Link $$@"
219 $(call MKPROGRAM,$$@) \
220 $$($(1)_CXXOBJS) \
221 $(LIBPATH). $$(foreach lib,$$($(1)_STATIC_LIBRARIES),$$(call EXPAND_LIBNAME,$$(lib))) \
222 $$(foreach lib,$$($(1)_DLLS),$$(call EXPAND_DLLNAME,$$(lib))) \
223 $$($(1)_LDFLAGS)
224 $(ifneq ($POSTMKPROGRAM,''))
225 $(call POSTMKPROGRAM,$$@)
227 GARBAGE += $$($(1)_DIR)$$($(1)_NAME)
229 ifdef $(1)_BUILD_ALL
230 all:: $$($(1)_DIR)$$($(1)_NAME)
231 endif
233 endef
235 # Delete target files if their recipe had an error exit-status code.
236 .DELETE_ON_ERROR:
238 .PHONY: all FORCE