1# -*- makefile -*- 2 3include $(MAKEDIR)/syslinux.mk 4 5# Support IA32 and x86_64 platforms with one build 6# Set up architecture specifics; for cross compilation, set ARCH as apt 7GCCOPT := $(call gcc_ok,-std=gnu99,) 8ifeq ($(ARCH),i386) 9 GCCOPT += $(call gcc_ok,-m32,) 10 GCCOPT += $(call gcc_ok,-mpreferred-stack-boundary=2,) 11 MARCH = i386 12endif 13ifeq ($(ARCH),x86_64) 14 GCCOPT += $(call gcc_ok,-m64,) 15 #let preferred-stack-boundary be default(=4) 16 MARCH = x86-64 17endif 18GCCOPT += $(call gcc_ok,-fno-stack-protector,) 19GCCOPT += $(call gcc_ok,-fwrapv,) 20GCCOPT += $(call gcc_ok,-freg-struct-return,) 21# Note -fPIE does not work with ld on x86_64, try -fPIC instead 22# Does BIOS build require -fPIE? 23GCCOPT += $(call gcc_ok,-fPIC) 24GCCOPT += $(call gcc_ok,-fno-exceptions,) 25GCCOPT += $(call gcc_ok,-fno-asynchronous-unwind-tables,) 26GCCOPT += $(call gcc_ok,-fno-strict-aliasing,) 27GCCOPT += $(call gcc_ok,-falign-functions=0,-malign-functions=0) 28GCCOPT += $(call gcc_ok,-falign-jumps=0,-malign-jumps=0) 29GCCOPT += $(call gcc_ok,-falign-labels=0,-malign-labels=0) 30GCCOPT += $(call gcc_ok,-falign-loops=0,-malign-loops=0) 31 32INCLUDE = -I$(SRC) 33STRIP = strip --strip-all -R .comment -R .note 34 35# zlib and libpng configuration flags 36LIBFLAGS = -DDYNAMIC_CRC_TABLE -DPNG_NO_CONSOLE_IO \ 37 -DPNG_NO_WRITE_SUPPORTED \ 38 -DPNG_NO_MNG_FEATURES \ 39 -DPNG_NO_READ_tIME -DPNG_NO_WRITE_tIME 40 41# We need some features in libpng which apparently aren't available in the 42# fixed-point versions. It's OK, because we have to have a non-graphical 43# fallback anyway, just use that on old machines... 44# LIBFLAGS += -DPNG_NO_FLOATING_POINT_SUPPORTED 45 46REQFLAGS = $(GCCOPT) -g -D__COM32__ -D__FIRMWARE_$(FIRMWARE)__ \ 47 -nostdinc -iwithprefix include -I. -I$(SRC)/sys \ 48 -I$(SRC)/../include -I$(com32)/include/sys \ 49 -I$(topdir)/core/include -I$(com32)/lib/ \ 50 -I$(com32)/lib/sys/module -I$(OBJ)/../.. 51OPTFLAGS = -Os -march=$(MARCH) -falign-functions=0 -falign-jumps=0 \ 52 -falign-labels=0 -ffast-math -fomit-frame-pointer 53WARNFLAGS = $(GCCWARN) -Wpointer-arith -Wwrite-strings -Wstrict-prototypes -Winline 54 55CFLAGS = $(OPTFLAGS) $(REQFLAGS) $(WARNFLAGS) $(LIBFLAGS) 56 57ifndef EFI_BUILD 58CFLAGS += -mregparm=3 -DREGPARM=3 59endif 60 61VPATH = $(SRC) 62LIBOTHER_OBJS = \ 63 atoi.o atol.o atoll.o calloc.o creat.o \ 64 fgets.o fprintf.o fputc.o \ 65 putchar.o \ 66 getopt.o getopt_long.o \ 67 lrand48.o stack.o memccpy.o memchr.o \ 68 mempcpy.o memmem.o memmove.o memswap.o \ 69 perror.o qsort.o seed48.o \ 70 srand48.o sscanf.o \ 71 strerror.o errlist.o \ 72 strnlen.o \ 73 strncat.o strndup.o \ 74 stpncpy.o \ 75 strntoimax.o strsep.o strspn.o strstr.o \ 76 strtoimax.o strtok.o strtol.o strtoll.o strtoull.o \ 77 strtoumax.o vprintf.o vsprintf.o \ 78 asprintf.o vasprintf.o \ 79 vsscanf.o \ 80 skipspace.o \ 81 chrreplace.o \ 82 bufprintf.o \ 83 inet.o dhcppack.o dhcpunpack.o \ 84 strreplace.o \ 85 lstrdup.o \ 86 \ 87 suffix_number.o \ 88 \ 89 getcwd.o fdopendir.o \ 90 \ 91 sys/line_input.o \ 92 sys/colortable.o sys/screensize.o \ 93 \ 94 sys/stdcon_read.o sys/stdcon_write.o sys/rawcon_read.o \ 95 sys/rawcon_write.o \ 96 sys/null_read.o sys/null_write.o sys/serial_write.o \ 97 \ 98 sys/xserial_write.o \ 99 \ 100 sys/ansi.o \ 101 \ 102 sys/ansicon_write.o sys/ansiserial_write.o \ 103 \ 104 pci/cfgtype.o pci/scan.o pci/bios.o \ 105 pci/readb.o pci/readw.o pci/readl.o \ 106 pci/writeb.o pci/writew.o pci/writel.o \ 107 \ 108 sys/x86_init_fpu.o math/pow.o math/strtod.o \ 109 syslinux/disk.o \ 110 \ 111 syslinux/setup_data.o 112 113## CORE OBJECTS, INCLUDED IN THE ROOT COM32 MODULE 114LIBENTRY_OBJS = \ 115 sys/intcall.o sys/farcall.o sys/cfarcall.o sys/zeroregs.o \ 116 sys/argv.o sys/sleep.o \ 117 sys/fileinfo.o sys/opendev.o sys/read.o sys/write.o sys/ftell.o \ 118 sys/close.o sys/open.o sys/fileread.o sys/fileclose.o \ 119 sys/openmem.o \ 120 sys/isatty.o sys/fstat.o \ 121 \ 122 dprintf.o vdprintf.o \ 123 \ 124 syslinux/idle.o \ 125 \ 126 exit.o 127 128LIBGCC_OBJS = \ 129 libgcc/__ashldi3.o libgcc/__udivdi3.o \ 130 libgcc/__negdi2.o libgcc/__ashrdi3.o libgcc/__lshrdi3.o \ 131 libgcc/__muldi3.o libgcc/__udivmoddi4.o libgcc/__umoddi3.o \ 132 libgcc/__divdi3.o libgcc/__moddi3.o 133 134LIBCONSOLE_OBJS = \ 135 \ 136 sys/openconsole.o sys/line_input.o \ 137 sys/colortable.o sys/screensize.o \ 138 \ 139 sys/stdcon_read.o sys/rawcon_read.o \ 140 sys/rawcon_write.o \ 141 sys/null_write.o sys/serial_write.o \ 142 \ 143 sys/xserial_write.o \ 144 \ 145 sys/ansi.o \ 146 \ 147 sys/ansicon_write.o sys/ansiserial_write.o \ 148 \ 149 syslinux/serial.o 150 151LIBLOAD_OBJS = \ 152 syslinux/addlist.o syslinux/freelist.o syslinux/memmap.o \ 153 syslinux/movebits.o syslinux/shuffle.o syslinux/shuffle_pm.o \ 154 syslinux/shuffle_rm.o syslinux/biosboot.o syslinux/zonelist.o \ 155 syslinux/dump_mmap.o syslinux/dump_movelist.o \ 156 \ 157 syslinux/run_default.o syslinux/run_command.o \ 158 syslinux/cleanup.o syslinux/localboot.o syslinux/runimage.o \ 159 \ 160 syslinux/loadfile.o syslinux/floadfile.o syslinux/zloadfile.o \ 161 \ 162 syslinux/load_linux.o syslinux/initramfs.o \ 163 syslinux/initramfs_file.o syslinux/initramfs_loadfile.o \ 164 syslinux/initramfs_archive.o 165 166LIBMODULE_OBJS = \ 167 sys/module/common.o sys/module/$(ARCH)/elf_module.o \ 168 sys/module/elfutils.o \ 169 sys/module/exec.o sys/module/elf_module.o 170 171# ZIP library object files 172LIBZLIB_OBJS = \ 173 zlib/adler32.o zlib/compress.o zlib/crc32.o \ 174 zlib/uncompr.o zlib/deflate.o zlib/trees.o zlib/zutil.o \ 175 zlib/inflate.o zlib/infback.o zlib/inftrees.o zlib/inffast.o \ 176 sys/zfile.o sys/zfopen.o 177 178MINLIBOBJS = \ 179 $(addprefix $(OBJ)/,syslinux/ipappend.o \ 180 syslinux/dsinfo.o \ 181 $(LIBOTHER_OBJS) \ 182 $(LIBGCC_OBJS) \ 183 $(LIBCONSOLE_OBJS) \ 184 $(LIBLOAD_OBJS) \ 185 $(LIBZLIB_OBJS)) 186# $(LIBVESA_OBJS) 187 188CORELIBOBJS = \ 189 memcpy.o memset.o memcmp.o printf.o strncmp.o vfprintf.o \ 190 strlen.o vsnprintf.o snprintf.o stpcpy.o strcmp.o strdup.o \ 191 strcpy.o strncpy.o setjmp.o fopen.o fread.o fread2.o puts.o \ 192 strtoul.o strntoumax.o strcasecmp.o \ 193 sprintf.o strlcat.o strchr.o strlcpy.o strncasecmp.o ctypes.o \ 194 fputs.o fwrite2.o fwrite.o fgetc.o fclose.o lmalloc.o \ 195 sys/err_read.o sys/err_write.o sys/null_read.o \ 196 sys/stdcon_write.o \ 197 syslinux/memscan.o strrchr.o strcat.o \ 198 libgcc/__ashldi3.o libgcc/__udivdi3.o \ 199 libgcc/__negdi2.o libgcc/__ashrdi3.o libgcc/__lshrdi3.o \ 200 libgcc/__muldi3.o libgcc/__udivmoddi4.o libgcc/__umoddi3.o \ 201 libgcc/__divdi3.o libgcc/__moddi3.o \ 202 syslinux/debug.o \ 203 $(LIBENTRY_OBJS) \ 204 $(LIBMODULE_OBJS) 205 206LDFLAGS = -m elf_$(ARCH) --hash-style=gnu -T $(com32)/lib/$(ARCH)/elf.ld 207 208.SUFFIXES: .c .o .a .so .lo .i .S .s .ls .ss .lss 209 210% : %.c # Cancel default rule 211 212% : %.S 213 214%.o: %.c 215 $(CC) $(MAKEDEPS) $(CFLAGS) -c -o $@ $< 216 217.c.i: 218 $(CC) $(MAKEDEPS) $(CFLAGS) -E -o $@ $< 219 220%.s: %.c 221 $(CC) $(MAKEDEPS) $(CFLAGS) -S -o $@ $< 222 223%.o: %.S 224 $(CC) $(MAKEDEPS) $(CFLAGS) -D__ASSEMBLY__ -c -o $@ $< 225 226.S.s: 227 $(CC) $(MAKEDEPS) $(CFLAGS) -D__ASSEMBLY__ -E -o $@ $< 228 229.S.lo: 230 $(CC) $(MAKEDEPS) $(CFLAGS) $(SOFLAGS) -D__ASSEMBLY__ -c -o $@ $< 231 232.S.ls: 233 $(CC) $(MAKEDEPS) $(CFLAGS) $(SOFLAGS) -D__ASSEMBLY__ -E -o $@ $< 234 235%(OBJ)/%.o: $(SRC)/%.s 236 $(CC) $(MAKEDEPS) $(CFLAGS) -x assembler -c -o $@ $< 237 238.ls.lo: 239 $(CC) $(MAKEDEPS) $(CFLAGS) $(SOFLAGS) -x assembler -c -o $@ $< 240 241.c.lo: 242 $(CC) $(MAKEDEPS) $(CFLAGS) $(SOFLAGS) -c -o $@ $< 243 244.c.ls: 245 $(CC) $(MAKEDEPS) $(CFLAGS) $(SOFLAGS) -S -o $@ $< 246 247%.c32: %.elf 248 $(OBJCOPY) --strip-debug --strip-unneeded $< $@ 249