2 # Rules to create AROS Kernel for amiga-m68k
5 include $(SRCDIR)/config/aros.cfg
9 #MM- kernel-link-amiga-m68k : \
10 #MM general-setup-amiga-m68k \
13 #MM kernel-alerthook-kobj \
14 #MM kernel-amiga-m68k-amigavideo-kobj \
15 #MM kernel-amiga-m68k-audio-kobj \
16 #MM kernel-amiga-m68k-cd-kobj \
17 #MM kernel-amiga-m68k-devs \
18 #MM kernel-amiga-m68k-kbd-kobj \
19 #MM kernel-amiga-m68k-mouse-kobj \
20 #MM kernel-amiga-m68k-uaegfx-kobj \
21 #MM kernel-amiga-m68k-wbtag-kobj \
22 #MM kernel-aros-kobj \
23 #MM kernel-hidd-bus-kobj \
24 #MM kernel-hidd-base-kobj \
26 #MM kernel-audio-kobj \
27 #MM kernel-battclock-kobj \
28 #MM kernel-bootloader-amiga-m68k-kobj \
29 #MM kernel-bootloader-kobj \
30 #MM kernel-cardres-kobj \
32 #MM kernel-console-kobj \
33 #MM kernel-debug-kobj \
34 #MM kernel-diag-kobj \
35 #MM kernel-disk-kobj \
37 #MM kernel-dosboot-kobj \
38 #MM kernel-expansion-kobj \
39 #MM kernel-filesystem-kobj \
40 #MM kernel-freeanim-kobj \
41 #MM kernel-fs-afs-kobj \
42 #MM kernel-fs-cdfs-kobj \
43 #MM kernel-fs-con-kobj \
44 #MM kernel-fs-ram-kobj \
45 #MM kernel-gameport-kobj \
46 #MM kernel-graphics-kobj \
47 #MM kernel-hidd-kobj \
48 #MM kernel-hidd-gayleata-kobj \
49 #MM kernel-hidd-gfx-kobj \
50 #MM kernel-hidd-kbd-kobj \
51 #MM kernel-hidd-mouse-kobj \
52 #MM kernel-hidd-amigakbd-kobj \
53 #MM kernel-hidd-amigamouse-kobj \
54 #MM kernel-hidd-amigavideo-kobj \
55 #MM kernel-hidd-uaegfx-kobj \
56 #MM kernel-hidd-ata_gayle-kobj \
57 #MM kernel-intuition-kobj \
58 #MM kernel-input-kobj \
59 #MM kernel-keymap-kobj \
60 #MM kernel-keyboard-kobj \
61 #MM kernel-layers-kobj \
62 #MM kernel-lddemon-kobj \
63 #MM kernel-m680x0-kobj \
64 #MM kernel-misc-kobj \
66 #MM kernel-partition-kobj \
67 #MM kernel-processor-kobj \
68 #MM kernel-task-kobj \
69 #MM kernel-potgo-kobj \
70 #MM kernel-romboot-kobj \
71 #MM kernel-setpatch-kobj \
72 #MM kernel-shell-kobj \
73 #MM kernel-shellcommands-kobj \
74 #MM kernel-timer-kobj \
75 #MM kernel-trackdisk-kobj \
76 #MM kernel-utility-kobj \
77 #MM kernel-usb-amiga-m68k \
78 #MM kernel-workbook-kobj \
79 #MM kernel-workbench-devs-amiga-m68k \
80 #MM workbench-libs-gadtools-kobj \
81 #MM workbench-libs-icon-kobj \
82 #MM workbench-libs-lowlevel-kobj \
83 #MM workbench-libs-mathffp-kobj \
84 #MM workbench-libs-mathieeesingbas-kobj \
85 #MM workbench-libs-nonvolatile-kobj \
86 #MM workbench-libs-nvdisk-kobj \
87 #MM workbench-libs-workbench-kobj \
88 #MM linklibs-loadseg \
93 #MM- kernel-workbench-devs-amiga-m68k : workbench-devs-amiga-m68k
95 # Make sure we optimize this code for size ..
96 OPTIMIZATION_CFLAGS := -Os
98 USELIBS := amiga arossupport autoinit libinit stdc.static
99 LIBS := -L$(GENDIR)/lib -lloadseg $(addprefix -l,$(USELIBS))
100 DEPLIBS := $(addprefix $(AROS_LIB)/lib,$(addsuffix .a,$(USELIBS)))
102 # Force rebuilding, so that we always get new date strings
107 # Use -m68060 when compiling .S files, as we will need the
108 # expanded instruction set to detect alternate CPUs
109 USER_CPPFLAGS := -DADATE="\"$(shell date "+%d.%m.%Y")\""
110 TARGET_ISA_AFLAGS := $(ISA_MC68060_FLAGS)
112 # Sadly, we need to consume Chip RAM for the initial SS and the ROM BSS.
113 # The initial System Stack is located at the end of the first 256K
114 # of CHIP RAM, but is only used until RTF_COLDSTART.
116 # Right before RTF_COLDSTART, a new SS will be allocated from the fastest
117 # available RAM, and this initial area will be ignored.
118 ROMLOC_ss := 0x003f800
120 # Main ROM (0xf80000 - 0xffffff)
121 ROMLOC_rom := 0x0f80000
123 FILES=start early debug mmu
124 AFILES=rom_entry rom_init cpu_detect superstack_swap
126 KLIBS := exec aros dos utility oop expansion partition debug
127 KDEVS := timer input keyboard console trackdisk gameport audio
128 KHNDLRS := con afs ram
129 KHIDDS := amigakbd amigamouse amigavideo ata_gayle gfx hiddclass keyboard mouse uaegfx
130 KRSRCS := battclock kernel processor task lddemon dosboot cia potgo disk FileSystem misc shell card bootloader
131 KHOOKS := diag romboot
133 KOBJS_rom := $(addprefix $(KOBJSDIR)/,$(addsuffix _library.ko ,$(KLIBS))) \
134 $(addprefix $(KOBJSDIR)/,$(addsuffix _device.ko ,$(KDEVS))) \
135 $(addprefix $(KOBJSDIR)/,$(addsuffix _handler.ko ,$(KHNDLRS))) \
136 $(addprefix $(KOBJSDIR)/,$(addsuffix _hidd.ko ,$(KHIDDS))) \
137 $(addprefix $(KOBJSDIR)/,$(addsuffix _resource.ko,$(KRSRCS))) \
138 $(addprefix $(KOBJSDIR)/,$(addsuffix _driver.ko ,$(KDRVRS) )) \
139 $(addprefix $(KOBJSDIR)/,$(addsuffix _hook.ko ,$(KHOOKS) ))
141 OBJS_rom := $(addprefix $(KOBJSDIR)/,$(addsuffix .o,$(AFILES))) \
142 $(addprefix $(KOBJSDIR)/,$(addsuffix .o,$(FILES)))
143 $(DISTDIR)/aros-amiga-m68k-rom.elf: $(KOBJS_rom) $(OBJS_rom)
145 # Expansion ROM (0xe00000-0xe7ffff)
149 KLIBS := keymap graphics layers intuition gadtools icon workbench \
150 mathffp mathieeesingbas freeanim lowlevel nonvolatile nvdisk \
154 KHIDDS := bus storage system
155 KRSRCS := shellcommands workbook wbtag
158 ROMLOC_ext := 0xe00000
160 $(addprefix $(KOBJSDIR)/,$(addsuffix _library.ko ,$(KLIBS) )) \
161 $(addprefix $(KOBJSDIR)/,$(addsuffix _device.ko ,$(KDEVS) )) \
162 $(addprefix $(KOBJSDIR)/,$(addsuffix _handler.ko ,$(KHNDLRS))) \
163 $(addprefix $(KOBJSDIR)/,$(addsuffix _hidd.ko ,$(KHIDDS) )) \
164 $(addprefix $(KOBJSDIR)/,$(addsuffix _resource.ko,$(KRSRCS) )) \
165 $(addprefix $(KOBJSDIR)/,$(addsuffix _driver.ko ,$(KDRVRS) )) \
166 $(addprefix $(KOBJSDIR)/,$(addsuffix _hook.ko ,$(KHOOKS) ))
167 OBJS_ext := $(addprefix $(KOBJSDIR)/,$(addsuffix .o,$(AFILES))) \
168 $(addprefix $(KOBJSDIR)/,$(addsuffix .o,$(FILES)))
169 $(DISTDIR)/aros-amiga-m68k-ext.elf: $(KOBJS_ext) $(OBJS_ext)
171 #MM kernel-link-amiga-m68k:
172 kernel-link-amiga-m68k : $(DISTDIR)/aros-amiga-m68k-rom.bin $(DISTDIR)/aros-amiga-m68k-ext.bin
174 #MM kernel-link-amiga-m68k-quick:
175 kernel-link-amiga-m68k-quick : $(DISTDIR)/aros-amiga-m68k-rom.bin $(DISTDIR)/aros-amiga-m68k-ext.bin
177 $(HOSTGENDIR)/tools/romcheck: romcheck.c
178 $(Q)$(HOST_CC) $(DEBUG_CFLAGS) -o $@ $<
180 $(GENDIR)/%_objs.ld: $(SRCDIR)/$(CURDIR)/mmakefile.src
182 $(Q)for file in $(OBJS_$*) $(KOBJS_$*); do \
183 echo "$$file(.rodata .rodata.*)" >>$@; \
184 echo "$$file(.text)" >>$@; \
187 $(DISTDIR)/aros-amiga-m68k-reloc.elf : $(DEPLIBS) $(SRCDIR)/$(CURDIR)/mmakefile.src \
188 $(OBJS_rom) $(KOBJS_rom) \
189 $(OBJS_ext) $(KOBJS_ext) \
190 $(SRCDIR)/$(CURDIR)/aros-rom.ld \
191 $(GENDIR)/rom_objs.ld \
192 $(GENDIR)/ext_objs.ld
194 @$(ECHO) Linking $@...
195 $(Q)$(KERNEL_CC) -Wl,-r \
196 -static -nostartfiles -nostdlib \
197 -Wl,--defsym -Wl,start=0x0 \
198 -Wl,--defsym -Wl,SysBase=0x4 \
199 -Wl,--defsym -Wl,AbsExecBase=0x4 \
201 -o $@ -Wl,-T -Wl,$(SRCDIR)/$(CURDIR)/aros-rom.ld \
202 -L$(AROS_LIB) $(LIBS) -lgcc
204 $(DISTDIR)/aros-amiga-m68k.elf: $(DISTDIR)/aros-amiga-m68k-reloc.elf
205 $(Q)$(KERNEL_LD) -o $@ \
206 --section-start .rom=$(ROMLOC_rom) \
207 --section-start .ext=$(ROMLOC_ext) \
208 --section-start .ss=$(ROMLOC_ss) \
210 $(Q)$(TARGET_OBJDUMP) -h $@ | grep '[rea][oxm][mte] '
212 $(DISTDIR)/aros-amiga-m68k-%.bin : $(DISTDIR)/aros-amiga-m68k.elf $(HOSTGENDIR)/tools/romcheck
213 $(Q)$(TARGET_OBJCOPY) \
214 --output-target binary \
217 $(DISTDIR)/aros-amiga-m68k.elf $@
219 $(Q)$(HOSTGENDIR)/tools/romcheck $@
220 $(Q)$(MKDIR) $(AROSARCHDIR)
221 $(Q)$(CP) $@ $(AROSARCHDIR)/aros-$*.bin
227 USER_INCLUDES += $(PRIV_KERNEL_INCLUDES) $(PRIV_EXEC_INCLUDES)
228 USER_CFLAGS += -fno-delete-null-pointer-checks
230 $(KOBJSDIR)/%.o : %.c
231 %compile_q cmd="$(KERNEL_CC)" opt="$(strip $(CFLAGS) $(CPPFLAGS) -I$(AROS_DEVELOPER)/include -I$(GENINCDIR))"
233 $(KOBJSDIR)/%.o : %.S
234 %compile_q cmd="$(KERNEL_CC)" opt="$(strip $(AFLAGS) $(TARGET_CFLAGS) $(CPPFLAGS) -I$(AROS_DEVELOPER)/include -I$(GENINCDIR))"
236 $(KOBJSDIR)/%.d : %.c
239 # Localize symbols, so that we don't get name clashes when linking
241 # .. except for exec.library. Our boot code needs symbols from it
242 # (PrepareMoveExecBase, InitKickTags, etc)
243 %/exec_library.ko: %/exec_library.o
246 # .. except for kernel.resource. Our boot code needs symbols from it
247 # (krnPrepareExecBase and krnCreateMemHeader)
248 %/kernel_resource.ko: %/kernel_resource.o
251 # .. except for expansion.library. Our boot code needs symbols from it
253 %/expansion_library.ko: %/expansion_library.o
256 # Localize symbols for everybody else though!
258 $(Q)$(NM_PLAIN) --defined-only $< | cut -d' ' -f3 >$@.sym
259 $(Q)$(OBJCOPY) --localize-symbols $@.sym $< $@
261 DEPS := $(foreach f, $(FILES), $(TARGETDIR)/$(f).d)
264 ###########################################################################
266 ## Compressed elf for AROSBootstrap
268 #MM- kernel-link-amiga-m68k: kernel-boot-elf
269 #MM- kernel-link-amiga-m68k-quick: kernel-boot-elf-quick
272 #MM kernel-boot-elf-quick:
273 kernel-boot-elf: $(AROSARCHDIR)/aros.elf $(AROSARCHDIR)/aros.elf.dbg
274 kernel-boot-elf-quick: $(AROSARCHDIR)/aros.elf $(AROSARCHDIR)/aros.elf.dbg
276 # Main ROM, that must live in MEMF_LOCAL memory
281 KLIBS := exec expansion
288 KOBJS_local := $(addprefix $(KOBJSDIR)/,$(addsuffix _library.ko ,$(KLIBS))) \
289 $(addprefix $(KOBJSDIR)/,$(addsuffix _device.ko ,$(KDEVS))) \
290 $(addprefix $(KOBJSDIR)/,$(addsuffix _handler.ko ,$(KHNDLRS))) \
291 $(addprefix $(KOBJSDIR)/,$(addsuffix _hidd.ko ,$(KHIDDS))) \
292 $(addprefix $(KOBJSDIR)/,$(addsuffix _resource.ko,$(KRSRCS))) \
293 $(addprefix $(KOBJSDIR)/,$(addsuffix _driver.ko ,$(KDRVRS) )) \
294 $(addprefix $(KOBJSDIR)/,$(addsuffix _hook.ko ,$(KHOOKS) ))
296 OBJS_local:= $(addprefix $(KOBJSDIR)/,$(addsuffix .o,$(AFILES))) \
297 $(addprefix $(KOBJSDIR)/,$(addsuffix .o,$(FILES)))
299 FILES=start early debug
300 AFILES=rom_entry rom_init cpu_detect superstack_swap
302 OBJS_start := $(addprefix $(KOBJSDIR)/,$(addsuffix .o,$(AFILES))) \
303 $(addprefix $(KOBJSDIR)/,$(addsuffix .o,$(FILES)))
306 # Everything else. Can live in MEMF_ANY
310 KLIBS := aros utility dos oop mathffp mathieeesingbas partition \
311 keymap graphics layers intuition gadtools icon workbench setpatch
312 KDEVS := timer input keyboard console trackdisk gameport audio ata cd
313 KHNDLRS := cdfs con afs ram
314 KHIDDS := amigakbd amigamouse amigavideo ata_gayle bus gfx hiddclass keyboard mouse storage system uaegfx
315 KRSRCS := battclock processor task lddemon dosboot cia potgo disk \
316 misc shell shellcommands workbook wbtag card FileSystem
317 KHOOKS := alert romboot
320 $(addprefix $(KOBJSDIR)/,$(addsuffix _library.ko ,$(KLIBS) )) \
321 $(addprefix $(KOBJSDIR)/,$(addsuffix _device.ko ,$(KDEVS) )) \
322 $(addprefix $(KOBJSDIR)/,$(addsuffix _handler.ko ,$(KHNDLRS))) \
323 $(addprefix $(KOBJSDIR)/,$(addsuffix _hidd.ko ,$(KHIDDS) )) \
324 $(addprefix $(KOBJSDIR)/,$(addsuffix _resource.ko,$(KRSRCS) )) \
325 $(addprefix $(KOBJSDIR)/,$(addsuffix _driver.ko ,$(KDRVRS) )) \
326 $(addprefix $(KOBJSDIR)/,$(addsuffix _hook.ko ,$(KHOOKS) ))
328 $(DISTDIR)/aros-amiga-m68k-ram.elf : $(DEPLIBS) $(SRCDIR)/$(CURDIR)/mmakefile.src \
330 $(OBJS_local) $(KOBJS_local) \
331 $(OBJS_any) $(KOBJS_any) \
332 $(SRCDIR)/$(CURDIR)/aros-ram.ld \
333 $(GENDIR)/start_objs.ld \
334 $(GENDIR)/local_objs.ld \
335 $(GENDIR)/any_objs.ld
337 @$(ECHO) Linking $@...
338 $(Q)$(KERNEL_CC) -Wl,-r \
339 -static -nostartfiles -nostdlib \
340 -Wl,--defsym -Wl,start=0x0 \
341 -Wl,--defsym -Wl,SysBase=0x4 \
342 -Wl,--defsym -Wl,AbsExecBase=0x4 \
344 -o $@ -Wl,-T -Wl,$(SRCDIR)/$(CURDIR)/aros-ram.ld \
345 -L$(AROS_LIB) $(LIBS) -lgcc
348 $(AROSARCHDIR)/aros.elf: $(DISTDIR)/aros-amiga-m68k-ram.elf \
349 $(SRCDIR)/$(CURDIR)/mmakefile.src
350 $(Q)$(MKDIR) $(AROSARCHDIR)
351 $(Q)$(TARGET_OBJCOPY) \
356 $(AROSARCHDIR)/aros.elf.dbg : $(DEPLIBS) $(SRCDIR)/$(CURDIR)/mmakefile.src \
358 $(OBJS_local) $(KOBJS_local) \
359 $(OBJS_any) $(KOBJS_any) \
360 $(SRCDIR)/$(CURDIR)/aros-dbg.ld \
361 $(GENDIR)/start_objs.ld \
362 $(GENDIR)/local_objs.ld \
363 $(GENDIR)/any_objs.ld
364 @$(IF) [ "$(DEBUG)" = "yes" ]; then \
365 $(ECHO) Linking $@...; \
366 $(KERNEL_CC) -Wl,-r \
367 -static -nostartfiles -nostdlib \
368 -Wl,--defsym -Wl,start=0x0 \
369 -Wl,--defsym -Wl,SysBase=0x4 \
370 -Wl,--defsym -Wl,AbsExecBase=0x4 \
372 -o $@ -Wl,-T -Wl,$(SRCDIR)/$(CURDIR)/aros-dbg.ld \
373 -L$(AROS_LIB) $(LIBS) -lgcc; \
374 $(TARGET_OBJCOPY) --add-gnu-debuglink=$@ $(AROSARCHDIR)/aros.elf; \