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-graphics-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 USELIBS := amiga arossupport autoinit libinit stdc.static
94 LIBS := -L$(GENDIR)/lib -lloadseg $(addprefix -l,$(USELIBS))
95 DEPLIBS := $(addprefix $(AROS_LIB)/lib,$(addsuffix .a,$(USELIBS)))
97 # Force rebuilding, so that we always get new date strings
102 # USe -m68060 when compiling .S files, as we will need the
103 # expanded instruction set to detect alterate CPUs
104 USER_AFLAGS := -march=68060 -DADATE="\"$(shell date "+%d.%m.%Y")\""
106 # Sadly, we need to consume Chip RAM for the initial SS and the ROM BSS.
107 # The initial System Stack is located at the end of the first 256K
108 # of CHIP RAM, but is only used until RTF_COLDSTART.
110 # Right before RTF_COLDSTART, a new SS will be allocated from the fastest
111 # available RAM, and this initial area will be ignored.
112 ROMLOC_ss := 0x003f800
114 # Main ROM (0xf80000 - 0xffffff)
115 ROMLOC_rom := 0x0f80000
117 FILES=start early debug mmu
118 AFILES=rom_entry rom_init cpu_detect superstack_swap
120 KLIBS := exec aros dos utility oop expansion partition debug
121 KDEVS := timer input keyboard console trackdisk gameport audio ata
122 KHNDLRS := con afs ram
123 KHIDDS := hiddclass graphics keyboard mouse amigakbd amigamouse amigavideo uaegfx ata_gayle
124 KRSRCS := battclock kernel processor task lddemon dosboot cia potgo disk FileSystem misc shell card bootloader
125 KHOOKS := diag romboot
127 KOBJS_rom := $(addprefix $(KOBJSDIR)/,$(addsuffix _library.ko ,$(KLIBS))) \
128 $(addprefix $(KOBJSDIR)/,$(addsuffix _device.ko ,$(KDEVS))) \
129 $(addprefix $(KOBJSDIR)/,$(addsuffix _handler.ko ,$(KHNDLRS))) \
130 $(addprefix $(KOBJSDIR)/,$(addsuffix _hidd.ko ,$(KHIDDS))) \
131 $(addprefix $(KOBJSDIR)/,$(addsuffix _resource.ko,$(KRSRCS))) \
132 $(addprefix $(KOBJSDIR)/,$(addsuffix _driver.ko ,$(KDRVRS) )) \
133 $(addprefix $(KOBJSDIR)/,$(addsuffix _hook.ko ,$(KHOOKS) ))
135 OBJS_rom := $(addprefix $(KOBJSDIR)/,$(addsuffix .o,$(AFILES))) \
136 $(addprefix $(KOBJSDIR)/,$(addsuffix .o,$(FILES)))
137 $(DISTDIR)/aros-amiga-m68k-rom.elf: $(KOBJS_rom) $(OBJS_rom)
139 # Expansion ROM (0xe00000-0xe7ffff)
143 KLIBS := keymap graphics layers intuition gadtools icon workbench \
144 mathffp mathieeesingbas freeanim lowlevel nonvolatile nvdisk \
149 KRSRCS := shellcommands workbook wbtag
152 ROMLOC_ext := 0xe00000
154 $(addprefix $(KOBJSDIR)/,$(addsuffix _library.ko ,$(KLIBS) )) \
155 $(addprefix $(KOBJSDIR)/,$(addsuffix _device.ko ,$(KDEVS) )) \
156 $(addprefix $(KOBJSDIR)/,$(addsuffix _handler.ko ,$(KHNDLRS))) \
157 $(addprefix $(KOBJSDIR)/,$(addsuffix _hidd.ko ,$(KHIDDS) )) \
158 $(addprefix $(KOBJSDIR)/,$(addsuffix _resource.ko,$(KRSRCS) )) \
159 $(addprefix $(KOBJSDIR)/,$(addsuffix _driver.ko ,$(KDRVRS) )) \
160 $(addprefix $(KOBJSDIR)/,$(addsuffix _hook.ko ,$(KHOOKS) ))
161 OBJS_ext := $(addprefix $(KOBJSDIR)/,$(addsuffix .o,$(AFILES))) \
162 $(addprefix $(KOBJSDIR)/,$(addsuffix .o,$(FILES)))
163 $(DISTDIR)/aros-amiga-m68k-ext.elf: $(KOBJS_ext) $(OBJS_ext)
165 #MM kernel-link-amiga-m68k:
166 kernel-link-amiga-m68k : $(DISTDIR)/aros-amiga-m68k-rom.bin $(DISTDIR)/aros-amiga-m68k-ext.bin
168 #MM kernel-link-amiga-m68k-quick:
169 kernel-link-amiga-m68k-quick : $(DISTDIR)/aros-amiga-m68k-rom.bin $(DISTDIR)/aros-amiga-m68k-ext.bin
171 $(HOSTGENDIR)/tools/romcheck: romcheck.c
172 $(Q)$(HOST_CC) $(DEBUG_CFLAGS) -o $@ $<
174 $(GENDIR)/%_objs.ld: $(SRCDIR)/$(CURDIR)/mmakefile.src
176 $(Q)for file in $(OBJS_$*) $(KOBJS_$*); do \
177 echo "$$file(.rodata .rodata.*)" >>$@; \
178 echo "$$file(.text)" >>$@; \
181 $(DISTDIR)/aros-amiga-m68k-reloc.elf : $(DEPLIBS) $(SRCDIR)/$(CURDIR)/mmakefile.src \
182 $(OBJS_rom) $(KOBJS_rom) \
183 $(OBJS_ext) $(KOBJS_ext) \
184 $(SRCDIR)/$(CURDIR)/aros-rom.ld \
185 $(GENDIR)/rom_objs.ld \
186 $(GENDIR)/ext_objs.ld
188 @$(ECHO) Linking $@...
189 $(Q)$(KERNEL_CC) -Wl,-r \
190 -static -nostartfiles -nostdlib \
191 -Wl,--defsym -Wl,start=0x0 \
192 -Wl,--defsym -Wl,SysBase=0x4 \
193 -Wl,--defsym -Wl,AbsExecBase=0x4 \
195 -o $@ -Wl,-T -Wl,$(SRCDIR)/$(CURDIR)/aros-rom.ld \
196 -L$(AROS_LIB) $(LIBS) -lgcc
198 $(DISTDIR)/aros-amiga-m68k.elf: $(DISTDIR)/aros-amiga-m68k-reloc.elf
199 $(Q)$(KERNEL_LD) -o $@ \
200 --section-start .rom=$(ROMLOC_rom) \
201 --section-start .ext=$(ROMLOC_ext) \
202 --section-start .ss=$(ROMLOC_ss) \
204 $(Q)$(TARGET_OBJDUMP) -h $@ | grep '[rea][oxm][mte] '
206 $(DISTDIR)/aros-amiga-m68k-%.bin : $(DISTDIR)/aros-amiga-m68k.elf $(HOSTGENDIR)/tools/romcheck
207 $(Q)$(TARGET_OBJCOPY) \
208 --output-target binary \
211 $(DISTDIR)/aros-amiga-m68k.elf $@
213 $(Q)$(HOSTGENDIR)/tools/romcheck $@
214 $(Q)$(MKDIR) $(AROSARCHDIR)
215 $(Q)$(CP) $@ $(AROSARCHDIR)/aros-$*.bin
221 USER_CFLAGS += $(PRIV_KERNEL_INCLUDES) $(PRIV_EXEC_INCLUDES) \
222 -fno-delete-null-pointer-checks
223 USER_AFLAGS += $(PRIV_KERNEL_INCLUDES) $(PRIV_EXEC_INCLUDES)
225 $(KOBJSDIR)/%.o : %.c
226 %compile_q cmd="$(KERNEL_CC)" opt="$(CFLAGS) $(USER_CFLAGS) -I$(AROSDIR)/Development/include -I$(GENINCDIR)"
228 $(KOBJSDIR)/%.o : %.S
229 %compile_q cmd="$(KERNEL_CC)" opt="$(CFLAGS) $(AFLAGS) $(USER_AFLAGS) -I$(AROSDIR)/Development/include -I$(GENINCDIR)"
231 $(KOBJSDIR)/%.d : %.c
234 # Localize symbols, so that we don't get name clashes when linking
236 # .. except for exec.library. Our boot code needs symbols from it
237 # (PrepareMoveExecBase, InitKickTags, etc)
238 %/exec_library.ko: %/exec_library.o
241 # .. except for kernel.resource. Our boot code needs symbols from it
242 # (krnPrepareExecBase and krnCreateMemHeader)
243 %/kernel_resource.ko: %/kernel_resource.o
246 # .. except for expansion.library. Our boot code needs symbols from it
248 %/expansion_library.ko: %/expansion_library.o
251 # Localize symbols for everybody else though!
253 $(Q)$(NM_PLAIN) --defined-only $< | cut -d' ' -f3 >$@.sym
254 $(Q)$(OBJCOPY) --localize-symbols $@.sym $< $@
256 DEPS := $(foreach f, $(FILES), $(TARGETDIR)/$(f).d)
259 ###########################################################################
261 ## Compressed elf for AROSBootstrap
263 #MM- kernel-link-amiga-m68k: kernel-boot-elf
264 #MM- kernel-link-amiga-m68k-quick: kernel-boot-elf-quick
267 #MM kernel-boot-elf-quick:
268 kernel-boot-elf: $(AROSARCHDIR)/aros.elf
269 kernel-boot-elf-quick: $(AROSARCHDIR)/aros.elf
271 # Main ROM, that must live in MEMF_LOCAL memory
276 KLIBS := exec expansion
283 KOBJS_local := $(addprefix $(KOBJSDIR)/,$(addsuffix _library.ko ,$(KLIBS))) \
284 $(addprefix $(KOBJSDIR)/,$(addsuffix _device.ko ,$(KDEVS))) \
285 $(addprefix $(KOBJSDIR)/,$(addsuffix _handler.ko ,$(KHNDLRS))) \
286 $(addprefix $(KOBJSDIR)/,$(addsuffix _hidd.ko ,$(KHIDDS))) \
287 $(addprefix $(KOBJSDIR)/,$(addsuffix _resource.ko,$(KRSRCS))) \
288 $(addprefix $(KOBJSDIR)/,$(addsuffix _driver.ko ,$(KDRVRS) )) \
289 $(addprefix $(KOBJSDIR)/,$(addsuffix _hook.ko ,$(KHOOKS) ))
291 OBJS_local:= $(addprefix $(KOBJSDIR)/,$(addsuffix .o,$(AFILES))) \
292 $(addprefix $(KOBJSDIR)/,$(addsuffix .o,$(FILES)))
294 FILES=start early debug
295 AFILES=rom_entry rom_init cpu_detect superstack_swap
297 OBJS_start := $(addprefix $(KOBJSDIR)/,$(addsuffix .o,$(AFILES))) \
298 $(addprefix $(KOBJSDIR)/,$(addsuffix .o,$(FILES)))
301 # Everything else. Can live in MEMF_ANY
305 KLIBS := aros utility dos oop mathffp mathieeesingbas partition \
306 keymap graphics layers intuition gadtools icon workbench setpatch
307 KDEVS := timer input keyboard console trackdisk gameport audio ata cd
308 KHNDLRS := cdfs con afs ram
309 KHIDDS := hiddclass graphics keyboard mouse amigakbd amigamouse amigavideo uaegfx ata_gayle
310 KRSRCS := battclock processor lddemon dosboot cia potgo disk \
311 misc shell shellcommands workbook wbtag card FileSystem
312 KHOOKS := alert romboot
315 $(addprefix $(KOBJSDIR)/,$(addsuffix _library.ko ,$(KLIBS) )) \
316 $(addprefix $(KOBJSDIR)/,$(addsuffix _device.ko ,$(KDEVS) )) \
317 $(addprefix $(KOBJSDIR)/,$(addsuffix _handler.ko ,$(KHNDLRS))) \
318 $(addprefix $(KOBJSDIR)/,$(addsuffix _hidd.ko ,$(KHIDDS) )) \
319 $(addprefix $(KOBJSDIR)/,$(addsuffix _resource.ko,$(KRSRCS) )) \
320 $(addprefix $(KOBJSDIR)/,$(addsuffix _driver.ko ,$(KDRVRS) )) \
321 $(addprefix $(KOBJSDIR)/,$(addsuffix _hook.ko ,$(KHOOKS) ))
323 $(DISTDIR)/aros-amiga-m68k-ram.elf : $(DEPLIBS) $(SRCDIR)/$(CURDIR)/mmakefile.src \
325 $(OBJS_local) $(KOBJS_local) \
326 $(OBJS_any) $(KOBJS_any) \
327 $(SRCDIR)/$(CURDIR)/aros-ram.ld \
328 $(GENDIR)/start_objs.ld \
329 $(GENDIR)/local_objs.ld \
330 $(GENDIR)/any_objs.ld
332 @$(ECHO) Linking $@...
333 $(Q)$(KERNEL_CC) -Wl,-r \
334 -static -nostartfiles -nostdlib \
335 -Wl,--defsym -Wl,start=0x0 \
336 -Wl,--defsym -Wl,SysBase=0x4 \
337 -Wl,--defsym -Wl,AbsExecBase=0x4 \
339 -o $@ -Wl,-T -Wl,$(SRCDIR)/$(CURDIR)/aros-ram.ld \
340 -L$(AROS_LIB) $(LIBS) -lgcc
343 $(AROSARCHDIR)/aros.elf: $(DISTDIR)/aros-amiga-m68k-ram.elf \
344 $(SRCDIR)/$(CURDIR)/mmakefile.src
345 $(Q)$(MKDIR) $(AROSARCHDIR)
346 $(Q)$(TARGET_OBJCOPY) \