Merge remote-tracking branch 'origin/master' into elflink
[syslinux/sherbszt.git] / core / Makefile
blob3898b4d2a3d8091a0bb8f8fdc0c28322b9e76b6d
1 ## -----------------------------------------------------------------------
2 ##
3 ## Copyright 1998-2009 H. Peter Anvin - All Rights Reserved
4 ## Copyright 2009-2010 Intel Corporation; author: H. Peter Anvin
5 ##
6 ## This program is free software; you can redistribute it and/or modify
7 ## it under the terms of the GNU General Public License as published by
8 ## the Free Software Foundation, Inc., 53 Temple Place Ste 330,
9 ## Boston MA 02111-1307, USA; either version 2 of the License, or
10 ## (at your option) any later version; incorporated herein by reference.
12 ## -----------------------------------------------------------------------
15 # Makefile for the SYSLINUX core
18 # No builtin rules
19 MAKEFLAGS += -r
20 MAKE += -r
22 topdir = ..
23 MAKEDIR = $(topdir)/mk
24 include $(MAKEDIR)/embedded.mk
25 -include $(topdir)/version.mk
27 OPTFLAGS =
28 INCLUDES = -I./include -I$(com32)/include -I$(com32)/lib
30 # This is very similar to cp437; technically it's for Norway and Denmark,
31 # but it's unlikely the characters that are different will be used in
32 # filenames by other users.
33 CODEPAGE = cp865
35 # The targets to build in this directory...
36 BTARGET = kwdhash.gen \
37 ldlinux.bss ldlinux.sys ldlinux.bin \
38 isolinux.bin isolinux-debug.bin pxelinux.0
40 # All primary source files for the main syslinux files
41 NASMSRC := $(wildcard *.asm)
42 NASMHDR := $(wildcard *.inc)
43 CSRC := $(wildcard *.c */*.c */*/*.c)
44 SSRC := $(wildcard *.S */*.S */*/*.S)
45 CHDR := $(wildcard *.h */*.h */*/*.h)
46 OTHERSRC := keywords
47 ALLSRC = $(NASMSRC) $(NASMHDR) $(CSRC) $(SSRC) $(CHDR) $(OTHERSRC)
49 COBJ := $(patsubst %.c,%.o,$(CSRC))
50 SOBJ := $(patsubst %.S,%.o,$(SSRC))
52 # Don't include console objects
53 COBJS = $(filter-out rawcon.o plaincon.o,$(COBJ))
55 LIB = libcom32.a
56 LIBS = $(LIB) --whole-archive $(com32)/lib/libcom32core.a
57 LIBDEP = $(filter-out -% %start%,$(LIBS))
58 LIBOBJS = $(COBJS) $(SOBJ)
60 NASMDEBUG = -g -F dwarf
61 NASMOPT += $(NASMDEBUG)
63 PREPCORE = ../lzo/prepcore
65 # CFLAGS += -DDEBUG=1
67 # The DATE is set on the make command line when building binaries for
68 # official release. Otherwise, substitute a hex string that is pretty much
69 # guaranteed to be unique to be unique from build to build.
70 ifndef HEXDATE
71 HEXDATE := $(shell $(PERL) ../now.pl $(SRCS))
72 endif
73 ifndef DATE
74 DATE := $(shell sh ../gen-id.sh $(VERSION) $(HEXDATE))
75 endif
77 all: $(BTARGET)
79 kwdhash.gen: keywords genhash.pl
80 $(PERL) genhash.pl < keywords > kwdhash.gen
82 .PRECIOUS: %.elf
84 %.raw: %.elf
85 $(OBJCOPY) -O binary -S $< $(@:.bin=.raw)
87 # GNU make 3.82 gets confused by the first form
88 .PRECIOUS: %.raw
90 %.bin: %.raw $(PREPCORE)
91 $(PREPCORE) $< $@
93 %.o: %.asm kwdhash.gen ../version.gen
94 $(NASM) -f elf $(NASMOPT) -DDATE_STR="'$(DATE)'" \
95 -DHEXDATE="$(HEXDATE)" \
96 -l $(@:.o=.lsr) -o $@ -MP -MD .$@.d $<
98 AUXLIBS = libisolinux.a libisolinux-debug.a libldlinux.a libpxelinux.a
100 %.elf: %.o $(LIBDEP) syslinux.ld $(AUXLIBS)
101 $(LD) $(LDFLAGS) -Bsymbolic -pie -E --hash-style=gnu -T syslinux.ld -M -o $@ $< \
102 --start-group $(LIBS) lib$(patsubst %.elf,%.a,$@) --end-group \
103 > $(@:.elf=.map)
104 $(OBJDUMP) -h $@ > $(@:.elf=.sec)
105 $(PERL) lstadjust.pl $(@:.elf=.lsr) $(@:.elf=.sec) $(@:.elf=.lst)
107 libisolinux.a: rawcon.o
108 rm -f $@
109 $(AR) cq $@ $^
110 $(RANLIB) $@
112 libisolinux-debug.a: libisolinux.a
113 cp $^ $@
115 libpxelinux.a: libisolinux.a
116 cp $^ $@
118 libldlinux.a: plaincon.o
119 rm -f $@
120 $(AR) cq $@ $^
121 $(RANLIB) $@
123 $(LIB): $(LIBOBJS)
124 rm -f $@
125 $(AR) cq $@ $^
126 $(RANLIB) $@
128 pxelinux.0: pxelinux.bin
129 cp -f $< $@
131 ldlinux.bss: ldlinux.bin
132 dd if=$< of=$@ bs=512 count=1
134 ldlinux.sys: ldlinux.bin
135 dd if=$< of=$@ bs=512 skip=2
137 codepage.cp: ../codepage/$(CODEPAGE).cp
138 cp -f $< $@
140 codepage.o: codepage.S codepage.cp
142 install: installer
144 install-lib: installer
146 install-all: install install-lib
148 netinstall: installer
150 tidy dist:
151 rm -f codepage.cp *.o *.elf *.a stupid.* patch.offset .depend .*.d
152 rm -f *.elf.tmp *.sym
153 rm -f *.lsr *.lst *.map *.sec *.raw
154 rm -f */*.o */*/*.o */*.lst */*/*.lst */.*.d */*/.*.d
155 rm -f $(OBSOLETE) $(LIB)
157 clean: tidy
159 spotless: clean
160 rm -f $(BTARGET) *.bin *_bin.c
162 # Include dependencies file
163 -include .*.d */.*.d */*/.*.d