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
80 AROS_DIR_INCLUDE := include
83 AROS_DIR_CONTRIB := Extras
85 # Absolute paths for standard directories
86 AROSARCHDIR := $(AROSDIR)/$(AROS_DIR_ARCH)
87 AROS_BOOT := $(AROSDIR)/$(AROS_DIR_BOOT)
88 AROS_C := $(AROSDIR)/$(AROS_DIR_C)
89 AROS_CLASSES := $(AROSDIR)/$(AROS_DIR_CLASSES)
90 AROS_CLASSES_ARCH := $(AROSDIR)/$(AROS_DIR_ARCH)/$(AROS_DIR_CLASSES)
91 AROS_DATATYPES := $(AROSDIR)/$(AROS_DIR_DATATYPES)
92 AROS_GADGETS := $(AROSDIR)/$(AROS_DIR_GADGETS)
93 AROS_DEVS := $(AROSDIR)/$(AROS_DIR_DEVS)
94 AROS_DEVS_ARCH := $(AROSDIR)/$(AROS_DIR_ARCH)/$(AROS_DIR_DEVS)
95 AROS_EXPANSION := $(AROSDIR)/$(AROS_DIR_EXPANSION)
96 AROS_FS := $(AROSDIR)/$(AROS_DIR_FS)
97 AROS_FS_ARCH := $(AROSDIR)/$(AROS_DIR_ARCH)/$(AROS_DIR_FS)
98 AROS_RESOURCES := $(AROS_DEVS)
99 AROS_DRIVERS := $(AROS_DEVS)/Drivers
100 AROS_LIBRARIES := $(AROSDIR)/$(AROS_DIR_LIBRARIES)
101 AROS_LIBRARIES_ARCH := $(AROSDIR)/$(AROS_DIR_ARCH)/$(AROS_DIR_LIBRARIES)
102 AROS_LOCALE := $(AROSDIR)/$(AROS_DIR_LOCALE)
103 AROS_CATALOGS := $(AROS_LOCALE)/Catalogs
104 AROS_HELP := $(AROS_LOCALE)/Help
105 AROS_PREFS := $(AROSDIR)/Prefs
106 AROS_ENVARC := $(AROS_PREFS)/Env-Archive
107 AROS_PACKAGES := $(AROS_ENVARC)/SYS/Packages
108 AROS_PRINTERS := $(AROS_DEVS)/Printers
109 AROS_S := $(AROSDIR)/$(AROS_DIR_S)
110 AROS_SYSTEM := $(AROSDIR)/System
111 AROS_WANDERER := $(AROS_SYSTEM)/Wanderer
112 AROS_THEMES := $(AROS_PREFS)/Presets/Themes
113 AROS_IMAGES := $(AROS_SYSTEM)/Images
114 AROS_TOOLS := $(AROSDIR)/$(AROS_DIR_TOOLS)
115 AROS_UTILITIES := $(AROSDIR)/Utilities
117 AROS_DEVELOPER := $(AROSDIR)/$(AROS_DIR_DEVELOPER)
118 AROS_DEBUG := $(AROS_DEVELOPER)/Debug
119 AROS_TESTS := $(AROS_DEBUG)/Tests
120 AROS_INCLUDES := $(AROS_DEVELOPER)/$(AROS_DIR_INCLUDE)
121 AROS_LIB := $(AROS_DEVELOPER)/$(AROS_DIR_LIB)
123 AROS_CONTRIB := $(AROSDIR)/$(AROS_DIR_CONTRIB)
124 AROS_CONTRIB_DEVELOPER := $(AROS_CONTRIB)/$(AROS_DIR_DEVELOPER)
125 AROS_CONTRIB_INCLUDES := $(AROS_CONTRIB_DEVELOPER)/$(AROS_DIR_INCLUDE)
126 AROS_CONTRIB_LIB := $(AROS_CONTRIB_DEVELOPER)/$(AROS_DIR_LIB)
128 # The generated files all go under the GENDIR path
129 SCRIPTDIR := $(GENDIR)/scripts
131 MKDEPEND := $(SRCDIR)/scripts/mkdep
132 FETCH := $(SRCDIR)/scripts/fetch.sh
133 CPYDIRREC := $(PYTHON) $(SRCDIR)/scripts/cpy-dir-rec.py
135 # The paths to the generated tools
136 TOOLDIR := $(HOSTDIR)/tools
137 TOOLLIB := $(TOOLDIR)/libtool.a
138 MMAKE := $(TOOLDIR)/mmake$(HOST_EXE_SUFFIX)
139 ARCHTOOL := $(TOOLDIR)/archtool$(HOST_EXE_SUFFIX)
140 ELF2HUNK := $(TOOLDIR)/elf2hunk$(HOST_EXE_SUFFIX)
141 GENMFSCRIPT := $(TOOLDIR)/genmf.py
142 GENMF := $(PYTHON) $(GENMFSCRIPT)
143 FLEXCAT := $(TOOLDIR)/flexcat$(HOST_EXE_SUFFIX)
144 FD2INLINE := $(TOOLDIR)/fd2inline$(HOST_EXE_SUFFIX)
145 FD2PRAGMA := $(TOOLDIR)/fd2pragma$(HOST_EXE_SUFFIX)
146 SFDC := $(TOOLDIR)/sfdc
147 MODTOOL := $(TOOLDIR)/modtool$(HOST_EXE_SUFFIX)
148 CREATEDTDESC := $(TOOLDIR)/createdtdesc$(HOST_EXE_SUFFIX)
149 AFSLIB := $(TOOLDIR)/libafs.a
150 COPYTOAFS := $(TOOLDIR)/copytoafs$(HOST_EXE_SUFFIX)
151 ILBMTOC := $(TOOLDIR)/ilbmtoc$(HOST_EXE_SUFFIX)
152 ILBMTOICON := $(TOOLDIR)/ilbmtoicon$(HOST_EXE_SUFFIX)
153 INFOINFO := $(TOOLDIR)/infoinfo$(HOST_EXE_SUFFIX)
154 GENSETS := $(TOOLDIR)/gensets$(HOST_EXE_SUFFIX)
155 COLLECT-AROS := $(TOOLDIR)/collect-aros$(HOST_EXE_SUFFIX)
156 GENMODULE := $(TOOLDIR)/genmodule$(HOST_EXE_SUFFIX)
157 SETREV := $(TOOLDIR)/setrev$(HOST_EXE_SUFFIX)
159 RESIDENT_BEGIN := compiler/libinit/libentry
160 KICKSTART_BEGIN := compiler/libinit/kickentry
162 AROS_CC := $(TARGET_CC)
163 ifneq ($(TARGET_CXX),)
164 AROS_CXX := $(TARGET_CXX)
166 AROS_CXX := $(CROSSTOOLSDIR)/$(AROS_TARGET_CPU)-aros-g++
168 AROS_CXXEXTS := cpp cxx cc c++
169 AROS_AS := $(TARGET_AS)
170 AROS_LD := $(TARGET_LD)
172 STRIP := $(TARGET_STRIP)
174 CALL := env AROS_HOST_ARCH=$(AROS_HOST_ARCH) AROS_HOST_CPU=$(AROS_HOST_CPU) \
175 AROS_TARGET_ARCH=$(AROS_TARGET_ARCH) AROS_TARGET_CPU=$(AROS_TARGET_CPU) AROS_TARGET_CPU_MODE=$(AROS_TARGET_CPU_MODE) \
176 AROS_TARGET_VARIANT=$(AROS_TARGET_VARIANT) AROS_TARGET_SUFFIX=$(AROS_TARGET_SUFFIX)
178 # At the moment we have two copies of the includes...
179 # This is the AROS includes, minus clib/mlib.
180 GENINCDIR := $(GENDIR)/include
182 # Basic make configuration. No need to edit anything else under here.
185 .SUFFIXES : .c .h .d .s .S
187 .PHONY : all clean setup subdirs
189 BASE_CFLAGS := $(CONFIG_BASE_CFLAGS)
190 BASE_CXXFLAGS := $(CONFIG_BASE_CXXFLAGS)
191 BASE_CPPFLAGS := $(CONFIG_BASE_CPPFLAGS)
193 # Was debugging enabled? Better set up the options.
195 BASE_CFLAGS += $(DEBUG_CFLAGS)
196 BASE_CXXFLAGS += $(DEBUG_CXXFLAGS)
197 BASE_CPPFLAGS += $(DEBUG_CPPFLAGS)
198 CONFIG_CFLAGS += $(DEBUG_CFLAGS)
199 CONFIG_CXXFLAGS += $(DEBUG_CXXFLAGS)
200 CONFIG_CPPFLAGS += $(DEBUG_CPPFLAGS)
201 CONFIG_AFLAGS += $(DEBUG_AFLAGS)
202 CONFIG_LDFLAGS += $(DEBUG_LDFLAGS)
203 HOST_CFLAGS += $(DEBUG_CFLAGS)
204 HOST_CXXFLAGS += $(DEBUG_CXXFLAGS)
205 HOST_CPPFLAGS += $(DEBUG_CPPFLAGS)
206 HOST_AFLAGS += $(DEBUG_AFLAGS)
207 HOST_LDFLAGS += $(DEBUG_LDFLAGS)
213 # compiler and assembler flags are set depending upon the directory
214 CFLAGS = $(TARGET_ISA_CFLAGS) $(TARGET_CFLAGS)
215 CXXFLAGS = $(TARGET_ISA_CXXFLAGS) $(TARGET_CXXFLAGS)
216 CPPFLAGS = $(TARGET_CPPFLAGS)
217 AFLAGS = $(TARGET_ISA_AFLAGS) $(USER_AFLAGS) $(CONFIG_AFLAGS)
218 LDFLAGS = $(USER_LDFLAGS) $(TARGET_LDFLAGS)
220 # Target arch/CPU-specific options that we can't set in 'configure'
221 # (these could be added to CFLAGS instead of using a new variable, except
222 # that CFLAGS is unfortunately also passed to host and kernel compilers,
223 # which might not recognise the same options)
224 ifeq ($(AROS_TARGET_CPU),i386)
225 SAFETY_CFLAGS = $(CFLAGS_NO_IPA_CP)
227 ifeq ($(AROS_TARGET_CPU),m68k)
228 SAFETY_CFLAGS += $(CFLAGS_NO_IPA_CP)
231 # if LTO is desired use these flags ...
232 # NB: make.tmpl builds the objects individually
233 # so we don't include -fwhole-program for
234 # binaries by default.
235 LTO_CFLAGS = $(CFLAGS_LTO)
236 LTO_BINARY_CFLAGS = $(LTO_CFLAGS)
237 LTO_BINARYWHOLE_CFLAGS = $(LTO_BINARY_CFLAGS) $(CFLAGS_WHOLE_PROGRAM)
239 # Apple iOS stuff for gcc
240 IOS_LDFLAGS := -F$(IOS_SDK_PATH)/System/Library/Frameworks
242 # Compatibility with old variables
243 OBJDIR := $(GENDIR)/$(CURDIR)
244 LIBDIR := $(AROS_LIB)
245 OSGENDIR := $(GENDIR)/rom
246 KOBJSDIR := $(GENDIR)/kobjs
248 # the build system needs to have some tools in the PATH
250 ifeq ($(AROS_PATH_SET),)
251 TMP_TOOLDIR := $(shell echo $(TOOLDIR) | sed 's/^\(.\):\//\/\1\//')
252 TMP_CROSSTOOLSDIR := $(shell echo $(CROSSTOOLSDIR) | sed 's/^\(.\):\//\/\1\//')
253 PATH := $(TMP_CROSSTOOLSDIR):$(TMP_TOOLDIR):$(TMP_TOOLDIR)/$(AROS_TARGET_CPU)-$(AROS_TARGET_ARCH)$(AROS_TARGET_SUFFIX):$(PATH)
255 export PATH AROS_PATH_SET
258 # Here follow some global variables that can get values through the makefile
259 # and will be handled in make.tail
261 # Dirs to create a makedir rule for
264 # Source directory is added to the target search path
265 VPATH := $(shell echo $(SRCDIR)/$(CURDIR) | sed 's/^\(.\):\//\/\1\//')
267 # Macro for expanding wildcards in source directory
268 # We use shell script here in order to avoid Unicode file names that are listed by pattern expansion but can't be accessed
269 # because of failing Unicode->ACP conversion under Windows
270 WILDCARD = $(shell cd $(SRCDIR)/$(CURDIR); for file in $(1); do if [ -f $$file ]; then printf "%s" "$$file "; fi; done)