1 # Copyright © 1995-2019, The AROS Development Team. All rights reserved.
4 # Static makefile rule file for AROS.
6 ifneq ($(AROS_TARGET_VARIANT),)
7 AROS_TARGET_SUFFIX =-$(AROS_TARGET_VARIANT)
8 ifeq ($(AROS_TARGET_ARCH),pc)
9 # 'pc' target has 'tiny' variant for boot floppy, which affects only GRUB options.
10 # It should not affect AROS_TARGET_PLATFORM
11 AROS_TARGET_PLATFORM := $(AROS_TARGET_ARCH)-$(AROS_TARGET_CPU)
13 AROS_TARGET_PLATFORM := $(AROS_TARGET_VARIANT)-$(AROS_TARGET_CPU)
17 AROS_TARGET_PLATFORM := $(AROS_TARGET_ARCH)-$(AROS_TARGET_CPU)
20 # All files corresponding to a specific host go here.
21 DIR_HOST := bin/$(AROS_HOST_ARCH)-$(AROS_HOST_CPU)
22 HOSTDIR := $(TOP)/$(DIR_HOST)
24 TOOLDIR := $(HOSTDIR)/$(DIR_TOOLS)
26 HOSTGENDIR := $(HOSTDIR)/gen/host
28 # All files corresponding to a specific target go here.
29 TARGETDIR := $(TOP)/bin/$(AROS_TARGET_ARCH)-$(AROS_TARGET_CPU)$(AROS_TARGET_SUFFIX)
31 GENDIR := $(TARGETDIR)/gen
33 CC_PREFIX := @aros_cc_pre@
35 -include $(GENDIR)/config/make.defaults
36 -include $(GENDIR)/config/make.opts
38 # target.cfg *must* come before host.cfg,
39 # and both must come before build.cfg
40 include $(GENDIR)/config/target.cfg
41 include $(HOSTGENDIR)/config/host.cfg
42 include $(GENDIR)/config/build.cfg
44 # Cross tools installation directory.
45 CROSSTOOLSDIR := @AROS_CROSSTOOLSDIR@
47 # Files downloaded from the net are put here
48 PORTSSOURCEDIR := @AROS_PORTSSRCDIR@
49 PORTSDIR := $(TARGETDIR)/Ports
51 # Distributable Files we generate are put here
52 DISTDIR := @AROS_BUILDDIR_UNIX@/distfiles
54 # File for AROS gcc cross compiler spec file
55 SPECS := $(GENDIR)/config/specs
57 # This is the directory structure for an AROS system.
58 AROSDIR := $(TARGETDIR)/AROS
60 # Relative paths for standard directories
62 ifeq ($(AROS_TARGET_ARCH),pc)
63 AROS_DIR_ARCH := $(AROS_DIR_BOOT)/$(AROS_TARGET_ARCH)
65 AROS_DIR_ARCH := $(AROS_DIR_BOOT)/$(AROS_TARGET_ARCH)$(AROS_TARGET_SUFFIX)
68 AROS_DIR_CLASSES := Classes
69 AROS_DIR_DATATYPES := $(AROS_DIR_CLASSES)/Datatypes
70 AROS_DIR_GADGETS := $(AROS_DIR_CLASSES)/Gadgets
72 AROS_DIR_EXPANSION := Expansion
74 AROS_DIR_LIBRARIES := Libs
75 AROS_DIR_LOCALE := Locale
77 AROS_DIR_TOOLS := Tools
79 AROS_DIR_DEVELOPER := Developer
83 AROS_DIR_INCLUDE := include
86 AROS_DIR_CONTRIB := Extras
88 # Absolute paths for standard directories
89 AROSARCHDIR := $(AROSDIR)/$(AROS_DIR_ARCH)
90 AROS_BOOT := $(AROSDIR)/$(AROS_DIR_BOOT)
91 AROS_C := $(AROSDIR)/$(AROS_DIR_C)
92 AROS_CLASSES := $(AROSDIR)/$(AROS_DIR_CLASSES)
93 AROS_CLASSES_ARCH := $(AROSDIR)/$(AROS_DIR_ARCH)/$(AROS_DIR_CLASSES)
94 AROS_DATATYPES := $(AROSDIR)/$(AROS_DIR_DATATYPES)
95 AROS_GADGETS := $(AROSDIR)/$(AROS_DIR_GADGETS)
96 AROS_DEVS := $(AROSDIR)/$(AROS_DIR_DEVS)
97 AROS_DEVS_ARCH := $(AROSDIR)/$(AROS_DIR_ARCH)/$(AROS_DIR_DEVS)
98 AROS_EXPANSION := $(AROSDIR)/$(AROS_DIR_EXPANSION)
99 AROS_FS := $(AROSDIR)/$(AROS_DIR_FS)
100 AROS_FS_ARCH := $(AROSDIR)/$(AROS_DIR_ARCH)/$(AROS_DIR_FS)
101 AROS_RESOURCES := $(AROS_DEVS)
102 AROS_DRIVERS := $(AROS_DEVS)/Drivers
103 AROS_LIBRARIES := $(AROSDIR)/$(AROS_DIR_LIBRARIES)
104 AROS_LIBRARIES_ARCH := $(AROSDIR)/$(AROS_DIR_ARCH)/$(AROS_DIR_LIBRARIES)
105 AROS_LOCALE := $(AROSDIR)/$(AROS_DIR_LOCALE)
106 AROS_CATALOGS := $(AROS_LOCALE)/Catalogs
107 AROS_HELP := $(AROS_LOCALE)/Help
108 AROS_PREFS := $(AROSDIR)/Prefs
109 AROS_ENVARC := $(AROS_PREFS)/Env-Archive
110 AROS_PACKAGES := $(AROS_ENVARC)/SYS/Packages
111 AROS_PRINTERS := $(AROS_DEVS)/Printers
112 AROS_S := $(AROSDIR)/$(AROS_DIR_S)
113 AROS_SYSTEM := $(AROSDIR)/System
114 AROS_WANDERER := $(AROS_SYSTEM)/Wanderer
115 AROS_THEMES := $(AROS_PREFS)/Presets/Themes
116 AROS_IMAGES := $(AROS_SYSTEM)/Images
117 AROS_TOOLS := $(AROSDIR)/$(AROS_DIR_TOOLS)
118 AROS_UTILITIES := $(AROSDIR)/Utilities
120 AROS_CONTRIB := $(AROSDIR)/$(AROS_DIR_CONTRIB)
122 # Absolute paths for developer directories
123 AROS_DEVELOPER := $(AROSDIR)/$(AROS_DIR_DEVELOPER)
124 AROS_SDK ?= $(AROS_DEVELOPER)/$(AROS_DIR_SDK)
125 AROS_ARCH_SDK ?= $(AROS_SDK)/$(AROS_TARGET_CPU)-$(AROS_TARGET_ARCH)$(AROS_TARGET_SUFFIX)-aros
126 AROS_DEV_ARCH_BINS := $(AROS_DEVELOPER)/$(AROS_TARGET_CPU)-aros/$(AROS_DIR_BIN)
127 AROS_DEV_BINS := $(AROS_DEVELOPER)/$(AROS_DIR_BIN)
128 AROS_DEBUG := $(AROS_DEVELOPER)/Debug
129 AROS_SDK_FD := $(AROS_SDK)/$(AROS_DIR_FD)
130 AROS_TESTS := $(AROS_DEBUG)/Tests
131 AROS_ARCH_INCLUDES = $(AROS_ARCH_SDK)/$(AROS_DIR_INCLUDE)
132 AROS_INCLUDES := $(AROS_DEVELOPER)/$(AROS_DIR_INCLUDE)
133 #AROS_INCLUDES := $(AROS_SDK)/$(AROS_DIR_INCLUDE)
134 AROS_ARCH_LIB = $(AROS_ARCH_SDK)/$(AROS_DIR_LIB)
135 AROS_LIB := $(AROS_DEVELOPER)/$(AROS_DIR_LIB)
136 #AROS_LIB := $(AROS_SDK)/$(AROS_DIR_LIB)
138 AROS_CONTRIB_DEVELOPER := $(AROS_CONTRIB)/$(AROS_DIR_DEVELOPER)
139 AROS_CONTRIB_SDK := $(AROS_SDK)/$(AROS_DIR_CONTRIB)
140 AROS_CONTRIB_ARCH_INCLUDES := $(AROS_ARCH_SDK)/$(AROS_DIR_CONTRIB)/$(AROS_DIR_INCLUDE)
141 AROS_CONTRIB_INCLUDES := $(AROS_CONTRIB_SDK)/$(AROS_DIR_INCLUDE)
142 AROS_CONTRIB_ARCH_LIB := $(AROS_ARCH_SDK)/$(AROS_DIR_CONTRIB)/$(AROS_DIR_LIB)
143 AROS_CONTRIB_LIB := $(AROS_CONTRIB_SDK)/$(AROS_DIR_LIB)
145 # The generated files all go under the GENDIR path
146 SCRIPTDIR := $(GENDIR)/scripts
148 MKDEPEND := $(SRCDIR)/scripts/mkdep
149 FETCH := $(SRCDIR)/scripts/fetch.sh
150 CPYDIRREC := $(PYTHON) $(SRCDIR)/scripts/cpy-dir-rec.py
152 # The paths to the generated tools
153 TOOLDIR := $(HOSTDIR)/tools
154 TOOLLIB := $(TOOLDIR)/libtool.a
155 MMAKE := $(TOOLDIR)/mmake$(HOST_EXE_SUFFIX)
156 ARCHTOOL := $(TOOLDIR)/archtool$(HOST_EXE_SUFFIX)
157 GENMFSCRIPT := $(TOOLDIR)/genmf.py
158 GENMF := $(PYTHON) $(GENMFSCRIPT)
159 FLEXCAT := $(TOOLDIR)/flexcat$(HOST_EXE_SUFFIX)
160 FD2INLINE := $(TOOLDIR)/fd2inline$(HOST_EXE_SUFFIX)
161 FD2PRAGMA := $(TOOLDIR)/fd2pragma$(HOST_EXE_SUFFIX)
162 SFDC := $(TOOLDIR)/sfdc
163 MODTOOL := $(TOOLDIR)/modtool$(HOST_EXE_SUFFIX)
164 CREATEDTDESC := $(TOOLDIR)/createdtdesc$(HOST_EXE_SUFFIX)
165 AFSLIB := $(TOOLDIR)/libafs.a
166 COPYTOAFS := $(TOOLDIR)/copytoafs$(HOST_EXE_SUFFIX)
167 ILBMTOC := $(TOOLDIR)/ilbmtoc$(HOST_EXE_SUFFIX)
168 ILBMTOICON := $(TOOLDIR)/ilbmtoicon$(HOST_EXE_SUFFIX)
169 INFOINFO := $(TOOLDIR)/infoinfo$(HOST_EXE_SUFFIX)
170 GENSETS := $(TOOLDIR)/gensets$(HOST_EXE_SUFFIX)
171 COLLECT-AROS := $(TOOLDIR)/collect-aros$(HOST_EXE_SUFFIX)
172 GENMODULE := $(TOOLDIR)/genmodule$(HOST_EXE_SUFFIX)
173 SETREV := $(TOOLDIR)/setrev$(HOST_EXE_SUFFIX)
174 @make_extra_commands@
175 RESIDENT_BEGIN := compiler/libinit/libentry
176 KICKSTART_BEGIN := compiler/libinit/kickentry
178 AROS_CC := $(TARGET_CC)
179 ifneq ($(TARGET_CXX),)
180 AROS_CXX := $(TARGET_CXX)
182 AROS_CXX := $(CROSSTOOLSDIR)/$(AROS_TARGET_CPU)-aros-g++
184 AROS_CXXEXTS := cpp cxx cc c++
185 AROS_AS := $(TARGET_AS)
186 AROS_LD := $(TARGET_LD)
188 STRIP := $(TARGET_STRIP)
190 CALL := env AROS_HOST_ARCH=$(AROS_HOST_ARCH) AROS_HOST_CPU=$(AROS_HOST_CPU) \
191 AROS_TARGET_ARCH=$(AROS_TARGET_ARCH) AROS_TARGET_CPU=$(AROS_TARGET_CPU) AROS_TARGET_CPU_MODE=$(AROS_TARGET_CPU_MODE) \
192 AROS_TARGET_VARIANT=$(AROS_TARGET_VARIANT) AROS_TARGET_SUFFIX=$(AROS_TARGET_SUFFIX)
194 # At the moment we have two copies of the includes...
195 # This is the AROS includes, minus clib/mlib.
196 GENINCDIR := $(GENDIR)/include
198 # Special testing tools..
199 PARSEOFFSETS := $(TOOLDIR)/parseoffsets$(HOST_EXE_SUFFIX)
201 # Basic make configuration. No need to edit anything else under here.
204 .SUFFIXES : .c .h .d .s .S
206 .PHONY : all clean setup subdirs
208 BASE_CFLAGS := $(CONFIG_BASE_CFLAGS)
209 BASE_CXXFLAGS := $(CONFIG_BASE_CXXFLAGS)
210 BASE_CPPFLAGS := $(CONFIG_BASE_CPPFLAGS)
212 # Was debugging enabled? Better set up the options.
214 BASE_CFLAGS += $(DEBUG_CFLAGS)
215 BASE_CXXFLAGS += $(DEBUG_CXXFLAGS)
216 BASE_CPPFLAGS += $(DEBUG_CPPFLAGS)
217 CONFIG_CFLAGS += $(DEBUG_CFLAGS)
218 CONFIG_CXXFLAGS += $(DEBUG_CXXFLAGS)
219 CONFIG_CPPFLAGS += $(DEBUG_CPPFLAGS)
220 CONFIG_AFLAGS += $(DEBUG_AFLAGS)
221 CONFIG_LDFLAGS += $(DEBUG_LDFLAGS)
222 HOST_CFLAGS += $(DEBUG_CFLAGS)
223 HOST_CXXFLAGS += $(DEBUG_CXXFLAGS)
224 HOST_CPPFLAGS += $(DEBUG_CPPFLAGS)
225 HOST_AFLAGS += $(DEBUG_AFLAGS)
226 HOST_LDFLAGS += $(DEBUG_LDFLAGS)
232 # compiler and assembler flags are set depending upon the directory
233 CFLAGS = $(TARGET_ISA_CFLAGS) $(TARGET_CFLAGS)
234 CXXFLAGS = $(TARGET_ISA_CXXFLAGS) $(TARGET_CXXFLAGS)
235 CPPFLAGS = $(TARGET_CPPFLAGS)
236 AFLAGS = $(TARGET_ISA_AFLAGS) $(USER_AFLAGS) $(CONFIG_AFLAGS)
237 LDFLAGS = $(USER_LDFLAGS) $(TARGET_LDFLAGS)
239 # Target arch/CPU-specific options that we can't set in 'configure'
240 # (these could be added to CFLAGS instead of using a new variable, except
241 # that CFLAGS is unfortunately also passed to host and kernel compilers,
242 # which might not recognise the same options)
243 ifeq ($(AROS_TARGET_CPU),i386)
244 SAFETY_CFLAGS += $(CFLAGS_NO_IPA_CP)
246 ifeq ($(AROS_TARGET_CPU),m68k)
247 SAFETY_CFLAGS += $(CFLAGS_NO_IPA_CP)
251 # if LTO is desired use these flags ...
252 # NB: make.tmpl builds the objects individually
253 # so we don't include -fwhole-program for
254 # binaries by default.
255 LTO_CFLAGS = $(CFLAGS_LTO)
256 LTO_BINARY_CFLAGS = $(LTO_CFLAGS)
257 LTO_BINARYWHOLE_CFLAGS = $(LTO_BINARY_CFLAGS) $(CFLAGS_WHOLE_PROGRAM)
258 @make_extra_targetcfg@
259 # Compatibility with old variables
260 OBJDIR := $(GENDIR)/$(CURDIR)
261 LIBDIR := $(AROS_LIB)
262 OSGENDIR := $(GENDIR)/rom
263 KOBJSDIR := $(GENDIR)/kobjs
265 # the build system needs to have some tools in the PATH
267 ifeq ($(AROS_PATH_SET),)
268 TMP_TOOLDIR := $(shell echo $(TOOLDIR) | sed 's/^\(.\):\//\/\1\//')
269 TMP_CROSSTOOLSDIR := $(shell echo $(CROSSTOOLSDIR) | sed 's/^\(.\):\//\/\1\//')
270 PATH := $(TMP_CROSSTOOLSDIR):$(TMP_TOOLDIR):$(TMP_TOOLDIR)/$(AROS_TARGET_CPU)-$(AROS_TARGET_ARCH)$(AROS_TARGET_SUFFIX):$(PATH)
272 export PATH AROS_PATH_SET
275 # Here follow some global variables that can get values through the makefile
276 # and will be handled in make.tail
278 # Dirs to create a makedir rule for
281 # Source directory is added to the target search path
282 VPATH := $(shell echo $(SRCDIR)/$(CURDIR) | sed 's/^\(.\):\//\/\1\//')
284 # Macro for expanding wildcards in source directory
285 # We use shell script here in order to avoid Unicode file names that are listed by pattern expansion but can't be accessed
286 # because of failing Unicode->ACP conversion under Windows
287 WILDCARD = $(shell cd $(SRCDIR)/$(CURDIR); for file in $(1); do if [ -f $$file ]; then printf "%s" "$$file "; fi; done)
289 # Defined to quieten output..