gPXE: merge gPXE 0.9.5
[syslinux.git] / memdisk / Makefile
blobd3023a0e37a27c2e82550b7b34609e9613be669f
1 ## -----------------------------------------------------------------------
2 ##
3 ## Copyright 2001-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 ## -----------------------------------------------------------------------
13 topdir = ..
14 include $(topdir)/MCONFIG.embedded
15 -include $(topdir)/version.mk
17 CFLAGS = $(GCCOPT) -g -W -Wall -Wno-sign-compare -DDATE='"$(DATE)"'
18 SFLAGS = $(GCCOPT) -D__ASSEMBLY__
19 LDFLAGS = $(GCCOPT) -g
20 INCLUDE = -I$(topdir)/com32/include
21 NASM = nasm
22 NASMOPT = -O9999
23 NFLAGS = -dDATE='"$(DATE)"' -dWITH_EDD
24 NINCLUDE =
26 SRCS = $(wildcard *.asm *.c *.h)
28 # The DATE is set on the make command line when building binaries for
29 # official release. Otherwise, substitute a hex string that is pretty much
30 # guaranteed to be unique to be unique from build to build.
31 ifndef HEXDATE
32 HEXDATE := $(shell $(PERL) ../now.pl $(SRCS))
33 endif
34 ifndef DATE
35 DATE := $(shell sh ../gen-id.sh $(VERSION) $(HEXDATE))
36 endif
38 # Important: init.o16 must be first!!
39 OBJS16 = init.o16 init32.o
40 OBJS32 = start32.o setup.o msetup.o e820func.o conio.o memcpy.o memset.o \
41 unzip.o memdisk.o
43 CSRC = setup.c msetup.c e820func.c conio.c unzip.c
44 SSRC = start32.S memcpy.S memset.S
45 NASMSRC = memdisk.asm memdisk16.asm
47 all: memdisk # e820test
49 # tidy, clean removes everything except the final binary
50 tidy dist:
51 rm -f *.o *.s *.tmp *.o16 *.s16 *.bin *.lst *.elf e820test
53 clean: tidy
55 # spotless also removes the product binary
56 spotless: clean
57 rm -f memdisk .depend
59 %.o: %.asm
60 $(NASM) $(NASMOPT) $(NFLAGS) $(NINCLUDE) -f elf -l $*.lst -o $@ $<
62 %.o: %.s
63 $(CC) $(SFLAGS) -c -o $@ $<
65 %.o: %.S
66 $(CC) $(INCLUDE) $(SFLAGS) -c -o $@ $<
68 %.o16: %.s16
69 $(CC) $(SFLAGS) -x assembler -c -o $@ $<
71 %.o: %.c
72 $(CC) $(INCLUDE) $(CFLAGS) -c -o $@ $<
74 %.s16: %.s
75 echo '.code16gcc' | cat - $< > $@
77 %.s: %.S
78 $(CC) $(INCLUDE) $(SFLAGS) -E -o $@ $<
80 %.s16: %.S16
81 $(CC) $(INCLUDE) $(SFLAGS) -x assembler-with-cpp -E -o $@ $<
83 %.s: %.c
84 $(CC) $(INCLUDE) $(CFLAGS) -S -o $@ $<
86 %.i: %.c
87 $(CC) $(INCLUDE) $(CFLAGS) -E -o $@ $<
89 # Cancel default rule
90 %.o: %.c
92 %.bin: %.asm
93 $(NASM) -f bin $(NASMOPT) $(NFLAGS) $(NINCLUDE) -o $@ -l $*.lst $<
95 memdisk16.elf: $(OBJS16)
96 $(LD) -Ttext 0 -o $@ $^
98 memdisk32.elf: $(OBJS32)
99 $(LD) -Ttext 0x100000 -o $@ $^
101 %.bin: %.elf
102 $(OBJCOPY) -O binary $< $@
104 memdisk: memdisk16.bin memdisk32.bin postprocess.pl
105 $(PERL) postprocess.pl $@ memdisk16.bin memdisk32.bin
107 e820test: e820func.o msetup.o e820test.o memdisk.o
108 $(CC) $(LDFLAGS) -o $@ $^
110 memdisk.o: memdisk.bin
111 $(LD) -r -b binary -o $@ $<
113 .depend:
114 rm -f .depend
115 for csrc in *.c ; do $(CC) $(INCLUDE) $(CFLAGS) -MM $$csrc >> .depend ; done
116 for ssrc in *.S ; do $(CC) $(INCLUDE) $(SFLAGS) -MM $$ssrc >> .depend ; done
117 for nsrc in $(NASMSRC) ; do $(NASM) -DDEPEND $(NINCLUDE) -o `echo $$nsrc | sed -e 's/\.asm/\.bin/'` -M $$nsrc >> .depend ; done
119 depend:
120 rm -f .depend
121 $(MAKE) .depend
123 # This file contains the version number, so add a dependency for it
124 setup.s: ../version
126 # Include dependencies file
127 include .depend