Aligning memcpy/memmove/mempcpy/memset for libcom32
[syslinux.git] / core / Makefile
blob7289294a95e0310258dbf9233b7afef53b9fc54c
1 ## -----------------------------------------------------------------------
2 ##
3 ## Copyright 1998-2008 H. Peter Anvin - All Rights Reserved
4 ##
5 ## This program is free software; you can redistribute it and/or modify
6 ## it under the terms of the GNU General Public License as published by
7 ## the Free Software Foundation, Inc., 53 Temple Place Ste 330,
8 ## Boston MA 02111-1307, USA; either version 2 of the License, or
9 ## (at your option) any later version; incorporated herein by reference.
11 ## -----------------------------------------------------------------------
14 # Makefile for the SYSLINUX core
17 # No builtin rules
18 MAKEFLAGS += -r
19 MAKE += -r
21 CC = gcc
23 TMPFILE = $(shell mktemp /tmp/gcc_ok.XXXXXX)
24 gcc_ok = $(shell tmpf=$(TMPFILE); if $(CC) $(1) dummy.c -o $$tmpf 2>/dev/null; \
25 then echo '$(1)'; else echo '$(2)'; fi; rm -f $$tmpf)
27 M32 := $(call gcc_ok,-m32,) $(call gcc_ok,-ffreestanding,) \
28 $(call gcc_ok,-fno-stack-protector,) \
29 $(call gcc_ok,-fno-top-level-reorder,$(call gcc_ok,-fno-unit-at-a-time))
31 LD = ld
32 LDFLAGS = -m elf_i386
33 OBJCOPY = objcopy
34 OBJDUMP = objdump
36 OPTFLAGS = -g -Os -march=i386 -falign-functions=0 -falign-jumps=0 -falign-loops=0 -fomit-frame-pointer
37 INCLUDES =
38 CFLAGS = $(M32) -mregparm=3 -DREGPARM=3 -W -Wall -msoft-float $(OPTFLAGS) $(INCLUDES)
40 NASM = nasm
41 NASMOPT = -O9999
42 NINCLUDE =
44 PERL = perl
46 VERSION := $(shell cat ../version)
48 # This is very similar to cp437; technically it's for Norway and Denmark,
49 # but it's unlikely the characters that are different will be used in
50 # filenames by other users.
51 CODEPAGE = cp865
53 # _bin.c files required by both BTARGET and ITARGET installers
54 BINFILES = bootsect_bin.c ldlinux_bin.c \
55 extlinux_bss_bin.c extlinux_sys_bin.c
57 # syslinux.exe is BTARGET so as to not require everyone to have the
58 # mingw suite installed
59 BTARGET = kwdhash.gen \
60 ldlinux.bss ldlinux.sys ldlinux.bin \
61 pxelinux.0 isolinux.bin isolinux-debug.bin \
62 extlinux.bin extlinux.bss extlinux.sys
63 ITARGET =
65 # All primary source files for the main syslinux files
66 NASMSRC = $(wildcard *.asm)
67 NASMHDR = $(wildcard *.inc)
68 CSRC = $(wildcard *.c)
69 CHDR = $(wildcard *.h)
70 OTHERSRC = keywords
71 ALLSRC = $(NASMSRC) $(NASMHDR) $(CSRC) $(CHDR) $(OTHERSRC)
73 # The DATE is set on the make command line when building binaries for
74 # official release. Otherwise, substitute a hex string that is pretty much
75 # guaranteed to be unique to be unique from build to build.
76 ifndef HEXDATE
77 HEXDATE := $(shell $(PERL) now.pl $(SRCS))
78 endif
79 ifndef DATE
80 DATE := $(HEXDATE)
81 endif
84 # NOTE: If you don't have the mingw compiler suite installed, you probably
85 # want to remove win32 from this list; otherwise you're going to get an
86 # error every time you try to build.
89 all: all-local
91 all-local: $(BTARGET) $(BINFILES)
93 installer: installer-local
95 installer-local: $(ITARGET) $(BINFILES)
97 kwdhash.gen: keywords genhash.pl
98 $(PERL) genhash.pl < keywords > kwdhash.gen
100 .PRECIOUS: %.elf
102 # Standard rule for {isolinux,isolinux-debug}.bin
103 iso%.bin: iso%.elf
104 $(OBJCOPY) -O binary $< $@
105 $(PERL) checksumiso.pl $@
107 # Standard rule for {ldlinux,pxelinux,extlinux}.bin
108 %.bin: %.elf
109 $(OBJCOPY) -O binary $< $@
111 %.o: %.asm kwdhash.gen ../version.gen
112 $(NASM) $(NASMOPT) -f elf -g -F stabs -DDATE_STR="'$(DATE)'" \
113 -DHEXDATE="$(HEXDATE)" \
114 -l $(@:.o=.lsr) -o $@ $<
116 %.elf: %.o syslinux.ld
117 $(LD) $(LDFLAGS) -T syslinux.ld -M -o $@ $< > $(@:.elf=.map)
118 $(OBJDUMP) -h $@ > $(@:.elf=.sec)
119 $(PERL) lstadjust.pl $(@:.elf=.lsr) $(@:.elf=.sec) $(@:.elf=.lst)
121 pxelinux.0: pxelinux.bin
122 cp -f $< $@
124 ldlinux.bss: ldlinux.bin
125 dd if=$< of=$@ bs=512 count=1
127 ldlinux.sys: ldlinux.bin
128 dd if=$< of=$@ bs=512 skip=1
130 extlinux.bss: extlinux.bin
131 dd if=$< of=$@ bs=512 count=1
133 extlinux.sys: extlinux.bin
134 dd if=$< of=$@ bs=512 skip=1
136 bootsect_bin.c: ldlinux.bss ../bin2c.pl
137 $(PERL) ../bin2c.pl syslinux_bootsect < $< > $@
139 ldlinux_bin.c: ldlinux.sys ../bin2c.pl
140 $(PERL) ../bin2c.pl syslinux_ldlinux < $< > $@
142 extlinux_bss_bin.c: extlinux.bss ../bin2c.pl
143 $(PERL) ../bin2c.pl extlinux_bootsect < $< > $@
145 extlinux_sys_bin.c: extlinux.sys ../bin2c.pl
146 $(PERL) ../bin2c.pl extlinux_image 512 < $< > $@
148 # NASM prior to 2.03 wouldn't auto-generate this dependency...
149 ldlinux.o: codepage.bin
151 codepage.bin: ../codepage/$(CODEPAGE).bin
152 cp -f $< $@
154 install: installer
156 install-lib: installer
158 install-all: install install-lib
160 netinstall: installer
162 tidy dist:
163 rm -f codepage.bin *.o *.elf stupid.* patch.offset
164 rm -f *.lsr *.lst *.map *.sec
165 rm -f $(OBSOLETE)
167 clean: tidy
168 rm -f $(ITARGET) *_bin.c
170 spotless: clean
171 rm -f $(BTARGET) .depend
173 .depend:
174 rm -f .depend
175 for csrc in $(CSRC) ; do $(CC) $(INCLUDE) -MM $$csrc >> .depend ; done
176 for nsrc in $(NASMSRC) ; do $(NASM) -DDEPEND $(NINCLUDE) -o `echo $$nsrc | sed -e 's/\.asm/\.o/'` -M $$nsrc >> .depend ; done
178 depend:
179 rm -f .depend
180 $(MAKE) .depend
182 # Include dependencies file
183 include .depend