try to make sure compiler/include/mmakefile is always refreshed correctly.
[AROS.git] / Makefile.in
blob24c2217249326cdea019744752804c63996e3e24
1 # Copyright © 2000-2016, 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 # normally, these variable's should go in mmake.config/globalvarfile
17 export AROS_TARGET_BOOTLOADER := @aros_target_bootloader@
18 export AROS_TARGET_ICONSET := @aros_target_iconset@
19 export AROS_GUI_THEME := @aros_target_guitheme@
21 TOP := @AROS_BUILDDIR@
22 SRCDIR := @SRCDIR@
23 include $(TOP)/config/make.cfg
24 ifneq ($(CROSSTOOLS_TARGET),)
25 include $(SRCDIR)/tools/crosstools/$(AROS_TOOLCHAIN).cfg
26 include $(SRCDIR)/tools/crosstools/$(AROS_TOOLCHAIN).deps
27 CROSSTOOLS_BUILDFLAG:=$(CROSSTOOLSDIR)/.installflag-crosstools
28 AROS_TOOLCHAIN_DEPS:=$(AROS_TOOLCHAIN_DEPS) $(SRCDIR)/tools/crosstools/$(AROS_TOOLCHAIN).cfg $(SRCDIR)/tools/crosstools/$(AROS_TOOLCHAIN).deps $(SRCDIR)/tools/crosstools/mmakefile.src
29 else
30 CROSSTOOLS_BUILDFLAG:=
31 endif
33 MMAKE_OPTIONS ?= --srcdir=$(SRCDIR) --builddir=$(TOP)
34 ifneq (,$(findstring s,$(MAKEFLAGS)))
35 MMAKE_OPTIONS += -q
36 endif
38 $(TOP)/compiler/include/mmakefile: $(SRCDIR)/compiler/include/mmakefile.in $(TOP)/config.status $(SRCDIR)/compiler/include/mmakefile.src $(SRCDIR)/config/make.tmpl
39 @$(TOP)/config.status --file=$@:$<
41 all: $(TOP)/compiler/include/mmakefile crosstools features
42 @+$(CALL) $(MMAKE) $(MMAKE_OPTIONS) AROS.AROS
44 makedirs:
45 @$(RM) $(TOP)/errors
46 @$(FOR) dir in $(AROSDIR) $(GENDIR) $(TOOLDIR) ; do \
47 $(IF) [ ! -d $$dir ]; then \
48 $(MECHO) $(MKDIR) "$$dir" ; \
49 $(MKDIR) "$$dir" ; \
50 else true ; fi ; \
51 done
52 @$(IF) [ ! -f $(AROSDIR)/.gdbinit ]; then \
53 $(CP) $(SRCDIR)/_gdbinit $(AROSDIR)/.gdbinit ; \
54 else true ; fi
56 # Create the tools that are used to build AROS.
57 tools : makedirs mmake $(GENMF) $(ARCHTOOL) $(ELF2HUNK) \
58 $(FLEXCAT) $(CREATEDTDESC) \
59 $(ILBMTOC) $(ILBMTOICON) $(INFOINFO) \
60 $(COLLECT-AROS) $(AFSLIB) $(COPYTOAFS) \
61 $(FD2INLINE) $(FD2PRAGMA) $(SFDC) $(SETREV)
62 @$(NOP)
64 # rebuild the crosstools if we are reconfigured, or its dependencies change.
65 $(CROSSTOOLSDIR)/.installflag-crosstools: $(TOP)/config.status $(AROS_TOOLCHAIN_DEPS) tools
66 @+$(IF) ! $(TEST) -f $@ ; then \
67 $(CALL) $(MMAKE) $(MMAKE_OPTIONS) AROS.$(CROSSTOOLS_TARGET) && $(TOUCH) $@ ; \
70 crosstools: tools $(CROSSTOOLS_BUILDFLAG)
71 @$(NOP)
73 $(TOP)/config/features.status: $(SRCDIR)/config/features $(CROSSTOOLS_BUILDFLAG)
74 @$(IF) ! $(TEST) -f $@ ; then \
75 $(ECHO) "Querying target compiler features..." ; \
76 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)" CONFIG_STATUS="features.status" $(SRCDIR)/config/features --host=$(AROS_BUILD_HOST) --with-config-dir=$(GENDIR)/config ; \
79 features: crosstools $(TOP)/config/features.status
80 @$(NOP)
82 $(GENMF): $(SRCDIR)/tools/genmf/genmf.py
83 @$(ECHO) Copying genmf...
84 @./config.status $(subst $(TOP)/,,$(GENMF)) genmf_executable
86 $(ELF2HUNK): $(SRCDIR)/tools/elf2hunk/elf2hunk.c
87 @$(ECHO) Building elf2hunk...
88 @$(CALL) $(MAKE) $(MKARGS) -C $(SRCDIR)/tools/elf2hunk SRCDIR=$(SRCDIR) TOP=$(TOP)
90 $(ARCHTOOL): $(SRCDIR)/tools/archtools/archtool.c
91 @$(ECHO) Building archtool...
92 @$(CALL) $(MAKE) $(MKARGS) -C $(SRCDIR)/tools/archtools SRCDIR=$(SRCDIR) TOP=$(TOP)
94 $(FLEXCAT): $(wildcard $(SRCDIR)/tools/flexcat/src/*.[ch]) $(wildcard $(SRCDIR)/tools/flexcat/src/sd/*.sd)
95 @$(ECHO) Building flexcat...
96 @$(CALL) $(MAKE) $(MKARGS) -C $(SRCDIR)/tools/flexcat/src -f Makefile.aros SRCDIR=$(SRCDIR) TOP=$(TOP)
98 $(CREATEDTDESC): $(wildcard $(SRCDIR)/tools/dtdesc/*.[ch]) $(wildcard $(SRCDIR)/tools/dtdesc/c_iff/*.[ch])
99 @$(ECHO) Building createdtdesc...
100 @$(CALL) $(MAKE) $(MKARGS) -C $(SRCDIR)/tools/dtdesc -f Makefile.aros SRCDIR=$(SRCDIR) TOP=$(TOP)
102 $(AFSLIB): $(wildcard $(SRCDIR)/workbench/devs/afs/*.[ch])
103 @$(ECHO) Building afslib...
104 @$(CALL) $(MAKE) $(MKARGS) -C $(SRCDIR)/tools/copytoafs -f Makefile.afslib SRCDIR=$(SRCDIR) TOP=$(TOP)
106 $(COPYTOAFS): $(AFSLIB) $(SRCDIR)/tools/copytoafs/copytoafs.c
107 @$(ECHO) Building copytoafs...
108 @$(CALL) $(MAKE) $(MKARGS) -C $(SRCDIR)/tools/copytoafs SRCDIR=$(SRCDIR) TOP=$(TOP)
110 $(ILBMTOC): $(SRCDIR)/tools/ilbmtoc/ilbmtoc.c
111 @$(ECHO) Building ilbmtoc...
112 @$(CALL) $(MAKE) $(MKARGS) -C $(SRCDIR)/tools/ilbmtoc SRCDIR=$(SRCDIR) TOP=$(TOP)
114 $(ILBMTOICON): $(SRCDIR)/tools/ilbmtoicon/ilbmtoicon.c
115 @$(ECHO) Building ilbmtoicon...
116 @$(CALL) $(MAKE) $(MKARGS) $@ -C $(SRCDIR)/tools/ilbmtoicon SRCDIR=$(SRCDIR) TOP=$(TOP)
118 $(INFOINFO): $(SRCDIR)/tools/ilbmtoicon/infoinfo.c
119 @$(ECHO) Building infoinfo...
120 @$(CALL) $(MAKE) $(MKARGS) $@ -C $(SRCDIR)/tools/ilbmtoicon SRCDIR=$(SRCDIR) TOP=$(TOP)
122 $(COLLECT-AROS): $(wildcard $(SRCDIR)/tools/collect-aros/*.[hc])
123 @$(ECHO) Building collect-aros...
124 @$(CALL) $(MAKE) $(MKARGS) -C $(SRCDIR)/tools/collect-aros SRCDIR=$(SRCDIR) TOP=$(TOP)
126 $(FD2INLINE): $(SRCDIR)/tools/fd2inline/fd2inline.c
127 @$(ECHO) Building fd2inline...
128 @$(CALL) $(MAKE) $(MKARGS) -C $(SRCDIR)/tools/fd2inline SRCDIR=$(SRCDIR) TOP=$(TOP)
130 $(FD2PRAGMA): $(SRCDIR)/tools/fd2pragma/fd2pragma.c
131 @$(ECHO) Building fd2pragma...
132 @$(CALL) $(MAKE) $(MKARGS) -C $(SRCDIR)/tools/fd2pragma SRCDIR=$(SRCDIR) TOP=$(TOP)
134 $(SFDC): $(SRCDIR)/tools/sfdc/*.pl
135 @$(ECHO) Building sfdc...
136 @$(CALL) $(MAKE) $(MKARGS) -C $(SRCDIR)/tools/sfdc SRCDIR=$(SRCDIR) TOP=$(TOP)
138 $(SETREV): $(SRCDIR)/tools/setrev/setrev.c
139 @$(ECHO) Building setrev...
140 @$(CALL) $(MAKE) $(MKARGS) -C $(SRCDIR)/tools/setrev SRCDIR=$(SRCDIR) TOP=$(TOP)
142 # MetaMake apparently requires a slighty different compilation. Probably
143 # because it is sort-of an external package as well.
145 mmake: $(TOP)/tools/MetaMake/Makefile $(MMAKE)
146 @$(NOP)
148 $(SRCDIR)/tools/MetaMake/configure: $(SRCDIR)/tools/MetaMake/configure.in
149 @$(ECHO) Building MetaMake...
150 @cd $(SRCDIR)/tools/MetaMake && @aros_host_aclocal@ && @aros_host_autoconf@
152 $(TOP)/tools/MetaMake/Makefile: $(SRCDIR)/tools/MetaMake/configure $(SRCDIR)/tools/MetaMake/Makefile.in
153 @$(IF) [ ! -d $(TOP)/tools/MetaMake ]; then \
154 $(MECHO) $(MKDIR) "$(TOP)/tools/MetaMake" ; \
155 $(MKDIR) "$(TOP)/tools/MetaMake"; \
157 @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
159 $(MMAKE): $(TOP)/tools/MetaMake/Makefile $(wildcard $(SRCDIR)/tools/MetaMake/*.[ch]) $(GENMF)
160 @$(MAKE) $(MKARGS) AUTOHEADER=@aros_host_autoheader@ -C $(TOP)/tools/MetaMake
161 @$(MAKE) $(MKARGS) -C $(TOP)/tools/MetaMake install
163 # Clean the sources and tools
164 clean:
165 @+$(CALL) $(MMAKE) $(MMAKE_OPTIONS) AROS.clean
166 @$(MAKE) $(MKARGS) -C $(TOP)/tools/MetaMake clean SRCDIR=$(SRCDIR) TOP=$(TOP)
167 @$(CALL) $(MAKE) $(MKARGS) -C $(SRCDIR)/tools/flexcat/src -f Makefile.aros clean SRCDIR=$(SRCDIR) TOP=$(TOP)
168 @$(CALL) $(MAKE) $(MKARGS) -C $(SRCDIR)/tools/archtools clean SRCDIR=$(SRCDIR) TOP=$(TOP)
169 @$(CALL) $(MAKE) $(MKARGS) -C $(SRCDIR)/tools/genmf clean
170 @$(CALL) $(MAKE) $(MKARGS) -C $(SRCDIR)/tools/dtdesc -f Makefile.aros clean SRCDIR=$(SRCDIR) TOP=$(TOP)
171 @$(CALL) $(MAKE) $(MKARGS) -C $(SRCDIR)/tools/collect-aros clean SRCDIR=$(SRCDIR) TOP=$(TOP)
172 @$(CALL) $(MAKE) $(MKARGS) -C $(SRCDIR)/tools/fd2inline clean SRCDIR=$(SRCDIR) TOP=$(TOP)
173 @$(CALL) $(MAKE) $(MKARGS) -C $(SRCDIR)/tools/fd2pragma clean SRCDIR=$(SRCDIR) TOP=$(TOP)
174 @$(CALL) $(MAKE) $(MKARGS) -C $(SRCDIR)/tools/sfdc clean SRCDIR=$(SRCDIR) TOP=$(TOP)
175 @$(CALL) $(MAKE) $(MKARGS) -C $(SRCDIR)/tools/setrev clean SRCDIR=$(SRCDIR) TOP=$(TOP)
176 -@$(RM) $(ARCHDIR) Makefile config.cache config.status config.log \
177 mmake.cache mmake.config rom/mmakefile config/make.cfg \
178 $(AROS_DEVELOPMENT)/include/aros/config.h \
179 $(GENDIR)/include/aros/config.h $(HOSTGENDIR)/config/host.cfg \
180 $(GENDIR)/config/target.cfg $(GENDIR)/config/make.defaults \
181 $(GENDIR)/config/specs \
182 $(TOOLDIR)/$(AROS_TARGET_CPU)-$(AROS_TARGET_ARCH)$(AROS_TARGET_SUFFIX)-aros-gcc \
183 $(TOOLDIR)/$(AROS_TARGET_CPU)-$(AROS_TARGET_ARCH)$(AROS_TARGET_SUFFIX)-aros-ld \
184 $(GENDIR)/scripts/genshared $(TOOLDIR)/genmf.py \
185 tools/adflib/myconf.aros tools/collect-aros/env.h
187 # Clean the sources and tools
188 arch-clean: clean
189 @$(NOP)
191 # Really clean all - like a clean checkout
192 dist-clean: arch-clean
193 @$(NOP)
195 # Don't try to generate $(TOP)/bin/$(AROS_TARGET_ARCH)-$(AROS_TARGET_CPU)$(AROS_TARGET_SUFFIX)/gen/config/make.opts
196 $(TOP)/bin/$(AROS_TARGET_ARCH)-$(AROS_TARGET_CPU)$(AROS_TARGET_SUFFIX)/gen/config/make.opts:
197 @$(NOP)
199 # targets which do not generate files or for which a file/directory exists
200 .PHONY: default all makedirs tools crosstools features docs clean arch-clean dist-clean install \
201 $(TOP)/bin/$(AROS_TARGET_ARCH)-$(AROS_TARGET_CPU)$(AROS_TARGET_SUFFIX)/gen/config/make.opts \
202 test kernel boot workbench compiler contrib ports sdk mmake query
204 # Workaround for bug in make v3.81 (should normally be handled by .DEFAULT)
205 install test kernel boot workbench compiler contrib ports sdk : crosstools features $(TOP)/compiler/include/mmakefile
206 @+$(CALL) $(MMAKE) $(MMAKE_OPTIONS) AROS.$@
208 # Bypass crosstools target.
209 query: tools
210 @+$(CALL) $(MMAKE) $(MMAKE_OPTIONS) AROS.$@
212 # Map MetaTargets to make targets : Call mmake with AROS.target
213 # This does not allow to check for dependancies, so it is not suitable for
214 # Calling standard main targets, but is usable as a shortcut for MetaMake
215 # if it was not installed globally
218 distfiles::
219 @+$(CALL) $(MMAKE) $(MMAKE_OPTIONS) AROS.$@
221 # The '%-quick' and '%-clean' targets are special - we don't want to wait around
222 # for building crosstools if we just want to build one subtarget
223 %-quick %-clean:
224 @+$(CALL) $(MMAKE) $(MMAKE_OPTIONS) AROS.$@
226 .DEFAULT: $(TOP)/compiler/include/mmakefile
227 @$(MAKE) $(MKARGS) crosstools
228 @$(MAKE) $(MKARGS) crosstools features
229 @+$(CALL) $(MMAKE) $(MMAKE_OPTIONS) AROS.$@