blob: 53a1750b8bd0717b608d2c550319cbda28fdcb05 [file] [log] [blame] [raw]
# For test target.
TESTS = size_test
noinst_SCRIPTS = $(TESTS)
# For dist target.
noinst_HEADERS = apic.h defs.h dir.h disk_inode.h disk_inode_ffs.h \
fat.h filesys.h freebsd.h fs.h i386-elf.h imgact_aout.h \
mb_header.h mb_info.h pc_slice.h serial.h shared.h smp-imps.h \
nbi.h
EXTRA_DIST = $(noinst_SCRIPTS)
# For <stage1.h>.
INCLUDES = -I$(top_srcdir)/stage1
# The library for /sbin/grub.
noinst_LIBRARIES = libgrub.a
libgrub_a_SOURCES = boot.c builtins.c common.c char_io.c cmdline.c \
disk_io.c gunzip.c fsys_ffs.c fsys_ext2fs.c fsys_fat.c \
fsys_minix.c fsys_reiserfs.c stage2.c md5.c
libgrub_a_CFLAGS = $(GRUB_CFLAGS) -I$(top_srcdir)/lib \
-DGRUB_UTIL=1 -DFSYS_EXT2FS=1 -DFSYS_FAT=1 -DFSYS_FFS=1 \
-DFSYS_MINIX=1 -DFSYS_REISERFS=1 -DSUPPORT_SERIAL \
-fwritable-strings
# Stage 2 and Stage 1.5's.
pkgdatadir = $(datadir)/$(PACKAGE)/$(host_cpu)-$(host_vendor)
EXTRA_PROGRAMS = nbloader.exec pxeloader.exec diskless.exec
if DISKLESS_SUPPORT
pkgdata_DATA = stage2 e2fs_stage1_5 fat_stage1_5 ffs_stage1_5 \
minix_stage1_5 reiserfs_stage1_5 nbgrub pxegrub
noinst_DATA = pre_stage2 start nbloader pxeloader diskless
noinst_PROGRAMS = pre_stage2.exec start.exec e2fs_stage1_5.exec \
fat_stage1_5.exec ffs_stage1_5.exec minix_stage1_5.exec \
reiserfs_stage1_5.exec nbloader.exec pxeloader.exec \
diskless.exec
else
pkgdata_DATA = stage2 e2fs_stage1_5 fat_stage1_5 ffs_stage1_5 \
minix_stage1_5 reiserfs_stage1_5
noinst_DATA = pre_stage2 start
noinst_PROGRAMS = pre_stage2.exec start.exec e2fs_stage1_5.exec \
fat_stage1_5.exec ffs_stage1_5.exec minix_stage1_5.exec \
reiserfs_stage1_5.exec
endif
MOSTLYCLEANFILES = $(noinst_PROGRAMS)
PRE_STAGE2_LINK = -nostdlib -Wl,-N -Wl,-Ttext -Wl,8200
START_LINK = -nostdlib -Wl,-N -Wl,-Ttext -Wl,8000
NBLOADER_LINK = -nostdlib -Wl,-N -Wl,-Ttext -Wl,0
PXELOADER_LINK = -nostdlib -Wl,-N -Wl,-Ttext -Wl,7C00
if NETBOOT_SUPPORT
NETBOOT_FLAGS = -I$(top_srcdir)/netboot -DSUPPORT_NETBOOT=1
else
NETBOOT_FLAGS =
endif
if SERIAL_SUPPORT
SERIAL_FLAGS = -DSUPPORT_SERIAL=1
else
SERIAL_FLAGS =
endif
STAGE2_COMPILE = $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
$(NETBOOT_FLAGS) $(SERIAL_FLAGS)
STAGE1_5_LINK = -nostdlib -Wl,-N -Wl,-Ttext -Wl,2000
STAGE1_5_COMPILE = $(STAGE2_COMPILE) -DNO_DECOMPRESSION=1 -DSTAGE1_5=1
# For stage2 target.
pre_stage2_exec_SOURCES = asm.S bios.c boot.c builtins.c common.c \
char_io.c cmdline.c disk_io.c gunzip.c fsys_ext2fs.c \
fsys_fat.c fsys_ffs.c fsys_minix.c fsys_reiserfs.c serial.c \
smp-imps.c stage2.c md5.c
pre_stage2_exec_CFLAGS = $(STAGE2_COMPILE) $(FSYS_CFLAGS)
pre_stage2_exec_LDFLAGS = $(PRE_STAGE2_LINK)
if NETBOOT_SUPPORT
pre_stage2_exec_LDADD = ../netboot/libdrivers.a
endif
if DISKLESS_SUPPORT
BUILT_SOURCES = stage2_size.h diskless_size.h
else
BUILT_SOURCES = stage2_size.h
endif
CLEANFILES = $(pkgdata_DATA) $(noinst_DATA) $(BUILT_SOURCES)
stage2_size.h: pre_stage2
-rm -f stage2_size.h
set dummy `ls -l pre_stage2`; \
echo "#define STAGE2_SIZE $$6" > stage2_size.h
start_exec_SOURCES = start.S
start_exec_CFLAGS = $(STAGE2_COMPILE)
start_exec_LDFLAGS = $(START_LINK)
# XXX: automake doesn't provide a way to specify dependencies for object
# files explicitly, so we must write this by a general Makefile scheme.
# If automake change the naming scheme for per-executable objects, this
# will be broken.
start_exec-start.o: stage2_size.h
stage2: pre_stage2 start
-rm -f stage2
cat start pre_stage2 > stage2
# For e2fs_stage1_5 target.
e2fs_stage1_5_exec_SOURCES = start.S asm.S common.c char_io.c disk_io.c \
stage1_5.c fsys_ext2fs.c bios.c
e2fs_stage1_5_exec_CFLAGS = $(STAGE1_5_COMPILE) -DFSYS_EXT2FS=1 \
-DNO_BLOCK_FILES=1
e2fs_stage1_5_exec_LDFLAGS = $(STAGE1_5_LINK)
# For fat_stage1_5 target.
fat_stage1_5_exec_SOURCES = start.S asm.S common.c char_io.c disk_io.c \
stage1_5.c fsys_fat.c bios.c
fat_stage1_5_exec_CFLAGS = $(STAGE1_5_COMPILE) -DFSYS_FAT=1 \
-DNO_BLOCK_FILES=1
fat_stage1_5_exec_LDFLAGS = $(STAGE1_5_LINK)
# For ffs_stage1_5 target.
ffs_stage1_5_exec_SOURCES = start.S asm.S common.c char_io.c disk_io.c \
stage1_5.c fsys_ffs.c bios.c
ffs_stage1_5_exec_CFLAGS = $(STAGE1_5_COMPILE) -DFSYS_FFS=1 \
-DNO_BLOCK_FILES=1
ffs_stage1_5_exec_LDFLAGS = $(STAGE1_5_LINK)
# For minix_stage1_5 target.
minix_stage1_5_exec_SOURCES = start.S asm.S common.c char_io.c disk_io.c \
stage1_5.c fsys_minix.c bios.c
minix_stage1_5_exec_CFLAGS = $(STAGE1_5_COMPILE) -DFSYS_MINIX=1 \
-DNO_BLOCK_FILES=1
minix_stage1_5_exec_LDFLAGS = $(STAGE1_5_LINK)
# For reiserfs_stage1_5 target.
reiserfs_stage1_5_exec_SOURCES = start.S asm.S common.c char_io.c \
disk_io.c stage1_5.c fsys_reiserfs.c bios.c
reiserfs_stage1_5_exec_CFLAGS = $(STAGE1_5_COMPILE) -DFSYS_REISERFS=1 \
-DNO_BLOCK_FILES=1
reiserfs_stage1_5_exec_LDFLAGS = $(STAGE1_5_LINK)
# For diskless target.
diskless_exec_SOURCES = $(pre_stage2_exec_SOURCES)
diskless_exec_CFLAGS = $(STAGE2_COMPILE) $(FSYS_CFLAGS) \
-DSUPPORT_DISKLESS=1
diskless_exec_LDFLAGS = $(PRE_STAGE2_LINK)
diskless_exec_LDADD = ../netboot/libdrivers.a
diskless_size.h: diskless
-rm -f $@
set dummy `ls -l $^`; \
echo "#define DISKLESS_SIZE $$6" > $@
# For nbloader target.
nbloader_exec_SOURCES = nbloader.S
nbloader_exec_CFLAGS = $(STAGE2_COMPILE)
nbloader_exec_LDFLAGS = $(NBLOADER_LINK)
# XXX: See the comment for start_exec-start.o.
nbloader_exec-nbloader.o: diskless_size.h
# For nbgrub target.
nbgrub: nbloader diskless
-rm -f $@
cat $^ > $@
# For pxeloader target.
pxeloader_exec_SOURCES = pxeloader.S
pxeloader_exec_CFLAGS = $(STAGE2_COMPILE)
pxeloader_exec_LDFLAGS = $(PXELOADER_LINK)
# For pxegrub target.
pxegrub: pxeloader diskless
-rm -f $@
cat $^ > $@
# General rule for making a raw binary.
%: %.exec
$(OBJCOPY) -O binary $< $@