Breaking out syslinux.efi to syslinux-efi package.
[syslinux-debian/hramrach.git] / mk / lib.mk
blobbc516c2ca29bf78d7d6bc83be6499c9236677c78
1 # -*- makefile -*-
3 include $(MAKEDIR)/syslinux.mk
5 # Support IA32 and x86_64 platforms with one build
6 # Set up architecture specifics; for cross compilation, set ARCH as apt
7 GCCOPT := $(call gcc_ok,-std=gnu99,)
8 ifeq ($(ARCH),i386)
9 GCCOPT += $(call gcc_ok,-m32,)
10 GCCOPT += $(call gcc_ok,-mpreferred-stack-boundary=2,)
11 MARCH = i386
12 endif
13 ifeq ($(ARCH),x86_64)
14 GCCOPT += $(call gcc_ok,-m64,)
15 #let preferred-stack-boundary be default(=4)
16 MARCH = x86-64
17 endif
18 GCCOPT += $(call gcc_ok,-fno-stack-protector,)
19 GCCOPT += $(call gcc_ok,-fwrapv,)
20 GCCOPT += $(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?
23 GCCOPT += $(call gcc_ok,-fPIC)
24 GCCOPT += $(call gcc_ok,-fno-exceptions,)
25 GCCOPT += $(call gcc_ok,-fno-asynchronous-unwind-tables,)
26 GCCOPT += $(call gcc_ok,-fno-strict-aliasing,)
27 GCCOPT += $(call gcc_ok,-falign-functions=0,-malign-functions=0)
28 GCCOPT += $(call gcc_ok,-falign-jumps=0,-malign-jumps=0)
29 GCCOPT += $(call gcc_ok,-falign-labels=0,-malign-labels=0)
30 GCCOPT += $(call gcc_ok,-falign-loops=0,-malign-loops=0)
32 INCLUDE = -I$(SRC)
33 STRIP = strip --strip-all -R .comment -R .note
35 # zlib and libpng configuration flags
36 LIBFLAGS = -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
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
46 REQFLAGS = $(GCCOPT) -g -D__COM32__ \
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)/../..
51 OPTFLAGS = -Os -march=$(MARCH) -falign-functions=0 -falign-jumps=0 \
52 -falign-labels=0 -ffast-math -fomit-frame-pointer
53 WARNFLAGS = $(GCCWARN) -Wpointer-arith -Wwrite-strings -Wstrict-prototypes -Winline
55 CFLAGS = $(OPTFLAGS) $(REQFLAGS) $(WARNFLAGS) $(LIBFLAGS)
57 ifndef EFI_BUILD
58 CFLAGS += -mregparm=3 -DREGPARM=3
59 endif
61 VPATH = $(SRC)
62 LIBOTHER_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 \
87 suffix_number.o \
89 getcwd.o fdopendir.o \
91 sys/line_input.o \
92 sys/colortable.o sys/screensize.o \
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 \
98 sys/xserial_write.o \
100 sys/ansi.o \
102 sys/ansicon_write.o sys/ansiserial_write.o \
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 \
108 sys/x86_init_fpu.o math/pow.o math/strtod.o \
109 syslinux/disk.o \
111 syslinux/setup_data.o
113 ## CORE OBJECTS, INCLUDED IN THE ROOT COM32 MODULE
114 LIBENTRY_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 \
122 dprintf.o vdprintf.o \
124 syslinux/idle.o \
126 exit.o
128 LIBGCC_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
134 LIBCONSOLE_OBJS = \
136 sys/openconsole.o sys/line_input.o \
137 sys/colortable.o sys/screensize.o \
139 sys/stdcon_read.o sys/rawcon_read.o \
140 sys/rawcon_write.o \
141 sys/null_write.o sys/serial_write.o \
143 sys/xserial_write.o \
145 sys/ansi.o \
147 sys/ansicon_write.o sys/ansiserial_write.o \
149 syslinux/serial.o
151 LIBLOAD_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/zonelist.o \
155 syslinux/dump_mmap.o syslinux/dump_movelist.o \
157 syslinux/run_default.o syslinux/run_command.o \
158 syslinux/cleanup.o syslinux/localboot.o syslinux/runimage.o \
160 syslinux/loadfile.o syslinux/floadfile.o syslinux/zloadfile.o \
162 syslinux/load_linux.o syslinux/initramfs.o \
163 syslinux/initramfs_file.o syslinux/initramfs_loadfile.o \
164 syslinux/initramfs_archive.o
166 LIBMODULE_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
171 # ZIP library object files
172 LIBZLIB_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
178 MINLIBOBJS = \
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)
188 CORELIBOBJS = \
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)
206 LDFLAGS = -m elf_$(ARCH) --hash-style=gnu -T $(com32)/lib/$(ARCH)/elf.ld
208 .SUFFIXES: .c .o .a .so .lo .i .S .s .ls .ss .lss
210 % : %.c # Cancel default rule
212 % : %.S
214 %.o: %.c
215 $(CC) $(MAKEDEPS) $(CFLAGS) -c -o $@ $<
217 .c.i:
218 $(CC) $(MAKEDEPS) $(CFLAGS) -E -o $@ $<
220 %.s: %.c
221 $(CC) $(MAKEDEPS) $(CFLAGS) -S -o $@ $<
223 %.o: %.S
224 $(CC) $(MAKEDEPS) $(CFLAGS) -D__ASSEMBLY__ -c -o $@ $<
226 .S.s:
227 $(CC) $(MAKEDEPS) $(CFLAGS) -D__ASSEMBLY__ -E -o $@ $<
229 .S.lo:
230 $(CC) $(MAKEDEPS) $(CFLAGS) $(SOFLAGS) -D__ASSEMBLY__ -c -o $@ $<
232 .S.ls:
233 $(CC) $(MAKEDEPS) $(CFLAGS) $(SOFLAGS) -D__ASSEMBLY__ -E -o $@ $<
235 %(OBJ)/%.o: $(SRC)/%.s
236 $(CC) $(MAKEDEPS) $(CFLAGS) -x assembler -c -o $@ $<
238 .ls.lo:
239 $(CC) $(MAKEDEPS) $(CFLAGS) $(SOFLAGS) -x assembler -c -o $@ $<
241 .c.lo:
242 $(CC) $(MAKEDEPS) $(CFLAGS) $(SOFLAGS) -c -o $@ $<
244 .c.ls:
245 $(CC) $(MAKEDEPS) $(CFLAGS) $(SOFLAGS) -S -o $@ $<
247 %.c32: %.elf
248 $(OBJCOPY) --strip-debug --strip-unneeded $< $@