Makefile.am 18.2 KB
Newer Older
1
AUTOMAKE_OPTIONS = subdir-objects -Wno-portability
2

BVK Chaitanya's avatar
BVK Chaitanya committed
3
DEPDIR=.deps-core
4

5
include $(top_srcdir)/conf/Makefile.common
6

7 8 9
CC=$(TARGET_CC)
CPP=$(TARGET_CC)
CCAS=$(TARGET_CC)
10 11
RANLIB=$(TARGET_RANLIB)
STRIP=$(TARGET_STRIP)
12

13 14
MACHO2IMG=$(top_builddir)/grub-macho2img

15 16 17 18
AM_CFLAGS = $(TARGET_CFLAGS)
AM_LDFLAGS = $(TARGET_LDFLAGS)
AM_CPPFLAGS = $(TARGET_CPPFLAGS) $(CPPFLAGS_DEFAULT)
AM_CCASFLAGS = $(TARGET_CCASFLAGS) $(CCASFLAGS_DEFAULT)
19

20 21 22 23
CFLAGS_PROGRAM += $(CFLAGS_PLATFORM)
LDFLAGS_PROGRAM += $(LDFLAGS_PLATFORM)
CPPFLAGS_PROGRAM += $(CPPFLAGS_PLATFORM)
CCASFLAGS_PROGRAM += $(CCASFLAGS_PLATFORM)
24

25 26 27
CFLAGS_LIBRARY += $(CFLAGS_PLATFORM) -fno-builtin
CPPFLAGS_LIBRARY += $(CPPFLAGS_PLATFORM)
CCASFLAGS_LIBRARY += $(CCASFLAGS_PLATFORM)
28

29
build-grub-pep2elf$(BUILD_EXEEXT): $(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) $(BUILD_LDFLAGS) -DGRUB_BUILD=1 -DGRUB_TARGET_WORDSIZE=64 -DGRUB_UTIL=1 -DGRUB_BUILD_PROGRAM_NAME=\"build-grub-pep2elf\" $^
31
CLEANFILES += build-grub-pep2elf$(BUILD_EXEEXT)
32

33
build-grub-pe2elf$(BUILD_EXEEXT): $(top_srcdir)/util/grub-pe2elf.c $(top_srcdir)/grub-core/kern/emu/misc.c $(top_srcdir)/util/misc.c
34
	$(BUILD_CC) -o $@ -I$(top_srcdir)/include $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $(BUILD_LDFLAGS) -DGRUB_BUILD=1 -DGRUB_TARGET_WORDSIZE=32 -DGRUB_UTIL=1 -DGRUB_BUILD_PROGRAM_NAME=\"build-grub-pe2elf\" $^
35
CLEANFILES += build-grub-pe2elf$(BUILD_EXEEXT)
36

37
# gentrigtables
38
gentrigtables$(BUILD_EXEEXT): gentrigtables.c
39
	$(BUILD_CC) -o $@ -I$(top_srcdir)/include $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $(BUILD_LDFLAGS) $< $(BUILD_LIBM)
40
CLEANFILES += gentrigtables$(BUILD_EXEEXT)
41

42 43 44 45
build-grub-module-verifier$(BUILD_EXEEXT): $(top_srcdir)/util/grub-module-verifier.c $(top_srcdir)/util/grub-module-verifier32.c $(top_srcdir)/util/grub-module-verifier64.c $(top_srcdir)/grub-core/kern/emu/misc.c $(top_srcdir)/util/misc.c
	$(BUILD_CC) -o $@ -I$(top_srcdir)/include $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $(BUILD_LDFLAGS) -DGRUB_BUILD=1 -DGRUB_UTIL=1 -DGRUB_BUILD_PROGRAM_NAME=\"build-grub-module-verifier\" $^
CLEANFILES += build-grub-module-verifier$(BUILD_EXEEXT)

46
# trigtables.c
47 48
trigtables.c: gentrigtables$(BUILD_EXEEXT) gentrigtables.c $(top_srcdir)/configure.ac
	./gentrigtables$(BUILD_EXEEXT) > $@
49 50 51
CLEANFILES += trigtables.c

# XXX Use Automake's LEX & YACC support
52 53
grub_script.tab.h: script/parser.y
	$(YACC) -d -p grub_script_yy -b grub_script $<
BVK Chaitanya's avatar
BVK Chaitanya committed
54
grub_script.tab.c: grub_script.tab.h
55 56 57
CLEANFILES += grub_script.tab.c grub_script.tab.h

# For the lexer.
58 59
grub_script.yy.h: script/yylex.l
	$(LEX) -o grub_script.yy.c --header-file=grub_script.yy.h $<
BVK Chaitanya's avatar
BVK Chaitanya committed
60
grub_script.yy.c: grub_script.yy.h
61

62
rs_decoder.h: $(srcdir)/lib/reed_solomon.c
63
	$(TARGET_CC) $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) -Os -I$(top_builddir) -S -DSTANDALONE -o $@ $< -g0 -mregparm=3 -ffreestanding
64

65 66
CLEANFILES += grub_script.yy.c grub_script.yy.h

67
include $(srcdir)/Makefile.core.am
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82

KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/cache.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/command.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/device.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/disk.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/dl.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/env.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/env_private.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/err.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/file.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/fs.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i18n.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/kernel.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/list.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/misc.h
83 84 85 86 87
if COND_emu
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/compiler-rt-emu.h
else
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/compiler-rt.h
endif
88 89 90 91 92
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/mm.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/parser.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/partition.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/term.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/time.h
93
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/mm_private.h
94
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/net.h
95
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/memory.h
96 97

if COND_i386_pc
98 99
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/kernel.h
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/pxe.h
100
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/int.h
101
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/tsc.h
102 103
endif

104 105 106 107 108 109 110 111 112 113 114 115
if COND_i386_xen_pvh
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/kernel.h
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/int.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/tsc.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/terminfo.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/extcmd.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/loader.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/lib/arg.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/xen.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/xen/hypercall.h
endif

116
if COND_i386_efi
117
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/kernel.h
118 119
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/efi.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/disk.h
120
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/tsc.h
121
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/acpi.h
122
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/pci.h
123
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/pmtimer.h
124 125 126
endif

if COND_i386_coreboot
127
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/kernel.h
128
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/tsc.h
129
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/coreboot/lbio.h
130 131 132 133 134
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/video.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/video_fb.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/gfxterm.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/font.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/bufio.h
135
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/acpi.h
136 137 138
endif

if COND_i386_multiboot
139
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/kernel.h
140
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/tsc.h
141
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/acpi.h
142 143 144 145
endif

if COND_i386_qemu
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/pci.h
146
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/tsc.h
147 148 149
endif

if COND_i386_ieee1275
150
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/kernel.h
151 152
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/ieee1275/ieee1275.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/terminfo.h
153 154
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/extcmd.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/lib/arg.h
155
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/tsc.h
156 157
endif

158
if COND_i386_xen
159
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/kernel.h
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/xen.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/xen/hypercall.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/terminfo.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/extcmd.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/lib/arg.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/loader.h
endif

if COND_x86_64_xen
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/xen.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/x86_64/xen/hypercall.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/terminfo.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/extcmd.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/lib/arg.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/loader.h
endif

177
if COND_x86_64_efi
178
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/kernel.h
179 180
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/efi.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/disk.h
181
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/tsc.h
182
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/pci.h
183
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/acpi.h
184
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/pmtimer.h
185 186
endif

187 188 189
if COND_ia64_efi
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/efi.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/disk.h
190
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/acpi.h
191 192
endif

193 194 195 196 197 198 199
if COND_mips
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/cpu/kernel.h
endif

if COND_mips_arc
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/extcmd.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/arc/arc.h
200
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/terminfo.h
201 202
endif

203
if COND_mips_qemu_mips
204 205 206 207 208
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/keyboard_layouts.h
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/kernel.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/serial.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/loader.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/terminfo.h
209
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/extcmd.h
210
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/lib/arg.h
211 212
endif

213
if COND_mips_loongson
214
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/keyboard_layouts.h
215
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/kernel.h
216
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/time.h
217
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/video.h
218
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/video_fb.h
219 220 221 222 223 224
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/gfxterm.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/font.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/bufio.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/pci.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/cs5536.h
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/pci.h
225
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/serial.h
226
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/loader.h
227 228 229
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/terminfo.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/extcmd.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/lib/arg.h
230 231
endif

232 233 234 235 236
if COND_mips_qemu_mips
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/memory.h
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/kernel.h
endif

237 238
if COND_powerpc_ieee1275
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/ieee1275/ieee1275.h
239 240 241
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/terminfo.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/extcmd.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/lib/arg.h
242 243 244 245 246
endif

if COND_sparc64_ieee1275
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/ieee1275/ieee1275.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/sparc64/ieee1275/ieee1275.h
247 248 249
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/terminfo.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/extcmd.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/lib/arg.h
250 251
endif

252 253 254 255 256
if COND_arm_uboot
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/uboot/uboot.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/uboot/disk.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/extcmd.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/lib/arg.h
257
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/arm/system.h
258 259 260 261 262
endif

if COND_arm_efi
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/efi.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/disk.h
263
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/arm/system.h
264
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/acpi.h
265 266
endif

267 268 269
if COND_arm64_efi
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/efi.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/disk.h
270
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/acpi.h
271 272
endif

273 274 275
if COND_emu
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/datetime.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/emu/misc.h
276
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/emu/net.h
277
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/emu/hostdisk.h
278
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/emu/hostfile.h
279
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/extcmd.h
280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302
if COND_GRUB_EMU_SDL
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/sdl.h
endif
if COND_GRUB_EMU_PCI
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/libpciaccess.h
endif
endif

symlist.h: $(top_builddir)/config.h $(KERNEL_HEADER_FILES)
	@list='$^'; \
	for p in $$list; do \
	  echo "#include <$$p>" >> $@ || (rm -f $@; exit 1); \
	done
CLEANFILES += symlist.h
BUILT_SOURCES += symlist.h

symlist.c: symlist.h gensymlist.sh
	$(TARGET_CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS_KERNEL) $(CPPFLAGS) -DGRUB_SYMBOL_GENERATOR=1 symlist.h > symlist.p || (rm -f symlist.p; exit 1)
	cat symlist.p | /bin/sh $(srcdir)/gensymlist.sh $(top_builddir)/config.h $(KERNEL_HEADER_FILES) >$@ || (rm -f $@; exit 1)
	rm -f symlist.p
CLEANFILES += symlist.c
BUILT_SOURCES += symlist.c

303
if COND_HAVE_ASM_USCORE
304
ASM_PREFIX=_
305 306 307 308
else
ASM_PREFIX=
endif

309
noinst_DATA += kernel_syms.lst
310

311 312 313
kernel_syms.lst: $(KERNEL_HEADER_FILES) $(top_builddir)/config.h
	$(TARGET_CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS_KERNEL) $(CPPFLAGS) $(CFLAGS) -DGRUB_SYMBOL_GENERATOR=1 $^ >kernel_syms.input
	cat kernel_syms.input | grep -v '^#' | sed -n \
314 315
	  -e '/EXPORT_FUNC *([a-zA-Z0-9_]*)/{s/.*EXPORT_FUNC *(\([a-zA-Z0-9_]*\)).*/defined kernel '"$(ASM_PREFIX)"'\1/;p;}' \
	  -e '/EXPORT_VAR *([a-zA-Z0-9_]*)/{s/.*EXPORT_VAR *(\([a-zA-Z0-9_]*\)).*/defined kernel '"$(ASM_PREFIX)"'\1/;p;}' \
316 317 318 319 320 321 322 323 324 325
	  | sort -u >$@
	rm -f kernel_syms.input
CLEANFILES += kernel_syms.lst

if COND_emu
kern/emu/grub_emu-main.$(OBJEXT):grub_emu_init.h
grub_emu-grub_emu_init.$(OBJEXT):grub_emu_init.h
kern/emu/grub_emu_dyn-main.$(OBJEXT):grub_emu_init.h
grub_emu_dyn-grub_emu_init.$(OBJEXT):grub_emu_init.h

326 327
grub_emu_init.h: genemuinitheader.sh $(MODULE_FILES)
	rm -f $@; echo $(MODULE_FILES) | sh $(srcdir)/genemuinitheader.sh $(TARGET_NM) > $@
328 329
CLEANFILES += grub_emu_init.h

330 331
grub_emu_init.c: grub_emu_init.h genemuinit.sh $(MODULE_FILES)
	rm -f $@; echo $(MODULE_FILES) | sh $(srcdir)/genemuinit.sh $(TARGET_NM) > $@
332 333
CLEANFILES += grub_emu_init.c
endif
334

335
# List files
336

337
fs.lst: $(MARKER_FILES)
338
	(for pp in $^; do \
339 340
	  b=`basename $$pp .marker`; \
	  if grep 'FS_LIST_MARKER' $$pp >/dev/null 2>&1; then \
341 342 343
	    echo $$b; \
	  fi; \
	done) | sort -u > $@
344
platform_DATA += fs.lst
345 346
CLEANFILES += fs.lst

347
command.lst: $(MARKER_FILES)
348
	(for pp in $^; do \
349 350 351
	  b=`basename $$pp .marker`; \
	  sed -n \
	    -e "/EXTCOMMAND_LIST_MARKER *( *\"/{s/.*( *\"\([^\"]*\)\".*/*\1: $$b/;p;}" \
352 353
	    -e "/P1COMMAND_LIST_MARKER *( *\"/{s/.*( *\"\([^\"]*\)\".*/*\1: $$b/;p;}" \
	    -e "/COMMAND_LIST_MARKER *( *\"/{s/.*( *\"\([^\"]*\)\".*/\1: $$b/;p;}" $$pp; \
354 355
	done) | sort -u > $@
platform_DATA += command.lst
356 357
CLEANFILES += command.lst

358
partmap.lst: $(MARKER_FILES)
359
	(for pp in $^; do \
360 361
	  b=`basename $$pp .marker`; \
	  if grep 'PARTMAP_LIST_MARKER' $$pp >/dev/null 2>&1; then \
362 363 364 365
	    echo $$b; \
	  fi; \
	done) | sort -u > $@
platform_DATA += partmap.lst
366 367
CLEANFILES += partmap.lst

368
terminal.lst: $(MARKER_FILES)
369
	(for pp in $^; do \
370 371 372 373
	  b=`basename $$pp .marker`; \
	  sed -n \
	    -e "/INPUT_TERMINAL_LIST_MARKER *( *\"/{s/.*( *\"\([^\"]*\)\".*/i\1: $$b/;p;}" \
	    -e "/OUTPUT_TERMINAL_LIST_MARKER *( *\"/{s/.*( *\"\([^\"]*\)\".*/o\1: $$b/;p;}" $$pp; \
374 375
	done) | sort -u > $@
platform_DATA += terminal.lst
376 377
CLEANFILES += terminal.lst

378
parttool.lst: $(MARKER_FILES)
379
	(for pp in $^; do \
380 381 382
	  b=`basename $$pp .marker`; \
	  sed -n \
	    -e "/PARTTOOL_LIST_MARKER *( *\"/{s/.*( *\"\([^\"]*\)\".*/\1: $$b/;p;}" $$pp; \
383 384
	done) | sort -u > $@
platform_DATA += parttool.lst
385 386
CLEANFILES += parttool.lst

387
video.lst: $(MARKER_FILES)
388
	(for pp in $^; do \
389 390
	  b=`basename $$pp .marker`; \
	  if grep 'VIDEO_LIST_MARKER' $$pp >/dev/null 2>&1; then \
391 392 393 394
	    echo $$b; \
	  fi; \
	done) | sort -u > $@
platform_DATA += video.lst
395
CLEANFILES += video.lst
396 397

# but, crypto.lst is simply copied
398
crypto.lst: $(srcdir)/lib/libgcrypt-grub/cipher/crypto.lst
399
	cp $^ $@
400
platform_DATA += crypto.lst
401
CLEANFILES += crypto.lst
402

403 404 405 406 407 408
syminfo.lst: gensyminfo.sh kernel_syms.lst $(MODULE_FILES)
	cat kernel_syms.lst > $@.new
	for m in $(MODULE_FILES); do \
	  sh $< $$m >> $@.new || exit 1; \
	done
	mv $@.new $@
409

410
# generate global module dependencies list
411
moddep.lst: syminfo.lst genmoddep.awk video.lst
412
	cat $< | sort | $(AWK) -f $(srcdir)/genmoddep.awk > $@ || (rm -f $@; exit 1)
413
platform_DATA += moddep.lst
BVK Chaitanya's avatar
BVK Chaitanya committed
414
CLEANFILES += config.log syminfo.lst moddep.lst
415

416
$(MOD_FILES): %.mod : genmod.sh moddep.lst %.module$(EXEEXT) build-grub-module-verifier$(BUILD_EXEEXT)
417
	TARGET_OBJ2ELF=@TARGET_OBJ2ELF@ sh $^ $@
418
platform_DATA += $(MOD_FILES)
419
platform_DATA += modinfo.sh
420
CLEANFILES += $(MOD_FILES)
421 422 423

if COND_ENABLE_EFIEMU
efiemu32.o: efiemu/runtime/efiemu.c $(TARGET_OBJ2ELF)
424 425 426
	-rm -f $@
	-rm -f $@.bin
	$(TARGET_CC) $(DEFS) $(INCLUDES) $(CPPFLAGS_EFIEMU) $(CPPFLAGS_DEFAULT) -m32 -Wall -Werror -nostdlib -static -O2 -c -o $@.bin $<
427
	if test "x$(TARGET_APPLE_LINKER)" = x1; then \
428
	  $(TARGET_OBJCONV) -felf32 -nu -nd $@.bin $@ || exit 1; \
429 430 431 432
	  rm -f $@.bin ; \
	elif test ! -z "$(TARGET_OBJ2ELF)"; then \
	  $(TARGET_OBJ2ELF) $@.bin || (rm -f $@.bin; exit 1); \
	  mv $@.bin $@ ; \
433
	else \
434
	  mv $@.bin $@ ; \
435 436
	fi

437
# Link format -arch,x86_64 means Apple linker
438
efiemu64_c.o: efiemu/runtime/efiemu.c
439
	$(TARGET_CC) $(DEFS) $(INCLUDES) $(CPPFLAGS_EFIEMU) $(CPPFLAGS_DEFAULT) -m64 -nostdlib -Wall -Werror -O2 -mcmodel=large -mno-red-zone -c -o $@ $<
440 441

efiemu64_s.o: efiemu/runtime/efiemu.S
442
	$(TARGET_CC) $(DEFS) $(INCLUDES) $(CPPFLAGS_EFIEMU) $(CPPFLAGS_DEFAULT) -m64 -Wall -Werror -nostdlib -O2 -mcmodel=large -mno-red-zone -c -o $@ $<
443 444

efiemu64.o: efiemu64_c.o efiemu64_s.o $(TARGET_OBJ2ELEF)
445 446 447
	-rm -f $@
	-rm -f $@.bin
	$(TARGET_CC) -m64 $(EFIEMU64_LINK_FORMAT) -nostdlib -static -Wl,-r -o $@.bin $^
448
	if test "x$(EFIEMU64_LINK_FORMAT)" = x-arch,x86_64; then \
449
	  $(TARGET_OBJCONV) -felf64 -nu -nd $@.bin $@ || exit 1; \
450 451
	  rm -f $@.bin; \
	else \
452
	  mv $@.bin $@ ; \
453 454 455 456 457
	fi

platform_DATA += efiemu32.o efiemu64.o
CLEANFILES += efiemu32.o efiemu64.o efiemu64_c.o efiemu64_s.o
endif
458 459 460 461 462 463 464

windowsdir=$(top_builddir)/$(PACKAGE)-$(VERSION)-for-windows
windowsdir: $(PROGRAMS) $(starfield_DATA) $(platform_DATA)
	test -d $(windowsdir)/$(target_cpu)-$(platform) || mkdir $(windowsdir)/$(target_cpu)-$(platform)
	for x in $(platform_DATA); do \
		cp -fp $$x $(windowsdir)/$(target_cpu)-$(platform)/$$x; \
	done