use USER_CPPFLAGS
[AROS.git] / Makefile.in
blob8188b73f1d3c4c639fb11c8ea8e213da87b22e63
1 # Copyright © 2000-2019, The AROS Development Team. All rights reserved.
2 # $Id$
4 # Main makefile for AROS
6 default: all
8 AROS_BUILD_HOST ?= @aros_build_host@
9 AROS_HOST_CPU ?= @aros_host_cpu@
10 AROS_HOST_ARCH ?= @aros_host_arch@
11 AROS_TARGET_CPU ?= @aros_target_cpu@
12 AROS_TARGET_CPU_MODE ?= @aros_target_cpu_mode@
13 AROS_TARGET_ARCH ?= @aros_target_arch@
14 AROS_TARGET_VARIANT ?= @aros_target_variant@
16 AMIGAOSNDKDIR ?= $(SRCDIR)/local/NDK_3.1
18 # normally, these variable's should go in mmake.config/globalvarfile
19 export AROS_TARGET_BOOTLOADER := @aros_target_bootloader@
20 export AROS_TARGET_ICONSET := @aros_target_iconset@
21 export AROS_GUI_THEME := @aros_target_guitheme@
23 TOP := @AROS_BUILDDIR@
24 SRCDIR := @SRCDIR@
25 include $(TOP)/config/make.cfg
26 ifneq ($(CROSSTOOLS_TARGET),)
27 include $(SRCDIR)/tools/crosstools/$(AROS_TOOLCHAIN).cfg
28 include $(SRCDIR)/tools/crosstools/$(AROS_TOOLCHAIN).deps
29 CROSSTOOLS_BUILDFLAG:=$(CROSSTOOLSDIR)/.installflag-crosstools
30 AROS_TOOLCHAIN_DEPS:=$(AROS_TOOLCHAIN_DEPS) $(SRCDIR)/tools/crosstools/$(AROS_TOOLCHAIN).cfg $(SRCDIR)/tools/crosstools/$(AROS_TOOLCHAIN).deps $(SRCDIR)/tools/crosstools/mmakefile.src
31 else
32 CROSSTOOLS_BUILDFLAG:=
33 endif
35 MMAKE_OPTIONS ?= --srcdir=$(SRCDIR) --builddir=$(TOP)
36 ifneq (,$(findstring s,$(MAKEFLAGS)))
37 MMAKE_OPTIONS += -q
38 endif
41 # Rules for Configure generated files ...
44 #$(TOP)/Makefile: $(SRCDIR)/Makefile.in $(TOP)/config.status
45 # @+$(ECHO) "Regenerating " $(subst $(TOP)/,,$@); \
46 # @$(TOP)/config.status --silent --file=$@:$<
48 #CONFIGUREFILES += $(TOP)/Makefile
50 $(TOP)/mmake.config: $(SRCDIR)/mmake.config.in $(TOP)/config.status
51 @+$(ECHO) "Regenerating " $(subst $(TOP)/,,$@); \
52 @$(TOP)/config.status --silent --file=$@:$<
54 CONFIGUREFILES += $(TOP)/mmake.config
55 CONFIGBUILDFILES += $(TOP)/mmake.config
57 $(TOP)/config/make.cfg: $(SRCDIR)/config/make.cfg.in $(TOP)/config.status
58 @+$(ECHO) "Regenerating " $(subst $(TOP)/,,$@); \
59 @$(TOP)/config.status --silent --file=$@:$<
61 CONFIGUREFILES += $(TOP)/config/make.cfg
62 CONFIGBUILDARCHFILES += $(TOP)/config/make.cfg
64 $(TOP)/compiler/include/geninc.cfg: $(SRCDIR)/compiler/include/geninc.cfg.in $(TOP)/config.status
65 @+$(ECHO) "Regenerating " $(subst $(TOP)/,,$@); \
66 @$(TOP)/config.status --silent --file=$@:$<
68 CONFIGUREFILES += $(TOP)/compiler/include/geninc.cfg
70 $(AROS_INCLUDES)/aros/config.h: $(SRCDIR)/config/config.h.in $(TOP)/config.status
71 @+$(ECHO) "Regenerating " $(subst $(TOP)/,,$@); \
72 @$(TOP)/config.status --silent --file=$@:$<
74 CONFIGUREFILES += $(AROS_INCLUDES)/aros/config.h
76 $(GENINCDIR)/aros/config.h: $(SRCDIR)/config/config.h.in $(TOP)/config.status
77 @+$(ECHO) "Regenerating " $(subst $(TOP)/,,$@); \
78 @$(TOP)/config.status --silent --file=$@:$<
80 CONFIGUREFILES += $(GENINCDIR)/aros/config.h
82 $(GENDIR)/config/target.cfg: $(SRCDIR)/config/target.cfg.in $(TOP)/config.status
83 @+$(ECHO) "Regenerating " $(subst $(TOP)/,,$@); \
84 @$(TOP)/config.status --silent --file=$@:$<
86 CONFIGUREFILES += $(GENDIR)/config/target.cfg
87 CONFIGBUILDARCHFILES += $(GENDIR)/config/target.cfg
89 $(GENDIR)/config/build.cfg: $(SRCDIR)/config/build.cfg.in $(TOP)/config.status
90 @+$(ECHO) "Regenerating " $(subst $(TOP)/,,$@); \
91 @$(TOP)/config.status --silent --file=$@:$<
93 CONFIGUREFILES += $(GENDIR)/config/build.cfg
94 CONFIGBUILDARCHFILES += $(GENDIR)/config/build.cfg
96 $(GENDIR)/config/make.defaults: $(SRCDIR)/config/make.defaults.in $(TOP)/config.status
97 @+$(ECHO) "Regenerating " $(subst $(TOP)/,,$@); \
98 @$(TOP)/config.status --silent --file=$@:$<
100 CONFIGUREFILES += $(GENDIR)/config/make.defaults
102 $(HOSTGENDIR)/config/host.cfg: $(SRCDIR)/config/host.cfg.in $(TOP)/config.status
103 @+$(ECHO) "Regenerating " $(subst $(TOP)/,,$@); \
104 @$(TOP)/config.status --silent --file=$@:$<
106 CONFIGUREFILES += $(HOSTGENDIR)/config/host.cfg
109 # Standard Rules ...
112 all: $(CONFIGUREFILES) crosstools features
113 @+$(CALL) $(MMAKE) $(MMAKE_OPTIONS) AROS.AROS
115 makedirs:
116 @$(RM) $(TOP)/errors
117 @$(FOR) dir in $(AROSDIR) $(GENDIR) $(TOOLDIR) ; do \
118 $(IF) [ ! -d $$dir ]; then \
119 $(MECHO) $(MKDIR) "$$dir" ; \
120 $(MKDIR) "$$dir" ; \
121 else true ; fi ; \
122 done
123 @$(IF) [ ! -f $(AROSDIR)/.gdbinit ]; then \
124 $(CP) $(SRCDIR)/_gdbinit $(AROSDIR)/.gdbinit ; \
125 else true ; fi
127 $(PARSEOFFSETS): $(wildcard $(SRCDIR)/tools/parseoffsets/*.[ch])
128 @$(ECHO) Building parseoffsets...
129 @$(CALL) $(MAKE) $(MKARGS) -C $(SRCDIR)/tools/parseoffsets SRCDIR=$(SRCDIR) TOP=$(TOP)
131 parsesdkoffsets : $(PARSEOFFSETS)
132 @$(IF) [ ! -d $(AMIGAOSNDKDIR) ]; then \
133 $(ECHO) "Please copy the AmigaOS 3.1 (tm) NDK files to $(AMIGAOSNDKDIR)" ; \
134 else \
135 $(ECHO) "Parsing Structure.Offsets file..." ; \
136 $(PARSEOFFSETS) --offsetsfile=$(AMIGAOSNDKDIR)/Includes_Libs/StructOffsets/Structure.Offsets --gendir=$(GENDIR)/tools/parseoffsets --bindir=$(AROS_TESTS)/sdk --sdkdir=$(AROS_INCLUDES) ; \
137 fi ;
139 # Create the tools that are used to build AROS.
140 tools : makedirs mmake $(GENMFSCRIPT) $(ARCHTOOL) $(ELF2HUNK) \
141 $(FLEXCAT) $(CREATEDTDESC) \
142 $(ILBMTOC) $(ILBMTOICON) $(INFOINFO) \
143 $(COLLECT-AROS) $(AFSLIB) $(COPYTOAFS) \
144 $(FD2INLINE) $(FD2PRAGMA) $(SFDC) $(SETREV) $(PARSEOFFSETS)
145 @$(NOP)
147 # rebuild the crosstools if we are reconfigured, or its dependencies change.
148 $(CROSSTOOLSDIR)/.installflag-crosstools: $(TOP)/config.status $(SRCDIR)/tools/crosstools/$(AROS_TOOLCHAIN).cfg $(SRCDIR)/tools/crosstools/$(AROS_TOOLCHAIN).deps $(AROS_TOOLCHAIN_DEPS) tools
149 @+$(IF) ! $(TEST) -f $@ ; then \
150 $(CALL) $(MMAKE) $(MMAKE_OPTIONS) AROS.$(CROSSTOOLS_TARGET) && $(TOUCH) $@ ; \
153 crosstools: tools $(CROSSTOOLS_BUILDFLAG)
154 @$(NOP)
156 $(TOP)/config/features.status: $(SRCDIR)/config/features $(CROSSTOOLS_BUILDFLAG)
157 @$(IF) ! $(TEST) -f $@ ; then \
158 $(ECHO) "Querying target compiler features..." ; \
159 cd $(TOP)/config ; CC="$(TARGET_CC) $(TARGET_SYSROOT)" CFLAGS="$(TARGET_CFLAGS) $(DEBUG_CFLAGS) $(OPTIMIZATION_CFLAGS)" CPP="$(TARGET_CPP) $(TARGET_SYSROOT)" CXX="$(TARGET_CXX) $(TARGET_SYSROOT)" CXXFLAGS=" $(TARGET_CXXFLAGS) $(DEBUG_CFLAGS) $(OPTIMIZATION_CFLAGS)" AROS_DEVELOPER="$(AROS_DEVELOPER)" CONFIG_STATUS="features.status" $(SRCDIR)/config/features --host=$(AROS_BUILD_HOST) --with-config-dir=$(GENDIR)/config ; \
162 CONFIGBUILDARCHFILES += $(TOP)/config/features.status
164 features: crosstools $(TOP)/config/features.status
165 @$(NOP)
167 NATIVEBUILDFILES = $(addprefix $(AROS_SDK)/,$(notdir $(CONFIGBUILDFILES)))
168 NATIVEBUILDARCHFILES = $(addprefix $(AROS_ARCH_SDK)/config/,$(notdir $(CONFIGBUILDARCHFILES)))
170 $(NATIVEBUILDFILES) $(NATIVEBUILDARCHFILES) : $(CONFIGBUILDFILES) $(CONFIGBUILDARCHFILES)
171 @$(ECHO) "Generating " $(subst $(TOP)/,,$@)
173 $(GENMFSCRIPT): $(SRCDIR)/tools/genmf/genmf.py
174 @$(ECHO) Generating $(subst $(TOP)/,,$(GENMFSCRIPT))...
175 @$(TOP)/config.status --silent --file=$(subst $(TOP)/,,$@):$<
177 $(ELF2HUNK): $(SRCDIR)/tools/elf2hunk/elf2hunk.c
178 @$(ECHO) Building elf2hunk...
179 @$(CALL) $(MAKE) $(MKARGS) -C $(SRCDIR)/tools/elf2hunk SRCDIR=$(SRCDIR) TOP=$(TOP)
181 $(ARCHTOOL): $(SRCDIR)/tools/archtools/archtool.c
182 @$(ECHO) Building archtool...
183 @$(CALL) $(MAKE) $(MKARGS) -C $(SRCDIR)/tools/archtools SRCDIR=$(SRCDIR) TOP=$(TOP)
185 $(FLEXCAT): $(wildcard $(SRCDIR)/tools/flexcat/src/*.[ch]) $(wildcard $(SRCDIR)/tools/flexcat/src/sd/*.sd)
186 @$(ECHO) Building flexcat...
187 @$(CALL) $(MAKE) $(MKARGS) -C $(SRCDIR)/tools/flexcat/src -f Makefile.aros SRCDIR=$(SRCDIR) TOP=$(TOP)
189 $(CREATEDTDESC): $(wildcard $(SRCDIR)/tools/dtdesc/*.[ch]) $(wildcard $(SRCDIR)/tools/dtdesc/c_iff/*.[ch])
190 @$(ECHO) Building createdtdesc...
191 @$(CALL) $(MAKE) $(MKARGS) -C $(SRCDIR)/tools/dtdesc -f Makefile.aros SRCDIR=$(SRCDIR) TOP=$(TOP)
193 $(AFSLIB): $(wildcard $(SRCDIR)/workbench/devs/afs/*.[ch])
194 @$(ECHO) Building afslib...
195 @$(CALL) $(MAKE) $(MKARGS) -C $(SRCDIR)/tools/copytoafs -f Makefile.afslib SRCDIR=$(SRCDIR) TOP=$(TOP)
197 $(COPYTOAFS): $(AFSLIB) $(SRCDIR)/tools/copytoafs/copytoafs.c
198 @$(ECHO) Building copytoafs...
199 @$(CALL) $(MAKE) $(MKARGS) -C $(SRCDIR)/tools/copytoafs SRCDIR=$(SRCDIR) TOP=$(TOP)
201 $(ILBMTOC): $(SRCDIR)/tools/ilbmtoc/ilbmtoc.c
202 @$(ECHO) Building ilbmtoc...
203 @$(CALL) $(MAKE) $(MKARGS) -C $(SRCDIR)/tools/ilbmtoc SRCDIR=$(SRCDIR) TOP=$(TOP)
205 $(ILBMTOICON): $(SRCDIR)/tools/ilbmtoicon/ilbmtoicon.c
206 @$(ECHO) Building ilbmtoicon...
207 @$(CALL) $(MAKE) $(MKARGS) $@ -C $(SRCDIR)/tools/ilbmtoicon SRCDIR=$(SRCDIR) TOP=$(TOP)
209 $(INFOINFO): $(SRCDIR)/tools/ilbmtoicon/infoinfo.c
210 @$(ECHO) Building infoinfo...
211 @$(CALL) $(MAKE) $(MKARGS) $@ -C $(SRCDIR)/tools/ilbmtoicon SRCDIR=$(SRCDIR) TOP=$(TOP)
213 $(COLLECT-AROS): $(wildcard $(SRCDIR)/tools/collect-aros/*.[hc])
214 @$(ECHO) Building collect-aros...
215 @$(CALL) $(MAKE) $(MKARGS) -C $(SRCDIR)/tools/collect-aros SRCDIR=$(SRCDIR) TOP=$(TOP)
217 $(FD2INLINE): $(SRCDIR)/tools/fd2inline/fd2inline.c
218 @$(ECHO) Building fd2inline...
219 @$(CALL) $(MAKE) $(MKARGS) -C $(SRCDIR)/tools/fd2inline SRCDIR=$(SRCDIR) TOP=$(TOP)
221 $(FD2PRAGMA): $(SRCDIR)/tools/fd2pragma/fd2pragma.c
222 @$(ECHO) Building fd2pragma...
223 @$(CALL) $(MAKE) $(MKARGS) -C $(SRCDIR)/tools/fd2pragma SRCDIR=$(SRCDIR) TOP=$(TOP)
225 $(SFDC): $(SRCDIR)/tools/sfdc/*.pl
226 @$(ECHO) Building sfdc...
227 @$(CALL) $(MAKE) $(MKARGS) -C $(SRCDIR)/tools/sfdc SRCDIR=$(SRCDIR) TOP=$(TOP)
229 $(SETREV): $(SRCDIR)/tools/setrev/setrev.c
230 @$(ECHO) Building setrev...
231 @$(CALL) $(MAKE) $(MKARGS) -C $(SRCDIR)/tools/setrev SRCDIR=$(SRCDIR) TOP=$(TOP)
233 # MetaMake apparently requires a slighty different compilation. Probably
234 # because it is sort-of an external package as well.
236 mmake: $(TOP)/tools/MetaMake/Makefile $(MMAKE)
237 @$(NOP)
239 $(SRCDIR)/tools/MetaMake/configure: $(SRCDIR)/tools/MetaMake/configure.in
240 @$(ECHO) Building MetaMake...
241 @cd $(SRCDIR)/tools/MetaMake && @aros_host_aclocal@ && @aros_host_autoconf@
243 $(TOP)/tools/MetaMake/Makefile: $(SRCDIR)/tools/MetaMake/configure $(SRCDIR)/tools/MetaMake/Makefile.in
244 @$(IF) [ ! -d $(TOP)/tools/MetaMake ]; then \
245 $(MECHO) $(MKDIR) "$(TOP)/tools/MetaMake" ; \
246 $(MKDIR) "$(TOP)/tools/MetaMake"; \
248 @cd $(TOP)/tools/MetaMake ; CC="$(HOST_CC)" CFLAGS="$(HOST_CFLAGS) -D_FILE_OFFSET_BITS=64" LDFLAGS="$(HOST_LDFLAGS)" $(SRCDIR)/tools/MetaMake/configure --prefix=$(TOOLDIR) --bindir=$(TOOLDIR) --with-objfiledir=$(HOSTGENDIR)/tools/MetaMake
250 $(MMAKE): $(TOP)/tools/MetaMake/Makefile $(wildcard $(SRCDIR)/tools/MetaMake/*.[ch]) $(GENMFSCRIPT)
251 @$(MAKE) $(MKARGS) AUTOHEADER=@aros_host_autoheader@ -C $(TOP)/tools/MetaMake
252 @$(MAKE) $(MKARGS) -C $(TOP)/tools/MetaMake install
254 # Clean the sources and tools
255 clean:
256 @+$(CALL) $(MMAKE) $(MMAKE_OPTIONS) AROS.clean
257 @$(MAKE) $(MKARGS) -C $(TOP)/tools/MetaMake clean SRCDIR=$(SRCDIR) TOP=$(TOP)
258 @$(CALL) $(MAKE) $(MKARGS) -C $(SRCDIR)/tools/flexcat/src -f Makefile.aros clean SRCDIR=$(SRCDIR) TOP=$(TOP)
259 @$(CALL) $(MAKE) $(MKARGS) -C $(SRCDIR)/tools/archtools clean SRCDIR=$(SRCDIR) TOP=$(TOP)
260 @$(CALL) $(MAKE) $(MKARGS) -C $(SRCDIR)/tools/genmf clean
261 @$(CALL) $(MAKE) $(MKARGS) -C $(SRCDIR)/tools/dtdesc -f Makefile.aros clean SRCDIR=$(SRCDIR) TOP=$(TOP)
262 @$(CALL) $(MAKE) $(MKARGS) -C $(SRCDIR)/tools/collect-aros clean SRCDIR=$(SRCDIR) TOP=$(TOP)
263 @$(CALL) $(MAKE) $(MKARGS) -C $(SRCDIR)/tools/fd2inline clean SRCDIR=$(SRCDIR) TOP=$(TOP)
264 @$(CALL) $(MAKE) $(MKARGS) -C $(SRCDIR)/tools/fd2pragma clean SRCDIR=$(SRCDIR) TOP=$(TOP)
265 @$(CALL) $(MAKE) $(MKARGS) -C $(SRCDIR)/tools/sfdc clean SRCDIR=$(SRCDIR) TOP=$(TOP)
266 @$(CALL) $(MAKE) $(MKARGS) -C $(SRCDIR)/tools/setrev clean SRCDIR=$(SRCDIR) TOP=$(TOP)
267 -@$(RM) $(ARCHDIR) Makefile config.cache config.status config.log \
268 mmake.cache mmake.config rom/mmakefile config/make.cfg \
269 $(AROS_DEVELOPMENT)/include/aros/config.h \
270 $(GENDIR)/include/aros/config.h $(HOSTGENDIR)/config/host.cfg \
271 $(GENDIR)/config/target.cfg $(GENDIR)/config/make.defaults \
272 $(GENDIR)/config/specs \
273 $(TOOLDIR)/$(AROS_TARGET_CPU)-$(AROS_TARGET_ARCH)$(AROS_TARGET_SUFFIX)-aros-gcc \
274 $(TOOLDIR)/$(AROS_TARGET_CPU)-$(AROS_TARGET_ARCH)$(AROS_TARGET_SUFFIX)-aros-ld \
275 $(GENDIR)/scripts/genshared $(TOOLDIR)/genmf.py \
276 tools/adflib/myconf.aros tools/collect-aros/env.h
278 # Clean the sources and tools
279 arch-clean: clean
280 @$(NOP)
282 # Really clean all - like a clean checkout
283 dist-clean: arch-clean
284 @$(NOP)
286 sdk : crosstools features $(CONFIGUREFILES) $(NATIVEBUILDFILES) $(NATIVEBUILDARCHFILES)
287 @+$(CALL) $(MMAKE) $(MMAKE_OPTIONS) AROS.$@
289 sdk-test: parsesdkoffsets crosstools features $(CONFIGUREFILES)
290 @$(CALL) $(MAKE) $(MKARGS) -C $(GENDIR)/tools/parseoffsets SRCDIR=$(SRCDIR) TOP=$(TOP) test-sdk-headers-genfiles
292 # Don't try to generate $(TOP)/bin/$(AROS_TARGET_ARCH)-$(AROS_TARGET_CPU)$(AROS_TARGET_SUFFIX)/gen/config/make.opts
293 $(TOP)/bin/$(AROS_TARGET_ARCH)-$(AROS_TARGET_CPU)$(AROS_TARGET_SUFFIX)/gen/config/make.opts:
294 @$(NOP)
296 # targets which do not generate files or for which a file/directory exists
297 .PHONY: default all makedirs tools crosstools features docs clean arch-clean dist-clean install \
298 $(TOP)/bin/$(AROS_TARGET_ARCH)-$(AROS_TARGET_CPU)$(AROS_TARGET_SUFFIX)/gen/config/make.opts \
299 test kernel boot workbench compiler contrib ports sdk mmake query
301 # Workaround for bug in make v3.81 (should normally be handled by .DEFAULT)
302 install test kernel boot workbench compiler contrib ports : crosstools features $(CONFIGUREFILES)
303 @+$(CALL) $(MMAKE) $(MMAKE_OPTIONS) AROS.$@
306 # Bypass crosstools target.
307 query: tools
308 @+$(CALL) $(MMAKE) $(MMAKE_OPTIONS) AROS.$@
310 # Map MetaTargets to make targets : Call mmake with AROS.target
311 # This does not allow to check for dependancies, so it is not suitable for
312 # Calling standard main targets, but is usable as a shortcut for MetaMake
313 # if it was not installed globally
316 distfiles::
317 @+$(CALL) $(MMAKE) $(MMAKE_OPTIONS) AROS.$@
319 # The '%-quick' and '%-clean' targets are special - we don't want to wait around
320 # for building crosstools if we just want to build one subtarget
321 %-quick %-clean:
322 @+$(CALL) $(MMAKE) $(MMAKE_OPTIONS) AROS.$@
324 .DEFAULT: $(CONFIGUREFILES)
325 @$(MAKE) $(MKARGS) crosstools
326 @$(MAKE) $(MKARGS) crosstools features
327 @+$(CALL) $(MMAKE) $(MMAKE_OPTIONS) AROS.$@