1# For test target. 2TESTS = size_test 3noinst_SCRIPTS = $(TESTS) 4 5# For dist target. 6noinst_HEADERS = apic.h defs.h dir.h disk_inode.h disk_inode_ffs.h \ 7 fat.h filesys.h freebsd.h fs.h hercules.h i386-elf.h \ 8 imgact_aout.h iso9660.h jfs.h mb_header.h mb_info.h md5.h \ 9 nbi.h pc_slice.h serial.h shared.h smp-imps.h term.h \ 10 terminfo.h tparm.h nbi.h ufs.h ufs2.h vstafs.h xfs.h graphics.h \ 11 fsys_zfs.h 12EXTRA_DIST = setjmp.S apm.S $(noinst_SCRIPTS) 13 14# For <stage1.h>. 15INCLUDES = -I$(top_srcdir)/stage1 16 17# The library for /sbin/grub. 18noinst_LIBRARIES = libgrub.a 19libgrub_a_SOURCES = boot.c builtins.c char_io.c cmdline.c common.c \ 20 disk_io.c fsys_ext2fs.c fsys_fat.c fsys_ffs.c fsys_iso9660.c \ 21 fsys_jfs.c fsys_minix.c fsys_reiserfs.c fsys_ufs.c fsys_ufs2.c \ 22 fsys_zfs.c zfs_fletcher.c zfs_lzjb.c zfs_lz4.c zfs_sha256.c \ 23 fsys_vstafs.c fsys_xfs.c gunzip.c md5.c serial.c stage2.c \ 24 terminfo.c tparm.c graphics.c 25libgrub_a_CFLAGS = $(GRUB_CFLAGS) -I$(top_srcdir)/lib \ 26 -DGRUB_UTIL=1 -DFSYS_EXT2FS=1 -DFSYS_FAT=1 -DFSYS_FFS=1 \ 27 -DFSYS_ISO9660=1 -DFSYS_JFS=1 -DFSYS_MINIX=1 -DFSYS_REISERFS=1 \ 28 -DFSYS_UFS=1 -DFSYS_UFS2=1 -DFSYS_ZFS=1 -DFSYS_VSTAFS=1 -DFSYS_XFS=1 \ 29 -DUSE_MD5_PASSWORDS=1 -DSUPPORT_SERIAL=1 -DSUPPORT_HERCULES=1 \ 30 31# Stage 2 and Stage 1.5's. 32pkglibdir = $(libdir)/$(PACKAGE)/$(host_cpu)-$(host_vendor) 33 34EXTRA_PROGRAMS = nbloader.exec pxeloader.exec diskless.exec 35 36if DISKLESS_SUPPORT 37pkglib_DATA = stage2 stage2_eltorito e2fs_stage1_5 fat_stage1_5 \ 38 ffs_stage1_5 iso9660_stage1_5 jfs_stage1_5 minix_stage1_5 \ 39 reiserfs_stage1_5 ufs_stage1_5 ufs2_stage1_5 zfs_stage1_5 vstafs_stage1_5 \ 40 xfs_stage1_5 nbgrub pxegrub 41noinst_DATA = pre_stage2 start start_eltorito nbloader pxeloader diskless 42noinst_PROGRAMS = pre_stage2.exec start.exec start_eltorito.exec \ 43 e2fs_stage1_5.exec fat_stage1_5.exec ffs_stage1_5.exec \ 44 iso9660_stage1_5.exec jfs_stage1_5.exec minix_stage1_5.exec \ 45 reiserfs_stage1_5.exec ufs_stage1_5.exec ufs2_stage1_5.exec \ 46 zfs_stage1_5.exec \ 47 vstafs_stage1_5.exec xfs_stage1_5.exec \ 48 nbloader.exec pxeloader.exec diskless.exec 49else 50pkglib_DATA = stage2 stage2_eltorito e2fs_stage1_5 fat_stage1_5 \ 51 ffs_stage1_5 iso9660_stage1_5 jfs_stage1_5 minix_stage1_5 \ 52 reiserfs_stage1_5 ufs_stage1_5 ufs2_stage1_5 zfs_stage1_5 vstafs_stage1_5 \ 53 xfs_stage1_5 54noinst_DATA = pre_stage2 start start_eltorito 55noinst_PROGRAMS = pre_stage2.exec start.exec start_eltorito.exec \ 56 e2fs_stage1_5.exec fat_stage1_5.exec ffs_stage1_5.exec \ 57 iso9660_stage1_5.exec jfs_stage1_5.exec minix_stage1_5.exec \ 58 reiserfs_stage1_5.exec ufs_stage1_5.exec ufs2_stage1_5.exec \ 59 zfs_stage1_5.exec vstafs_stage1_5.exec xfs_stage1_5.exec 60endif 61MOSTLYCLEANFILES = $(noinst_PROGRAMS) 62 63PRE_STAGE2_LINK = -nostdlib -Wl,-N -Wl,-Ttext -Wl,8200 64START_LINK = -nostdlib -Wl,-N -Wl,-Ttext -Wl,8000 65NBLOADER_LINK = -nostdlib -Wl,-N -Wl,-Ttext -Wl,0 66PXELOADER_LINK = -nostdlib -Wl,-N -Wl,-Ttext -Wl,7C00 67START_ELTORITO_LINK = -nostdlib -Wl,-N -Wl,-Ttext -Wl,7C00 68 69if NETBOOT_SUPPORT 70NETBOOT_FLAGS = -I$(top_srcdir)/netboot -DSUPPORT_NETBOOT=1 71else 72NETBOOT_FLAGS = 73endif 74 75if SERIAL_SUPPORT 76SERIAL_FLAGS = -DSUPPORT_SERIAL=1 77else 78SERIAL_FLAGS = 79endif 80 81if HERCULES_SUPPORT 82HERCULES_FLAGS = -DSUPPORT_HERCULES=1 83else 84HERCULES_FLAGS = 85endif 86 87if GRAPHICS_SUPPORT 88GRAPHICS_FLAGS = -DSUPPORT_GRAPHICS=1 89else 90GRAPHICS_FLAGS = 91endif 92 93STAGE2_COMPILE = $(STAGE2_CFLAGS) -fno-builtin -nostdinc \ 94 $(NETBOOT_FLAGS) $(SERIAL_FLAGS) $(HERCULES_FLAGS) $(GRAPHICS_FLAGS) 95 96STAGE1_5_LINK = -nostdlib -Wl,-N -Wl,-Ttext -Wl,2000 97STAGE1_5_COMPILE = $(STAGE2_COMPILE) -DNO_DECOMPRESSION=1 -DSTAGE1_5=1 98 99# For stage2 target. 100pre_stage2_exec_SOURCES = asm.S bios.c boot.c builtins.c char_io.c \ 101 cmdline.c common.c console.c disk_io.c fsys_ext2fs.c \ 102 fsys_fat.c fsys_ffs.c fsys_iso9660.c fsys_jfs.c fsys_minix.c \ 103 fsys_reiserfs.c fsys_ufs.c fsys_ufs2.c fsys_vstafs.c fsys_xfs.c \ 104 fsys_zfs.c zfs_fletcher.c zfs_lzjb.c zfs_lz4.c zfs_sha256.c \ 105 gunzip.c hercules.c md5.c serial.c smp-imps.c stage2.c terminfo.c \ 106 tparm.c graphics.c 107pre_stage2_exec_CFLAGS = $(STAGE2_COMPILE) $(FSYS_CFLAGS) 108pre_stage2_exec_CCASFLAGS = $(STAGE2_COMPILE) $(FSYS_CFLAGS) 109pre_stage2_exec_LDFLAGS = $(PRE_STAGE2_LINK) 110 111if NETBOOT_SUPPORT 112pre_stage2_exec_LDADD = ../netboot/libdrivers.a 113endif 114 115if DISKLESS_SUPPORT 116BUILT_SOURCES = stage2_size.h diskless_size.h 117else 118BUILT_SOURCES = stage2_size.h 119endif 120 121CLEANFILES = $(pkglib_DATA) $(noinst_DATA) $(BUILT_SOURCES) 122 123stage2_size.h: pre_stage2 124 -rm -f stage2_size.h 125 set dummy `ls -l pre_stage2`; \ 126 echo "#define STAGE2_SIZE $$6" > stage2_size.h 127 128start_exec_SOURCES = start.S 129start_exec_CCASFLAGS = $(STAGE2_COMPILE) 130start_exec_LDFLAGS = $(START_LINK) 131 132# XXX: automake doesn't provide a way to specify dependencies for object 133# files explicitly, so we must write this by a general Makefile scheme. 134# If automake change the naming scheme for per-executable objects, this 135# will be broken. 136start_exec-start.$(OBJEXT): stage2_size.h 137 138stage2: pre_stage2 start 139 -rm -f stage2 140 cat start pre_stage2 > stage2 141 142start_eltorito_exec_SOURCES = start_eltorito.S 143start_eltorito_exec_CCASFLAGS = $(STAGE2_COMPILE) 144start_eltorito_exec_LDFLAGS = $(START_ELTORITO_LINK) 145 146start_eltorito_exec-start.$(OBJEXT): stage2_size.h 147 148stage2_eltorito: pre_stage2 start_eltorito 149 -rm -f stage2_eltorito 150 cat start_eltorito pre_stage2 > stage2_eltorito 151 152# For e2fs_stage1_5 target. 153e2fs_stage1_5_exec_SOURCES = start.S asm.S common.c char_io.c disk_io.c \ 154 stage1_5.c fsys_ext2fs.c bios.c 155e2fs_stage1_5_exec_CFLAGS = $(STAGE1_5_COMPILE) -DFSYS_EXT2FS=1 \ 156 -DNO_BLOCK_FILES=1 157e2fs_stage1_5_exec_CCASFLAGS = $(STAGE1_5_COMPILE) -DFSYS_EXT2FS=1 \ 158 -DNO_BLOCK_FILES=1 159e2fs_stage1_5_exec_LDFLAGS = $(STAGE1_5_LINK) 160 161# For fat_stage1_5 target. 162fat_stage1_5_exec_SOURCES = start.S asm.S common.c char_io.c disk_io.c \ 163 stage1_5.c fsys_fat.c bios.c 164fat_stage1_5_exec_CFLAGS = $(STAGE1_5_COMPILE) -DFSYS_FAT=1 \ 165 -DNO_BLOCK_FILES=1 166fat_stage1_5_exec_CCASFLAGS = $(STAGE1_5_COMPILE) -DFSYS_FAT=1 \ 167 -DNO_BLOCK_FILES=1 168fat_stage1_5_exec_LDFLAGS = $(STAGE1_5_LINK) 169 170# For ffs_stage1_5 target. 171ffs_stage1_5_exec_SOURCES = start.S asm.S common.c char_io.c disk_io.c \ 172 stage1_5.c fsys_ffs.c bios.c 173ffs_stage1_5_exec_CFLAGS = $(STAGE1_5_COMPILE) -DFSYS_FFS=1 \ 174 -DNO_BLOCK_FILES=1 175ffs_stage1_5_exec_CCASFLAGS = $(STAGE1_5_COMPILE) -DFSYS_FFS=1 \ 176 -DNO_BLOCK_FILES=1 177ffs_stage1_5_exec_LDFLAGS = $(STAGE1_5_LINK) 178 179# For ufs_stage1_5 target. 180ufs_stage1_5_exec_SOURCES = start.S asm.S common.c char_io.c disk_io.c \ 181 stage1_5.c fsys_ufs.c bios.c 182ufs_stage1_5_exec_CFLAGS = $(STAGE1_5_COMPILE) -DFSYS_UFS=1 \ 183 -DNO_BLOCK_FILES=1 184ufs_stage1_5_exec_CCASFLAGS = $(STAGE1_5_COMPILE) -DFSYS_UFS=1 \ 185 -DNO_BLOCK_FILES=1 186ufs_stage1_5_exec_LDFLAGS = $(STAGE1_5_LINK) 187 188# For ufs2_stage1_5 target. 189ufs2_stage1_5_exec_SOURCES = start.S asm.S common.c char_io.c disk_io.c \ 190 stage1_5.c fsys_ufs2.c bios.c 191ufs2_stage1_5_exec_CFLAGS = $(STAGE1_5_COMPILE) -DFSYS_UFS2=1 \ 192 -DNO_BLOCK_FILES=1 193ufs2_stage1_5_exec_CCASFLAGS = $(STAGE1_5_COMPILE) -DFSYS_UFS2=1 \ 194 -DNO_BLOCK_FILES=1 195ufs2_stage1_5_exec_LDFLAGS = $(STAGE1_5_LINK) 196 197# For zfs_stage1_5 target. 198zfs_stage1_5_exec_SOURCES = start.S asm.S common.c char_io.c disk_io.c \ 199 stage1_5.c fsys_zfs.c zfs_fletcher.c zfs_lzjb.c zfs_lz4.c \ 200 zfs_sha256.c bios.c 201zfs_stage1_5_exec_CFLAGS = $(STAGE1_5_COMPILE) -DFSYS_ZFS=1 \ 202 -DNO_BLOCK_FILES=1 203zfs_stage1_5_exec_CCASFLAGS = $(STAGE1_5_COMPILE) -DFSYS_ZFS=1 \ 204 -DNO_BLOCK_FILES=1 205zfs_stage1_5_exec_LDFLAGS = $(STAGE1_5_LINK) 206 207# For minix_stage1_5 target. 208minix_stage1_5_exec_SOURCES = start.S asm.S common.c char_io.c disk_io.c \ 209 stage1_5.c fsys_minix.c bios.c 210minix_stage1_5_exec_CFLAGS = $(STAGE1_5_COMPILE) -DFSYS_MINIX=1 \ 211 -DNO_BLOCK_FILES=1 212minix_stage1_5_exec_CCASFLAGS = $(STAGE1_5_COMPILE) -DFSYS_MINIX=1 \ 213 -DNO_BLOCK_FILES=1 214minix_stage1_5_exec_LDFLAGS = $(STAGE1_5_LINK) 215 216# For reiserfs_stage1_5 target. 217reiserfs_stage1_5_exec_SOURCES = start.S asm.S common.c char_io.c \ 218 disk_io.c stage1_5.c fsys_reiserfs.c bios.c 219reiserfs_stage1_5_exec_CFLAGS = $(STAGE1_5_COMPILE) -DFSYS_REISERFS=1 \ 220 -DNO_BLOCK_FILES=1 221reiserfs_stage1_5_exec_CCASFLAGS = $(STAGE1_5_COMPILE) -DFSYS_REISERFS=1 \ 222 -DNO_BLOCK_FILES=1 223reiserfs_stage1_5_exec_LDFLAGS = $(STAGE1_5_LINK) 224 225# For vstafs_stage1_5 target. 226vstafs_stage1_5_exec_SOURCES = start.S asm.S common.c char_io.c \ 227 disk_io.c stage1_5.c fsys_vstafs.c bios.c 228vstafs_stage1_5_exec_CFLAGS = $(STAGE1_5_COMPILE) -DFSYS_VSTAFS=1 \ 229 -DNO_BLOCK_FILES=1 230vstafs_stage1_5_exec_CCASFLAGS = $(STAGE1_5_COMPILE) -DFSYS_VSTAFS=1 \ 231 -DNO_BLOCK_FILES=1 232vstafs_stage1_5_exec_LDFLAGS = $(STAGE1_5_LINK) 233 234# For jfs_stage1_5 target. 235jfs_stage1_5_exec_SOURCES = start.S asm.S common.c char_io.c \ 236 disk_io.c stage1_5.c fsys_jfs.c bios.c 237jfs_stage1_5_exec_CFLAGS = $(STAGE1_5_COMPILE) -DFSYS_JFS=1 \ 238 -DNO_BLOCK_FILES=1 239jfs_stage1_5_exec_CCASFLAGS = $(STAGE1_5_COMPILE) -DFSYS_JFS=1 \ 240 -DNO_BLOCK_FILES=1 241jfs_stage1_5_exec_LDFLAGS = $(STAGE1_5_LINK) 242 243# For xfs_stage1_5 target. 244xfs_stage1_5_exec_SOURCES = start.S asm.S common.c char_io.c \ 245 disk_io.c stage1_5.c fsys_xfs.c bios.c 246xfs_stage1_5_exec_CFLAGS = $(STAGE1_5_COMPILE) -DFSYS_XFS=1 \ 247 -DNO_BLOCK_FILES=1 248xfs_stage1_5_exec_CCASFLAGS = $(STAGE1_5_COMPILE) -DFSYS_XFS=1 \ 249 -DNO_BLOCK_FILES=1 250xfs_stage1_5_exec_LDFLAGS = $(STAGE1_5_LINK) 251 252# For iso9660_stage1_5 target. 253iso9660_stage1_5_exec_SOURCES = start_eltorito.S asm.S common.c char_io.c \ 254 disk_io.c stage1_5.c fsys_iso9660.c bios.c 255iso9660_stage1_5_exec_CFLAGS = $(STAGE1_5_COMPILE) -DFSYS_ISO9660=1 \ 256 -DNO_BLOCK_FILES=1 257iso9660_stage1_5_exec_CCASFLAGS = $(STAGE1_5_COMPILE) -DFSYS_ISO9660=1 \ 258 -DNO_BLOCK_FILES=1 259iso9660_stage1_5_exec_LDFLAGS = $(STAGE1_5_LINK) 260 261# For diskless target. 262diskless_exec_SOURCES = $(pre_stage2_exec_SOURCES) 263diskless_exec_CFLAGS = $(STAGE2_COMPILE) $(FSYS_CFLAGS) \ 264 -DSUPPORT_DISKLESS=1 265diskless_exec_CCASFLAGS = $(STAGE2_COMPILE) $(FSYS_CFLAGS) \ 266 -DSUPPORT_DISKLESS=1 267diskless_exec_LDFLAGS = $(PRE_STAGE2_LINK) 268diskless_exec_LDADD = ../netboot/libdrivers.a 269 270diskless_size.h: diskless 271 -rm -f $@ 272 set dummy `ls -l $^`; \ 273 echo "#define DISKLESS_SIZE $$6" > $@ 274 275# For nbloader target. 276nbloader_exec_SOURCES = nbloader.S 277nbloader_exec_CCASFLAGS = $(STAGE2_COMPILE) 278nbloader_exec_LDFLAGS = $(NBLOADER_LINK) 279 280# XXX: See the comment for start_exec-start.o. 281nbloader_exec-nbloader.$(OBJEXT): diskless_size.h 282 283# For nbgrub target. 284nbgrub: nbloader diskless 285 -rm -f $@ 286 cat $^ > $@ 287 288# For pxeloader target. 289pxeloader_exec_SOURCES = pxeloader.S 290pxeloader_exec_CCASFLAGS = $(STAGE2_COMPILE) 291pxeloader_exec_LDFLAGS = $(PXELOADER_LINK) 292 293# XXX: See the comment for start_exec-start.o. 294pxeloader_exec-pxeloader.$(OBJEXT): diskless_size.h 295 296# For pxegrub target. 297pxegrub: pxeloader diskless 298 -rm -f $@ 299 cat $^ > $@ 300 301# General rule for making a raw binary. 302SUFFIXES = .exec 303.exec: 304 $(OBJCOPY) -O binary $< $@ 305