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 alterate CPUs
107 USER_AFLAGS := -march=68060 -DADATE="\"$(shell date "+%d.%m.%Y")\""
109 # Sadly, we need to consume Chip RAM for the initial SS and the ROM BSS.
110 # The initial System Stack is located at the end of the first 256K
111 # of CHIP RAM, but is only used until RTF_COLDSTART.
113 # Right before RTF_COLDSTART, a new SS will be allocated from the fastest
114 # available RAM, and this initial area will be ignored.
115 ROMLOC_ss := 0x003f800
117 # Main ROM (0xf80000 - 0xffffff)
118 ROMLOC_rom := 0x0f80000
120 FILES=start early debug mmu
121 AFILES=rom_entry rom_init cpu_detect superstack_swap
123 KLIBS := exec aros dos utility oop expansion partition debug
124 KDEVS := timer input keyboard console trackdisk gameport audio ata
125 KHNDLRS := con afs ram
126 KHIDDS := hiddclass gfx keyboard mouse amigakbd amigamouse amigavideo uaegfx ata_gayle
127 KRSRCS := battclock kernel processor task lddemon dosboot cia potgo disk FileSystem misc shell card bootloader
128 KHOOKS := diag romboot
130 KOBJS_rom := $(addprefix $(KOBJSDIR)/,$(addsuffix _library.ko ,$(KLIBS))) \
131 $(addprefix $(KOBJSDIR)/,$(addsuffix _device.ko ,$(KDEVS))) \
132 $(addprefix $(KOBJSDIR)/,$(addsuffix _handler.ko ,$(KHNDLRS))) \
133 $(addprefix $(KOBJSDIR)/,$(addsuffix _hidd.ko ,$(KHIDDS))) \
134 $(addprefix $(KOBJSDIR)/,$(addsuffix _resource.ko,$(KRSRCS))) \
135 $(addprefix $(KOBJSDIR)/,$(addsuffix _driver.ko ,$(KDRVRS) )) \
136 $(addprefix $(KOBJSDIR)/,$(addsuffix _hook.ko ,$(KHOOKS) ))
138 OBJS_rom := $(addprefix $(KOBJSDIR)/,$(addsuffix .o,$(AFILES))) \
139 $(addprefix $(KOBJSDIR)/,$(addsuffix .o,$(FILES)))
140 $(DISTDIR)/aros-amiga-m68k-rom.elf: $(KOBJS_rom) $(OBJS_rom)
142 # Expansion ROM (0xe00000-0xe7ffff)
146 KLIBS := keymap graphics layers intuition gadtools icon workbench \
147 mathffp mathieeesingbas freeanim lowlevel nonvolatile nvdisk \
152 KRSRCS := shellcommands workbook wbtag
155 ROMLOC_ext := 0xe00000
157 $(addprefix $(KOBJSDIR)/,$(addsuffix _library.ko ,$(KLIBS) )) \
158 $(addprefix $(KOBJSDIR)/,$(addsuffix _device.ko ,$(KDEVS) )) \
159 $(addprefix $(KOBJSDIR)/,$(addsuffix _handler.ko ,$(KHNDLRS))) \
160 $(addprefix $(KOBJSDIR)/,$(addsuffix _hidd.ko ,$(KHIDDS) )) \
161 $(addprefix $(KOBJSDIR)/,$(addsuffix _resource.ko,$(KRSRCS) )) \
162 $(addprefix $(KOBJSDIR)/,$(addsuffix _driver.ko ,$(KDRVRS) )) \
163 $(addprefix $(KOBJSDIR)/,$(addsuffix _hook.ko ,$(KHOOKS) ))
164 OBJS_ext := $(addprefix $(KOBJSDIR)/,$(addsuffix .o,$(AFILES))) \
165 $(addprefix $(KOBJSDIR)/,$(addsuffix .o,$(FILES)))
166 $(DISTDIR)/aros-amiga-m68k-ext.elf: $(KOBJS_ext) $(OBJS_ext)
168 #MM kernel-link-amiga-m68k:
169 kernel-link-amiga-m68k : $(DISTDIR)/aros-amiga-m68k-rom.bin $(DISTDIR)/aros-amiga-m68k-ext.bin
171 #MM kernel-link-amiga-m68k-quick:
172 kernel-link-amiga-m68k-quick : $(DISTDIR)/aros-amiga-m68k-rom.bin $(DISTDIR)/aros-amiga-m68k-ext.bin
174 $(HOSTGENDIR)/tools/romcheck: romcheck.c
175 $(Q)$(HOST_CC) $(DEBUG_CFLAGS) -o $@ $<
177 $(GENDIR)/%_objs.ld: $(SRCDIR)/$(CURDIR)/mmakefile.src
179 $(Q)for file in $(OBJS_$*) $(KOBJS_$*); do \
180 echo "$$file(.rodata .rodata.*)" >>$@; \
181 echo "$$file(.text)" >>$@; \
184 $(DISTDIR)/aros-amiga-m68k-reloc.elf : $(DEPLIBS) $(SRCDIR)/$(CURDIR)/mmakefile.src \
185 $(OBJS_rom) $(KOBJS_rom) \
186 $(OBJS_ext) $(KOBJS_ext) \
187 $(SRCDIR)/$(CURDIR)/aros-rom.ld \
188 $(GENDIR)/rom_objs.ld \
189 $(GENDIR)/ext_objs.ld
191 @$(ECHO) Linking $@...
192 $(Q)$(KERNEL_CC) -Wl,-r \
193 -static -nostartfiles -nostdlib \
194 -Wl,--defsym -Wl,start=0x0 \
195 -Wl,--defsym -Wl,SysBase=0x4 \
196 -Wl,--defsym -Wl,AbsExecBase=0x4 \
198 -o $@ -Wl,-T -Wl,$(SRCDIR)/$(CURDIR)/aros-rom.ld \
199 -L$(AROS_LIB) $(LIBS) -lgcc
201 $(DISTDIR)/aros-amiga-m68k.elf: $(DISTDIR)/aros-amiga-m68k-reloc.elf
202 $(Q)$(KERNEL_LD) -o $@ \
203 --section-start .rom=$(ROMLOC_rom) \
204 --section-start .ext=$(ROMLOC_ext) \
205 --section-start .ss=$(ROMLOC_ss) \
207 $(Q)$(TARGET_OBJDUMP) -h $@ | grep '[rea][oxm][mte] '
209 $(DISTDIR)/aros-amiga-m68k-%.bin : $(DISTDIR)/aros-amiga-m68k.elf $(HOSTGENDIR)/tools/romcheck
210 $(Q)$(TARGET_OBJCOPY) \
211 --output-target binary \
214 $(DISTDIR)/aros-amiga-m68k.elf $@
216 $(Q)$(HOSTGENDIR)/tools/romcheck $@
217 $(Q)$(MKDIR) $(AROSARCHDIR)
218 $(Q)$(CP) $@ $(AROSARCHDIR)/aros-$*.bin
224 USER_CFLAGS += $(PRIV_KERNEL_INCLUDES) $(PRIV_EXEC_INCLUDES) \
225 -fno-delete-null-pointer-checks
226 USER_AFLAGS += $(PRIV_KERNEL_INCLUDES) $(PRIV_EXEC_INCLUDES)
228 $(KOBJSDIR)/%.o : %.c
229 %compile_q cmd="$(KERNEL_CC)" opt="$(CFLAGS) $(USER_CFLAGS) -I$(AROS_DEVELOPER)/include -I$(GENINCDIR)"
231 $(KOBJSDIR)/%.o : %.S
232 %compile_q cmd="$(KERNEL_CC)" opt="$(CFLAGS) $(AFLAGS) $(USER_AFLAGS) -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
272 kernel-boot-elf-quick: $(AROSARCHDIR)/aros.elf
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 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) \