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 \
24 #MM kernel-audio-kobj \
25 #MM kernel-battclock-kobj \
26 #MM kernel-bootloader-amiga-m68k-kobj \
27 #MM kernel-bootloader-kobj \
28 #MM kernel-cardres-kobj \
30 #MM kernel-console-kobj \
31 #MM kernel-debug-kobj \
32 #MM kernel-diag-kobj \
33 #MM kernel-disk-kobj \
35 #MM kernel-dosboot-kobj \
36 #MM kernel-expansion-kobj \
37 #MM kernel-filesystem-kobj \
38 #MM kernel-freeanim-kobj \
39 #MM kernel-fs-afs-kobj \
40 #MM kernel-fs-cdfs-kobj \
41 #MM kernel-fs-con-kobj \
42 #MM kernel-fs-ram-kobj \
43 #MM kernel-gameport-kobj \
44 #MM kernel-graphics-kobj \
45 #MM kernel-hidd-kobj \
46 #MM kernel-hidd-gayleata-kobj \
47 #MM kernel-hidd-gfx-kobj \
48 #MM kernel-hidd-kbd-kobj \
49 #MM kernel-hidd-mouse-kobj \
50 #MM kernel-hidd-amigakbd-kobj \
51 #MM kernel-hidd-amigamouse-kobj \
52 #MM kernel-hidd-amigavideo-kobj \
53 #MM kernel-hidd-uaegfx-kobj \
54 #MM kernel-hidd-ata_gayle-kobj \
55 #MM kernel-intuition-kobj \
56 #MM kernel-input-kobj \
57 #MM kernel-keymap-kobj \
58 #MM kernel-keyboard-kobj \
59 #MM kernel-layers-kobj \
60 #MM kernel-lddemon-kobj \
61 #MM kernel-m680x0-kobj \
62 #MM kernel-misc-kobj \
64 #MM kernel-partition-kobj \
65 #MM kernel-processor-kobj \
66 #MM kernel-task-kobj \
67 #MM kernel-potgo-kobj \
68 #MM kernel-romboot-kobj \
69 #MM kernel-setpatch-kobj \
70 #MM kernel-shell-kobj \
71 #MM kernel-shellcommands-kobj \
72 #MM kernel-timer-kobj \
73 #MM kernel-trackdisk-kobj \
74 #MM kernel-utility-kobj \
75 #MM kernel-usb-amiga-m68k \
76 #MM kernel-workbook-kobj \
77 #MM kernel-workbench-devs-amiga-m68k \
78 #MM workbench-libs-gadtools-kobj \
79 #MM workbench-libs-icon-kobj \
80 #MM workbench-libs-lowlevel-kobj \
81 #MM workbench-libs-mathffp-kobj \
82 #MM workbench-libs-mathieeesingbas-kobj \
83 #MM workbench-libs-nonvolatile-kobj \
84 #MM workbench-libs-nvdisk-kobj \
85 #MM workbench-libs-workbench-kobj \
86 #MM linklibs-loadseg \
91 #MM- kernel-workbench-devs-amiga-m68k : workbench-devs-amiga-m68k
93 # Make sure we optimize this code for size ..
94 OPTIMIZATION_CFLAGS := -Os
96 USELIBS := amiga arossupport autoinit libinit stdc.static
97 LIBS := -L$(GENDIR)/lib -lloadseg $(addprefix -l,$(USELIBS))
98 DEPLIBS := $(addprefix $(AROS_LIB)/lib,$(addsuffix .a,$(USELIBS)))
100 # Force rebuilding, so that we always get new date strings
105 # Use -m68060 when compiling .S files, as we will need the
106 # expanded instruction set to detect alternate CPUs
107 USER_CPPFLAGS := -DADATE="\"$(shell date "+%d.%m.%Y")\""
108 TARGET_ISA_AFLAGS := $(ISA_MC68060_FLAGS)
110 # Sadly, we need to consume Chip RAM for the initial SS and the ROM BSS.
111 # The initial System Stack is located at the end of the first 256K
112 # of CHIP RAM, but is only used until RTF_COLDSTART.
114 # Right before RTF_COLDSTART, a new SS will be allocated from the fastest
115 # available RAM, and this initial area will be ignored.
116 ROMLOC_ss := 0x003f800
118 # Main ROM (0xf80000 - 0xffffff)
119 ROMLOC_rom := 0x0f80000
121 FILES=start early debug mmu
122 AFILES=rom_entry rom_init cpu_detect superstack_swap
124 KLIBS := exec aros dos utility oop expansion partition debug
125 KDEVS := timer input keyboard console trackdisk gameport audio
126 KHNDLRS := con afs ram
127 KHIDDS := hiddclass gfx keyboard mouse amigakbd amigamouse amigavideo uaegfx ata_gayle
128 KRSRCS := battclock kernel processor task lddemon dosboot cia potgo disk FileSystem misc shell card bootloader
129 KHOOKS := diag romboot
131 KOBJS_rom := $(addprefix $(KOBJSDIR)/,$(addsuffix _library.ko ,$(KLIBS))) \
132 $(addprefix $(KOBJSDIR)/,$(addsuffix _device.ko ,$(KDEVS))) \
133 $(addprefix $(KOBJSDIR)/,$(addsuffix _handler.ko ,$(KHNDLRS))) \
134 $(addprefix $(KOBJSDIR)/,$(addsuffix _hidd.ko ,$(KHIDDS))) \
135 $(addprefix $(KOBJSDIR)/,$(addsuffix _resource.ko,$(KRSRCS))) \
136 $(addprefix $(KOBJSDIR)/,$(addsuffix _driver.ko ,$(KDRVRS) )) \
137 $(addprefix $(KOBJSDIR)/,$(addsuffix _hook.ko ,$(KHOOKS) ))
139 OBJS_rom := $(addprefix $(KOBJSDIR)/,$(addsuffix .o,$(AFILES))) \
140 $(addprefix $(KOBJSDIR)/,$(addsuffix .o,$(FILES)))
141 $(DISTDIR)/aros-amiga-m68k-rom.elf: $(KOBJS_rom) $(OBJS_rom)
143 # Expansion ROM (0xe00000-0xe7ffff)
147 KLIBS := keymap graphics layers intuition gadtools icon workbench \
148 mathffp mathieeesingbas freeanim lowlevel nonvolatile nvdisk \
153 KRSRCS := shellcommands workbook wbtag
156 ROMLOC_ext := 0xe00000
158 $(addprefix $(KOBJSDIR)/,$(addsuffix _library.ko ,$(KLIBS) )) \
159 $(addprefix $(KOBJSDIR)/,$(addsuffix _device.ko ,$(KDEVS) )) \
160 $(addprefix $(KOBJSDIR)/,$(addsuffix _handler.ko ,$(KHNDLRS))) \
161 $(addprefix $(KOBJSDIR)/,$(addsuffix _hidd.ko ,$(KHIDDS) )) \
162 $(addprefix $(KOBJSDIR)/,$(addsuffix _resource.ko,$(KRSRCS) )) \
163 $(addprefix $(KOBJSDIR)/,$(addsuffix _driver.ko ,$(KDRVRS) )) \
164 $(addprefix $(KOBJSDIR)/,$(addsuffix _hook.ko ,$(KHOOKS) ))
165 OBJS_ext := $(addprefix $(KOBJSDIR)/,$(addsuffix .o,$(AFILES))) \
166 $(addprefix $(KOBJSDIR)/,$(addsuffix .o,$(FILES)))
167 $(DISTDIR)/aros-amiga-m68k-ext.elf: $(KOBJS_ext) $(OBJS_ext)
169 #MM kernel-link-amiga-m68k:
170 kernel-link-amiga-m68k : $(DISTDIR)/aros-amiga-m68k-rom.bin $(DISTDIR)/aros-amiga-m68k-ext.bin
172 #MM kernel-link-amiga-m68k-quick:
173 kernel-link-amiga-m68k-quick : $(DISTDIR)/aros-amiga-m68k-rom.bin $(DISTDIR)/aros-amiga-m68k-ext.bin
175 $(HOSTGENDIR)/tools/romcheck: romcheck.c
176 $(Q)$(HOST_CC) $(DEBUG_CFLAGS) -o $@ $<
178 $(GENDIR)/%_objs.ld: $(SRCDIR)/$(CURDIR)/mmakefile.src
180 $(Q)for file in $(OBJS_$*) $(KOBJS_$*); do \
181 echo "$$file(.rodata .rodata.*)" >>$@; \
182 echo "$$file(.text)" >>$@; \
185 $(DISTDIR)/aros-amiga-m68k-reloc.elf : $(DEPLIBS) $(SRCDIR)/$(CURDIR)/mmakefile.src \
186 $(OBJS_rom) $(KOBJS_rom) \
187 $(OBJS_ext) $(KOBJS_ext) \
188 $(SRCDIR)/$(CURDIR)/aros-rom.ld \
189 $(GENDIR)/rom_objs.ld \
190 $(GENDIR)/ext_objs.ld
192 @$(ECHO) Linking $@...
193 $(Q)$(KERNEL_CC) -Wl,-r \
194 -static -nostartfiles -nostdlib \
195 -Wl,--defsym -Wl,start=0x0 \
196 -Wl,--defsym -Wl,SysBase=0x4 \
197 -Wl,--defsym -Wl,AbsExecBase=0x4 \
199 -o $@ -Wl,-T -Wl,$(SRCDIR)/$(CURDIR)/aros-rom.ld \
200 -L$(AROS_LIB) $(LIBS) -lgcc
202 $(DISTDIR)/aros-amiga-m68k.elf: $(DISTDIR)/aros-amiga-m68k-reloc.elf
203 $(Q)$(KERNEL_LD) -o $@ \
204 --section-start .rom=$(ROMLOC_rom) \
205 --section-start .ext=$(ROMLOC_ext) \
206 --section-start .ss=$(ROMLOC_ss) \
208 $(Q)$(TARGET_OBJDUMP) -h $@ | grep '[rea][oxm][mte] '
210 $(DISTDIR)/aros-amiga-m68k-%.bin : $(DISTDIR)/aros-amiga-m68k.elf $(HOSTGENDIR)/tools/romcheck
211 $(Q)$(TARGET_OBJCOPY) \
212 --output-target binary \
215 $(DISTDIR)/aros-amiga-m68k.elf $@
217 $(Q)$(HOSTGENDIR)/tools/romcheck $@
218 $(Q)$(MKDIR) $(AROSARCHDIR)
219 $(Q)$(CP) $@ $(AROSARCHDIR)/aros-$*.bin
225 USER_INCLUDES += $(PRIV_KERNEL_INCLUDES) $(PRIV_EXEC_INCLUDES)
226 USER_CFLAGS += -fno-delete-null-pointer-checks
228 $(KOBJSDIR)/%.o : %.c
229 %compile_q cmd="$(KERNEL_CC)" opt="$(strip $(CFLAGS) $(CPPFLAGS) -I$(AROS_DEVELOPER)/include -I$(GENINCDIR))"
231 $(KOBJSDIR)/%.o : %.S
232 %compile_q cmd="$(KERNEL_CC)" opt="$(strip $(AFLAGS) $(TARGET_CFLAGS) $(CPPFLAGS) -I$(AROS_DEVELOPER)/include -I$(GENINCDIR))"
234 $(KOBJSDIR)/%.d : %.c
237 # Localize symbols, so that we don't get name clashes when linking
239 # .. except for exec.library. Our boot code needs symbols from it
240 # (PrepareMoveExecBase, InitKickTags, etc)
241 %/exec_library.ko: %/exec_library.o
244 # .. except for kernel.resource. Our boot code needs symbols from it
245 # (krnPrepareExecBase and krnCreateMemHeader)
246 %/kernel_resource.ko: %/kernel_resource.o
249 # .. except for expansion.library. Our boot code needs symbols from it
251 %/expansion_library.ko: %/expansion_library.o
254 # Localize symbols for everybody else though!
256 $(Q)$(NM_PLAIN) --defined-only $< | cut -d' ' -f3 >$@.sym
257 $(Q)$(OBJCOPY) --localize-symbols $@.sym $< $@
259 DEPS := $(foreach f, $(FILES), $(TARGETDIR)/$(f).d)
262 ###########################################################################
264 ## Compressed elf for AROSBootstrap
266 #MM- kernel-link-amiga-m68k: kernel-boot-elf
267 #MM- kernel-link-amiga-m68k-quick: kernel-boot-elf-quick
270 #MM kernel-boot-elf-quick:
271 kernel-boot-elf: $(AROSARCHDIR)/aros.elf $(AROSARCHDIR)/aros.elf.dbg
272 kernel-boot-elf-quick: $(AROSARCHDIR)/aros.elf $(AROSARCHDIR)/aros.elf.dbg
274 # Main ROM, that must live in MEMF_LOCAL memory
279 KLIBS := exec expansion
286 KOBJS_local := $(addprefix $(KOBJSDIR)/,$(addsuffix _library.ko ,$(KLIBS))) \
287 $(addprefix $(KOBJSDIR)/,$(addsuffix _device.ko ,$(KDEVS))) \
288 $(addprefix $(KOBJSDIR)/,$(addsuffix _handler.ko ,$(KHNDLRS))) \
289 $(addprefix $(KOBJSDIR)/,$(addsuffix _hidd.ko ,$(KHIDDS))) \
290 $(addprefix $(KOBJSDIR)/,$(addsuffix _resource.ko,$(KRSRCS))) \
291 $(addprefix $(KOBJSDIR)/,$(addsuffix _driver.ko ,$(KDRVRS) )) \
292 $(addprefix $(KOBJSDIR)/,$(addsuffix _hook.ko ,$(KHOOKS) ))
294 OBJS_local:= $(addprefix $(KOBJSDIR)/,$(addsuffix .o,$(AFILES))) \
295 $(addprefix $(KOBJSDIR)/,$(addsuffix .o,$(FILES)))
297 FILES=start early debug
298 AFILES=rom_entry rom_init cpu_detect superstack_swap
300 OBJS_start := $(addprefix $(KOBJSDIR)/,$(addsuffix .o,$(AFILES))) \
301 $(addprefix $(KOBJSDIR)/,$(addsuffix .o,$(FILES)))
304 # Everything else. Can live in MEMF_ANY
308 KLIBS := aros utility dos oop mathffp mathieeesingbas partition \
309 keymap graphics layers intuition gadtools icon workbench setpatch
310 KDEVS := timer input keyboard console trackdisk gameport audio ata cd
311 KHNDLRS := cdfs con afs ram
312 KHIDDS := hiddclass gfx keyboard mouse amigakbd amigamouse amigavideo uaegfx ata_gayle
313 KRSRCS := battclock processor task lddemon dosboot cia potgo disk \
314 misc shell shellcommands workbook wbtag card FileSystem
315 KHOOKS := alert romboot
318 $(addprefix $(KOBJSDIR)/,$(addsuffix _library.ko ,$(KLIBS) )) \
319 $(addprefix $(KOBJSDIR)/,$(addsuffix _device.ko ,$(KDEVS) )) \
320 $(addprefix $(KOBJSDIR)/,$(addsuffix _handler.ko ,$(KHNDLRS))) \
321 $(addprefix $(KOBJSDIR)/,$(addsuffix _hidd.ko ,$(KHIDDS) )) \
322 $(addprefix $(KOBJSDIR)/,$(addsuffix _resource.ko,$(KRSRCS) )) \
323 $(addprefix $(KOBJSDIR)/,$(addsuffix _driver.ko ,$(KDRVRS) )) \
324 $(addprefix $(KOBJSDIR)/,$(addsuffix _hook.ko ,$(KHOOKS) ))
326 $(DISTDIR)/aros-amiga-m68k-ram.elf : $(DEPLIBS) $(SRCDIR)/$(CURDIR)/mmakefile.src \
328 $(OBJS_local) $(KOBJS_local) \
329 $(OBJS_any) $(KOBJS_any) \
330 $(SRCDIR)/$(CURDIR)/aros-ram.ld \
331 $(GENDIR)/start_objs.ld \
332 $(GENDIR)/local_objs.ld \
333 $(GENDIR)/any_objs.ld
335 @$(ECHO) Linking $@...
336 $(Q)$(KERNEL_CC) -Wl,-r \
337 -static -nostartfiles -nostdlib \
338 -Wl,--defsym -Wl,start=0x0 \
339 -Wl,--defsym -Wl,SysBase=0x4 \
340 -Wl,--defsym -Wl,AbsExecBase=0x4 \
342 -o $@ -Wl,-T -Wl,$(SRCDIR)/$(CURDIR)/aros-ram.ld \
343 -L$(AROS_LIB) $(LIBS) -lgcc
346 $(AROSARCHDIR)/aros.elf: $(DISTDIR)/aros-amiga-m68k-ram.elf \
347 $(SRCDIR)/$(CURDIR)/mmakefile.src
348 $(Q)$(MKDIR) $(AROSARCHDIR)
349 $(Q)$(TARGET_OBJCOPY) \
354 $(AROSARCHDIR)/aros.elf.dbg : $(DEPLIBS) $(SRCDIR)/$(CURDIR)/mmakefile.src \
356 $(OBJS_local) $(KOBJS_local) \
357 $(OBJS_any) $(KOBJS_any) \
358 $(SRCDIR)/$(CURDIR)/aros-dbg.ld \
359 $(GENDIR)/start_objs.ld \
360 $(GENDIR)/local_objs.ld \
361 $(GENDIR)/any_objs.ld
362 @$(IF) [ "$(DEBUG)" = "yes" ]; then \
363 $(ECHO) Linking $@...; \
364 $(KERNEL_CC) -Wl,-r \
365 -static -nostartfiles -nostdlib \
366 -Wl,--defsym -Wl,start=0x0 \
367 -Wl,--defsym -Wl,SysBase=0x4 \
368 -Wl,--defsym -Wl,AbsExecBase=0x4 \
370 -o $@ -Wl,-T -Wl,$(SRCDIR)/$(CURDIR)/aros-dbg.ld \
371 -L$(AROS_LIB) $(LIBS) -lgcc; \
372 $(TARGET_OBJCOPY) --add-gnu-debuglink=$@ $(AROSARCHDIR)/aros.elf; \