1 # Copyright © 1995-2018, 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 HOSTDIR := $(TOP)/bin/$(AROS_HOST_ARCH)-$(AROS_HOST_CPU)
22 TOOLDIR := $(HOSTDIR)/tools
24 HOSTGENDIR := $(HOSTDIR)/gen/host
26 # All files corresponding to a specific target go here.
27 TARGETDIR := $(TOP)/bin/$(AROS_TARGET_ARCH)-$(AROS_TARGET_CPU)$(AROS_TARGET_SUFFIX)
29 GENDIR := $(TARGETDIR)/gen
31 CC_PREFIX := @aros_cc_pre@
33 -include $(GENDIR)/config/make.defaults
34 -include $(GENDIR)/config/make.opts
36 # target.cfg *must* come before host.cfg,
37 # and both must come before build.cfg
38 include $(GENDIR)/config/target.cfg
39 include $(HOSTGENDIR)/config/host.cfg
40 include $(GENDIR)/config/build.cfg
42 # Cross tools installation directory.
43 CROSSTOOLSDIR := @AROS_CROSSTOOLSDIR@
45 # Files downloaded from the net are put here
46 PORTSSOURCEDIR := @AROS_PORTSSRCDIR@
47 PORTSDIR := $(TARGETDIR)/Ports
49 # Distributable Files we generate are put here
50 DISTDIR := @AROS_BUILDDIR_UNIX@/distfiles
52 # File for AROS gcc cross compiler spec file
53 SPECS := $(GENDIR)/config/specs
55 # This is the directory structure for an AROS system.
56 AROSDIR := $(TARGETDIR)/AROS
58 # Relative paths for standard directories
60 ifeq ($(AROS_TARGET_ARCH),pc)
61 AROS_DIR_ARCH := boot/$(AROS_TARGET_ARCH)
63 AROS_DIR_ARCH := boot/$(AROS_TARGET_ARCH)$(AROS_TARGET_SUFFIX)
66 AROS_DIR_CLASSES := Classes
67 AROS_DIR_DATATYPES := $(AROS_DIR_CLASSES)/Datatypes
68 AROS_DIR_GADGETS := $(AROS_DIR_CLASSES)/Gadgets
70 AROS_DIR_EXPANSION := Expansion
72 AROS_DIR_LIBRARIES := Libs
73 AROS_DIR_LOCALE := Locale
75 AROS_DIR_TOOLS := Tools
77 AROS_DIR_DEVELOPER := Developer
78 AROS_DIR_INCLUDE := include
81 AROS_DIR_CONTRIB := Extras
83 # Absolute paths for standard directories
84 AROSARCHDIR := $(AROSDIR)/$(AROS_DIR_ARCH)
85 AROS_BOOT := $(AROSDIR)/$(AROS_DIR_BOOT)
86 AROS_C := $(AROSDIR)/$(AROS_DIR_C)
87 AROS_CLASSES := $(AROSDIR)/$(AROS_DIR_CLASSES)
88 AROS_CLASSES_ARCH := $(AROSDIR)/$(AROS_DIR_ARCH)/$(AROS_DIR_CLASSES)
89 AROS_DATATYPES := $(AROSDIR)/$(AROS_DIR_DATATYPES)
90 AROS_GADGETS := $(AROSDIR)/$(AROS_DIR_GADGETS)
91 AROS_DEVS := $(AROSDIR)/$(AROS_DIR_DEVS)
92 AROS_DEVS_ARCH := $(AROSDIR)/$(AROS_DIR_ARCH)/$(AROS_DIR_DEVS)
93 AROS_EXPANSION := $(AROSDIR)/$(AROS_DIR_EXPANSION)
94 AROS_FS := $(AROSDIR)/$(AROS_DIR_FS)
95 AROS_FS_ARCH := $(AROSDIR)/$(AROS_DIR_ARCH)/$(AROS_DIR_FS)
96 AROS_RESOURCES := $(AROS_DEVS)
97 AROS_DRIVERS := $(AROS_DEVS)/Drivers
98 AROS_LIBRARIES := $(AROSDIR)/$(AROS_DIR_LIBRARIES)
99 AROS_LIBRARIES_ARCH := $(AROSDIR)/$(AROS_DIR_ARCH)/$(AROS_DIR_LIBRARIES)
100 AROS_LOCALE := $(AROSDIR)/$(AROS_DIR_LOCALE)
101 AROS_CATALOGS := $(AROS_LOCALE)/Catalogs
102 AROS_HELP := $(AROS_LOCALE)/Help
103 AROS_PREFS := $(AROSDIR)/Prefs
104 AROS_ENVARC := $(AROS_PREFS)/Env-Archive
105 AROS_PACKAGES := $(AROS_ENVARC)/SYS/Packages
106 AROS_PRINTERS := $(AROS_DEVS)/Printers
107 AROS_S := $(AROSDIR)/$(AROS_DIR_S)
108 AROS_SYSTEM := $(AROSDIR)/System
109 AROS_WANDERER := $(AROS_SYSTEM)/Wanderer
110 AROS_THEMES := $(AROS_PREFS)/Presets/Themes
111 AROS_IMAGES := $(AROS_SYSTEM)/Images
112 AROS_TOOLS := $(AROSDIR)/$(AROS_DIR_TOOLS)
113 AROS_UTILITIES := $(AROSDIR)/Utilities
115 AROS_DEVELOPER := $(AROSDIR)/$(AROS_DIR_DEVELOPER)
116 AROS_DEBUG := $(AROS_DEVELOPER)/Debug
117 AROS_TESTS := $(AROS_DEBUG)/Tests
118 AROS_INCLUDES := $(AROS_DEVELOPER)/$(AROS_DIR_INCLUDE)
119 AROS_LIB := $(AROS_DEVELOPER)/$(AROS_DIR_LIB)
121 AROS_CONTRIB := $(AROSDIR)/$(AROS_DIR_CONTRIB)
122 AROS_CONTRIB_DEVELOPER := $(AROS_CONTRIB)/$(AROS_DIR_DEVELOPER)
123 AROS_CONTRIB_INCLUDES := $(AROS_CONTRIB_DEVELOPER)/$(AROS_DIR_INCLUDE)
124 AROS_CONTRIB_LIB := $(AROS_CONTRIB_DEVELOPER)/$(AROS_DIR_LIB)
126 # The generated files all go under the GENDIR path
127 SCRIPTDIR := $(GENDIR)/scripts
129 MKDEPEND := $(SRCDIR)/scripts/mkdep
130 FETCH := $(SRCDIR)/scripts/fetch.sh
131 CPYDIRREC := @PYTHON@ $(SRCDIR)/scripts/cpy-dir-rec.py
133 # The paths to the generated tools
134 TOOLDIR := $(HOSTDIR)/tools
135 TOOLLIB := $(TOOLDIR)/libtool.a
136 MMAKE := $(TOOLDIR)/mmake$(HOST_EXE_SUFFIX)
137 ARCHTOOL := $(TOOLDIR)/archtool$(HOST_EXE_SUFFIX)
138 ELF2HUNK := $(TOOLDIR)/elf2hunk$(HOST_EXE_SUFFIX)
139 GENMF := $(TOOLDIR)/genmf.py
140 FLEXCAT := $(TOOLDIR)/flexcat$(HOST_EXE_SUFFIX)
141 FD2INLINE := $(TOOLDIR)/fd2inline$(HOST_EXE_SUFFIX)
142 FD2PRAGMA := $(TOOLDIR)/fd2pragma$(HOST_EXE_SUFFIX)
143 SFDC := $(TOOLDIR)/sfdc
144 MODTOOL := $(TOOLDIR)/modtool$(HOST_EXE_SUFFIX)
145 CREATEDTDESC := $(TOOLDIR)/createdtdesc$(HOST_EXE_SUFFIX)
146 AFSLIB := $(TOOLDIR)/libafs.a
147 COPYTOAFS := $(TOOLDIR)/copytoafs$(HOST_EXE_SUFFIX)
148 ILBMTOC := $(TOOLDIR)/ilbmtoc$(HOST_EXE_SUFFIX)
149 ILBMTOICON := $(TOOLDIR)/ilbmtoicon$(HOST_EXE_SUFFIX)
150 INFOINFO := $(TOOLDIR)/infoinfo$(HOST_EXE_SUFFIX)
151 GENSETS := $(TOOLDIR)/gensets$(HOST_EXE_SUFFIX)
152 COLLECT-AROS := $(TOOLDIR)/collect-aros$(HOST_EXE_SUFFIX)
153 GENMODULE := $(TOOLDIR)/genmodule$(HOST_EXE_SUFFIX)
154 SETREV := $(TOOLDIR)/setrev$(HOST_EXE_SUFFIX)
156 RESIDENT_BEGIN := compiler/libinit/libentry
157 KICKSTART_BEGIN := compiler/libinit/kickentry
159 AROS_CC := $(TARGET_CC)
160 ifneq ($(TARGET_CXX),)
161 AROS_CXX := $(TARGET_CXX)
163 AROS_CXX := $(CROSSTOOLSDIR)/$(AROS_TARGET_CPU)-aros-g++
165 AROS_CXXEXTS := cpp cxx cc c++
166 AROS_AS := $(TARGET_AS)
167 AROS_LD := $(TARGET_LD)
169 STRIP := $(TARGET_STRIP)
171 CALL := env AROS_HOST_ARCH=$(AROS_HOST_ARCH) AROS_HOST_CPU=$(AROS_HOST_CPU) \
172 AROS_TARGET_ARCH=$(AROS_TARGET_ARCH) AROS_TARGET_CPU=$(AROS_TARGET_CPU) AROS_TARGET_CPU_MODE=$(AROS_TARGET_CPU_MODE) \
173 AROS_TARGET_VARIANT=$(AROS_TARGET_VARIANT) AROS_TARGET_SUFFIX=$(AROS_TARGET_SUFFIX)
175 # At the moment we have two copies of the includes...
176 # This is the AROS includes, minus clib/mlib.
177 GENINCDIR := $(GENDIR)/include
179 # Basic make configuration. No need to edit anything else under here.
182 .SUFFIXES : .c .h .d .s .S
184 .PHONY : all clean setup subdirs
186 BASE_CFLAGS := $(CONFIG_BASE_CFLAGS)
187 BASE_CXXFLAGS := $(CONFIG_BASE_CXXFLAGS)
188 BASE_CPPFLAGS := $(CONFIG_BASE_CPPFLAGS)
190 # Was debugging enabled? Better set up the options.
192 BASE_CFLAGS += $(DEBUG_CFLAGS)
193 BASE_CXXFLAGS += $(DEBUG_CXXFLAGS)
194 BASE_CPPFLAGS += $(DEBUG_CPPFLAGS)
195 CONFIG_CFLAGS += $(DEBUG_CFLAGS)
196 CONFIG_CXXFLAGS += $(DEBUG_CXXFLAGS)
197 CONFIG_CPPFLAGS += $(DEBUG_CPPFLAGS)
198 CONFIG_AFLAGS += $(DEBUG_AFLAGS)
199 CONFIG_LDFLAGS += $(DEBUG_LDFLAGS)
200 HOST_CFLAGS += $(DEBUG_CFLAGS)
201 HOST_CXXFLAGS += $(DEBUG_CXXFLAGS)
202 HOST_CPPFLAGS += $(DEBUG_CPPFLAGS)
203 HOST_AFLAGS += $(DEBUG_AFLAGS)
204 HOST_LDFLAGS += $(DEBUG_LDFLAGS)
210 # compiler and assembler flags are set depending upon the directory
211 CFLAGS = $(ISA_FLAGS) $(TARGET_CFLAGS)
212 CXXFLAGS = $(ISA_FLAGS) $(TARGET_CXXFLAGS)
213 CPPFLAGS = $(TARGET_CPPFLAGS)
214 AFLAGS = $(ISA_FLAGS) $(USER_AFLAGS) $(CONFIG_AFLAGS)
215 LDFLAGS = $(USER_LDFLAGS) $(CONFIG_LDFLAGS)
217 # Target arch/CPU-specific options that we can't set in 'configure'
218 # (these could be added to CFLAGS instead of using a new variable, except
219 # that CFLAGS is unfortunately also passed to host and kernel compilers,
220 # which might not recognise the same options)
221 ifeq ($(AROS_TARGET_CPU),i386)
222 SAFETY_CFLAGS = $(CFLAGS_NO_IPA_CP)
224 ifeq ($(AROS_TARGET_CPU),m68k)
225 SAFETY_CFLAGS += $(CFLAGS_NO_IPA_CP)
228 # if LTO is desired use these flags ...
229 # NB: make.tmpl builds the objects individually
230 # so we don't include -fwhole-program for
231 # binaries by default.
232 LTO_CFLAGS = $(CFLAGS_LTO)
233 LTO_BINARY_CFLAGS = $(LTO_CFLAGS)
234 LTO_BINARYWHOLE_CFLAGS = $(LTO_BINARY_CFLAGS) $(CFLAGS_WHOLE_PROGRAM)
236 # Apple iOS stuff for gcc
237 IOS_LDFLAGS := -F$(IOS_SDK_PATH)/System/Library/Frameworks
239 # Compatibility with old variables
240 OBJDIR := $(GENDIR)/$(CURDIR)
241 LIBDIR := $(AROS_LIB)
242 OSGENDIR := $(GENDIR)/rom
243 KOBJSDIR := $(GENDIR)/kobjs
245 # the build system needs to have some tools in the PATH
247 ifeq ($(AROS_PATH_SET),)
248 TMP_TOOLDIR := $(shell echo $(TOOLDIR) | sed 's/^\(.\):\//\/\1\//')
249 TMP_CROSSTOOLSDIR := $(shell echo $(CROSSTOOLSDIR) | sed 's/^\(.\):\//\/\1\//')
250 PATH := $(TMP_CROSSTOOLSDIR):$(TMP_TOOLDIR):$(TMP_TOOLDIR)/$(AROS_TARGET_CPU)-$(AROS_TARGET_ARCH)$(AROS_TARGET_SUFFIX):$(PATH)
252 export PATH AROS_PATH_SET
255 # Here follow some global variables that can get values through the makefile
256 # and will be handled in make.tail
258 # Dirs to create a makedir rule for
261 # Source directory is added to the target search path
262 VPATH := $(shell echo $(SRCDIR)/$(CURDIR) | sed 's/^\(.\):\//\/\1\//')
264 # Macro for expanding wildcards in source directory
265 # We use shell script here in order to avoid Unicode file names that are listed by pattern expansion but can't be accessed
266 # because of failing Unicode->ACP conversion under Windows
267 WILDCARD = $(shell cd $(SRCDIR)/$(CURDIR); for file in $(1); do if [ -f $$file ]; then printf "%s" "$$file "; fi; done)