1 AUTOMAKE_OPTIONS = subdir-objects -Wno-portability
5 include $(top_srcdir)/conf/Makefile.common
10 RANLIB=$(TARGET_RANLIB)
13 MACHO2IMG=$(top_builddir)/grub-macho2img
15 AM_CFLAGS = $(TARGET_CFLAGS)
16 AM_LDFLAGS = $(TARGET_LDFLAGS)
17 AM_CPPFLAGS = $(TARGET_CPPFLAGS) $(CPPFLAGS_DEFAULT)
18 AM_CCASFLAGS = $(TARGET_CCASFLAGS) $(CCASFLAGS_DEFAULT)
20 CFLAGS_PROGRAM += $(CFLAGS_PLATFORM)
21 LDFLAGS_PROGRAM += $(LDFLAGS_PLATFORM)
22 CPPFLAGS_PROGRAM += $(CPPFLAGS_PLATFORM)
23 CCASFLAGS_PROGRAM += $(CCASFLAGS_PLATFORM)
25 CFLAGS_LIBRARY += $(CFLAGS_PLATFORM) -fno-builtin
26 CPPFLAGS_LIBRARY += $(CPPFLAGS_PLATFORM)
27 CCASFLAGS_LIBRARY += $(CCASFLAGS_PLATFORM)
29 build-grub-pe2elf: $(top_srcdir)/util/grub-pe2elf.c $(top_srcdir)/grub-core/kern/emu/misc.c $(top_srcdir)/util/misc.c
30 $(BUILD_CC) -o $@ -I$(top_srcdir)/include $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) -DGRUB_BUILD=1 -DGRUB_UTIL=1 -DGRUB_BUILD_PROGRAM_NAME=\"build-grub-pe2elf\" $^
33 gentrigtables: gentrigtables.c
34 $(BUILD_CC) -o $@ -I$(top_srcdir)/include $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $< $(BUILD_LIBM)
35 CLEANFILES += gentrigtables
38 trigtables.c: gentrigtables gentrigtables.c $(top_srcdir)/configure.ac
40 CLEANFILES += trigtables.c
42 # XXX Use Automake's LEX & YACC support
43 grub_script.tab.h: script/parser.y
44 $(YACC) -d -p grub_script_yy -b grub_script $<
45 grub_script.tab.c: grub_script.tab.h
46 CLEANFILES += grub_script.tab.c grub_script.tab.h
49 grub_script.yy.h: script/yylex.l
50 $(LEX) -o grub_script.yy.c --header-file=grub_script.yy.h $<
51 grub_script.yy.c: grub_script.yy.h
53 rs_decoder.h: $(srcdir)/lib/reed_solomon.c
54 $(TARGET_CC) $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) -Os -I$(top_builddir) -S -DSTANDALONE -o $@ $< -g0 -mregparm=3 -ffreestanding
56 CLEANFILES += grub_script.yy.c grub_script.yy.h
58 include $(srcdir)/Makefile.core.am
60 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/cache.h
61 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/command.h
62 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/device.h
63 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/disk.h
64 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/dl.h
65 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/env.h
66 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/env_private.h
67 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/err.h
68 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/file.h
69 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/fs.h
70 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i18n.h
71 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/kernel.h
72 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/list.h
73 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/misc.h
74 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/mm.h
75 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/parser.h
76 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/partition.h
77 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/term.h
78 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/time.h
79 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/mm_private.h
80 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/net.h
82 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/libgcc.h
84 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/memory.h
87 KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/kernel.h
88 KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/pxe.h
89 KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/int.h
90 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/tsc.h
94 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/efi.h
95 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/disk.h
96 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/tsc.h
97 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/pci.h
100 if COND_i386_coreboot
101 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/tsc.h
102 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/coreboot/lbio.h
103 KERNEL_HEADER_FILES += $(top_builddir)/include/grub/i386/pc/int.h
104 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/video.h
105 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/video_fb.h
106 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/gfxterm.h
107 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/font.h
108 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/bufio.h
111 if COND_i386_multiboot
112 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/tsc.h
113 KERNEL_HEADER_FILES += $(top_builddir)/include/grub/i386/pc/int.h
117 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/pci.h
118 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/tsc.h
121 if COND_i386_ieee1275
122 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/ieee1275/ieee1275.h
123 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/terminfo.h
124 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/extcmd.h
125 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/lib/arg.h
126 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/tsc.h
130 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/xen.h
131 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/xen/hypercall.h
132 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/terminfo.h
133 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/extcmd.h
134 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/lib/arg.h
135 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/loader.h
139 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/xen.h
140 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/x86_64/xen/hypercall.h
141 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/terminfo.h
142 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/extcmd.h
143 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/lib/arg.h
144 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/loader.h
148 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/efi.h
149 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/disk.h
150 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/tsc.h
151 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/pci.h
155 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/efi.h
156 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/disk.h
160 KERNEL_HEADER_FILES += $(top_builddir)/include/grub/cpu/kernel.h
164 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/extcmd.h
165 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/arc/arc.h
166 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/terminfo.h
169 if COND_mips_qemu_mips
170 KERNEL_HEADER_FILES += $(top_builddir)/include/grub/keyboard_layouts.h
171 KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/kernel.h
172 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/serial.h
173 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/loader.h
174 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/terminfo.h
175 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/extcmd.h
176 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/lib/arg.h
179 if COND_mips_loongson
180 KERNEL_HEADER_FILES += $(top_builddir)/include/grub/keyboard_layouts.h
181 KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/kernel.h
182 KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/time.h
183 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/video.h
184 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/video_fb.h
185 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/gfxterm.h
186 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/font.h
187 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/bufio.h
188 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/pci.h
189 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/cs5536.h
190 KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/pci.h
191 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/serial.h
192 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/loader.h
193 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/terminfo.h
194 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/extcmd.h
195 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/lib/arg.h
198 if COND_mips_qemu_mips
199 KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/memory.h
200 KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/kernel.h
203 if COND_powerpc_ieee1275
204 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/ieee1275/ieee1275.h
205 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/terminfo.h
206 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/extcmd.h
207 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/lib/arg.h
210 if COND_sparc64_ieee1275
211 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/ieee1275/ieee1275.h
212 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/sparc64/ieee1275/ieee1275.h
213 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/terminfo.h
214 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/extcmd.h
215 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/lib/arg.h
219 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/uboot/uboot.h
220 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/uboot/disk.h
221 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/extcmd.h
222 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/lib/arg.h
226 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/arm/efi/loader.h
227 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/efi.h
228 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/disk.h
232 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/efi.h
233 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/disk.h
237 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/datetime.h
238 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/emu/misc.h
239 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/emu/net.h
240 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/emu/hostdisk.h
241 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/emu/hostfile.h
242 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/extcmd.h
244 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/sdl.h
247 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/libusb.h
250 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/libpciaccess.h
254 symlist.h: $(top_builddir)/config.h $(KERNEL_HEADER_FILES)
256 for p in $$list; do \
257 echo "#include <$$p>" >> $@ || (rm -f $@; exit 1); \
259 CLEANFILES += symlist.h
260 BUILT_SOURCES += symlist.h
262 symlist.c: symlist.h gensymlist.sh
263 $(TARGET_CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS_KERNEL) $(CPPFLAGS) -DGRUB_SYMBOL_GENERATOR=1 symlist.h > symlist.p || (rm -f symlist.p; exit 1)
264 cat symlist.p | /bin/sh $(srcdir)/gensymlist.sh $(top_builddir)/config.h $(KERNEL_HEADER_FILES) >$@ || (rm -f $@; exit 1)
266 CLEANFILES += symlist.c
267 BUILT_SOURCES += symlist.c
269 if COND_HAVE_ASM_USCORE
275 noinst_DATA += kernel_syms.lst
277 kernel_syms.lst: $(KERNEL_HEADER_FILES) $(top_builddir)/config.h
278 $(TARGET_CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS_KERNEL) $(CPPFLAGS) $(CFLAGS) -DGRUB_SYMBOL_GENERATOR=1 $^ >kernel_syms.input
279 cat kernel_syms.input | grep -v '^#' | sed -n \
280 -e '/EXPORT_FUNC *([a-zA-Z0-9_]*)/{s/.*EXPORT_FUNC *(\([a-zA-Z0-9_]*\)).*/defined kernel '"$(ASM_PREFIX)"'\1/;p;}' \
281 -e '/EXPORT_VAR *([a-zA-Z0-9_]*)/{s/.*EXPORT_VAR *(\([a-zA-Z0-9_]*\)).*/defined kernel '"$(ASM_PREFIX)"'\1/;p;}' \
283 rm -f kernel_syms.input
284 CLEANFILES += kernel_syms.lst
287 kern/emu/grub_emu-main.$(OBJEXT):grub_emu_init.h
288 grub_emu-grub_emu_init.$(OBJEXT):grub_emu_init.h
289 kern/emu/grub_emu_dyn-main.$(OBJEXT):grub_emu_init.h
290 grub_emu_dyn-grub_emu_init.$(OBJEXT):grub_emu_init.h
292 grub_emu_init.h: genemuinitheader.sh $(MOD_FILES)
293 rm -f $@; echo $(MOD_FILES) | sh $(srcdir)/genemuinitheader.sh $(TARGET_NM) > $@
294 CLEANFILES += grub_emu_init.h
296 grub_emu_init.c: grub_emu_init.h genemuinit.sh $(MOD_FILES)
297 rm -f $@; echo $(MOD_FILES) | sh $(srcdir)/genemuinit.sh $(TARGET_NM) > $@
298 CLEANFILES += grub_emu_init.c
303 fs.lst: $(MARKER_FILES)
305 b=`basename $$pp .marker`; \
306 if grep 'FS_LIST_MARKER' $$pp >/dev/null 2>&1; then \
310 platform_DATA += fs.lst
313 command.lst: $(MARKER_FILES)
315 b=`basename $$pp .marker`; \
317 -e "/EXTCOMMAND_LIST_MARKER *( *\"/{s/.*( *\"\([^\"]*\)\".*/*\1: $$b/;p;}" \
318 -e "/P1COMMAND_LIST_MARKER *( *\"/{s/.*( *\"\([^\"]*\)\".*/*\1: $$b/;p;}" \
319 -e "/COMMAND_LIST_MARKER *( *\"/{s/.*( *\"\([^\"]*\)\".*/\1: $$b/;p;}" $$pp; \
321 platform_DATA += command.lst
322 CLEANFILES += command.lst
324 partmap.lst: $(MARKER_FILES)
326 b=`basename $$pp .marker`; \
327 if grep 'PARTMAP_LIST_MARKER' $$pp >/dev/null 2>&1; then \
331 platform_DATA += partmap.lst
332 CLEANFILES += partmap.lst
334 terminal.lst: $(MARKER_FILES)
336 b=`basename $$pp .marker`; \
338 -e "/INPUT_TERMINAL_LIST_MARKER *( *\"/{s/.*( *\"\([^\"]*\)\".*/i\1: $$b/;p;}" \
339 -e "/OUTPUT_TERMINAL_LIST_MARKER *( *\"/{s/.*( *\"\([^\"]*\)\".*/o\1: $$b/;p;}" $$pp; \
341 platform_DATA += terminal.lst
342 CLEANFILES += terminal.lst
344 parttool.lst: $(MARKER_FILES)
346 b=`basename $$pp .marker`; \
348 -e "/PARTTOOL_LIST_MARKER *( *\"/{s/.*( *\"\([^\"]*\)\".*/\1: $$b/;p;}" $$pp; \
350 platform_DATA += parttool.lst
351 CLEANFILES += parttool.lst
353 video.lst: $(MARKER_FILES)
355 b=`basename $$pp .marker`; \
356 if grep 'VIDEO_LIST_MARKER' $$pp >/dev/null 2>&1; then \
360 platform_DATA += video.lst
361 CLEANFILES += video.lst
363 # but, crypto.lst is simply copied
364 crypto.lst: $(srcdir)/lib/libgcrypt-grub/cipher/crypto.lst
366 platform_DATA += crypto.lst
367 CLEANFILES += crypto.lst
369 syminfo.lst: gensyminfo.sh kernel_syms.lst $(MODULE_FILES)
370 cat kernel_syms.lst > $@.new
371 for m in $(MODULE_FILES); do \
372 sh $< $$m >> $@.new || exit 1; \
376 # generate global module dependencies list
377 moddep.lst: syminfo.lst genmoddep.awk video.lst
378 cat $< | sort | $(AWK) -f $(srcdir)/genmoddep.awk > $@ || (rm -f $@; exit 1)
379 platform_DATA += moddep.lst
380 CLEANFILES += config.log syminfo.lst moddep.lst
382 $(MOD_FILES): %.mod : genmod.sh moddep.lst %.module$(EXEEXT)
383 TARGET_OBJ2ELF=@TARGET_OBJ2ELF@ sh $^ $@
384 platform_DATA += $(MOD_FILES)
385 platform_DATA += modinfo.sh
386 CLEANFILES += $(MOD_FILES)
388 if COND_ENABLE_EFIEMU
389 efiemu32.o: efiemu/runtime/efiemu.c $(TARGET_OBJ2ELF)
392 $(TARGET_CC) $(DEFS) $(INCLUDES) $(CPPFLAGS_EFIEMU) $(CPPFLAGS_DEFAULT) -m32 -Wall -Werror -nostdlib -static -O2 -c -o $@.bin $<
393 if test "x$(TARGET_APPLE_LINKER)" = x1; then \
394 $(TARGET_OBJCONV) -felf32 -nu -nd $@.bin $@ || exit 1; \
396 elif test ! -z "$(TARGET_OBJ2ELF)"; then \
397 $(TARGET_OBJ2ELF) $@.bin || (rm -f $@.bin; exit 1); \
403 # Link format -arch,x86_64 means Apple linker
404 efiemu64_c.o: efiemu/runtime/efiemu.c
405 $(TARGET_CC) $(DEFS) $(INCLUDES) $(CPPFLAGS_EFIEMU) $(CPPFLAGS_DEFAULT) -m64 -nostdlib -Wall -Werror -O2 -mcmodel=large -mno-red-zone -c -o $@ $<
407 efiemu64_s.o: efiemu/runtime/efiemu.S
408 $(TARGET_CC) $(DEFS) $(INCLUDES) $(CPPFLAGS_EFIEMU) $(CPPFLAGS_DEFAULT) -m64 -Wall -Werror -nostdlib -O2 -mcmodel=large -mno-red-zone -c -o $@ $<
410 efiemu64.o: efiemu64_c.o efiemu64_s.o $(TARGET_OBJ2ELEF)
413 $(TARGET_CC) -m64 $(EFIEMU64_LINK_FORMAT) -nostdlib -static -Wl,-r -o $@.bin $^
414 if test "x$(EFIEMU64_LINK_FORMAT)" = x-arch,x86_64; then \
415 $(TARGET_OBJCONV) -felf64 -nu -nd $@.bin $@ || exit 1; \
421 platform_DATA += efiemu32.o efiemu64.o
422 CLEANFILES += efiemu32.o efiemu64.o efiemu64_c.o efiemu64_s.o
425 windowsdir=$(top_builddir)/$(PACKAGE)-$(VERSION)-for-windows
426 windowsdir: $(PROGRAMS) $(starfield_DATA) $(platform_DATA)
427 test -d $(windowsdir)/$(target_cpu)-$(platform) || mkdir $(windowsdir)/$(target_cpu)-$(platform)
428 for x in $(platform_DATA); do \
429 cp -fp $$x $(windowsdir)/$(target_cpu)-$(platform)/$$x; \