Adding debian version 3.70~pre8+dfsg-1.
[syslinux-debian/hramrach.git] / memdisk / Makefile
blobd9cc7f9f1eb6db8cadbf0c727d80072e1e4e8994
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 VERSION := $(shell cat ../version)
15 TMPFILE = $(shell mktemp /tmp/gcc_ok.XXXXXX)
17 gcc_ok = $(shell tmpf=$(TMPFILE); if $(CC) $(1) -c -x c /dev/null -o $$tmpf 2>/dev/null; \
18 then echo $(1); else echo $(2); fi; rm -f $$tmpf)
20 M32 := $(call gcc_ok,-m32,)
21 ALIGN := $(call gcc_ok,-falign-functions=0 -falign-jumps=0 -falign-loops=0,-malign-functions=0 -malign-jumps=0 -malign-loops=0)
22 FREE := $(call gcc_ok,-ffreestanding,) $(call gcc_ok,-fno-stack-protector,)
24 CC = gcc
25 CFLAGS = $(M32) $(FREE) -g -W -Wall -Wno-sign-compare \
26 -Os -fomit-frame-pointer -march=i386 $(ALIGN) \
27 -DVERSION='"$(VERSION)"' -DDATE='"$(DATE)"'
28 SFLAGS = $(M32) -march=i386 -D__ASSEMBLY__
29 LDFLAGS = $(M32) -g
30 INCLUDE = -I../com32/include
31 LD = ld -m elf_i386
32 NASM = nasm
33 NASMOPT = -O9999
34 NFLAGS = -dVERSION='"$(VERSION)"' -dDATE='"$(DATE)"' -dWITH_EDD
35 NINCLUDE =
36 OBJCOPY = objcopy
37 PERL = perl
39 # Important: init.o16 must be first!!
40 OBJS16 = init.o16 init32.o
41 OBJS32 = start32.o setup.o msetup.o e820func.o conio.o memcpy.o memset.o \
42 unzip.o memdisk.o
44 CSRC = setup.c msetup.c e820func.c conio.c unzip.c
45 SSRC = start32.S memcpy.S memset.S
46 NASMSRC = memdisk.asm memdisk16.asm
48 all: memdisk # e820test
50 # tidy, clean removes everything except the final binary
51 tidy:
52 rm -f *.o *.s *.o16 *.s16 *.bin *.lst *.elf e820test
54 clean: tidy
56 # spotless also removes the product binary
57 spotless: clean
58 rm -f memdisk .depend
60 %.o: %.asm
61 $(NASM) $(NASMOPT) $(NFLAGS) $(NINCLUDE) -f elf -l $*.lst -o $@ $<
63 %.o: %.s
64 $(CC) $(SFLAGS) -c -o $@ $<
66 %.o: %.S
67 $(CC) $(INCLUDE) $(SFLAGS) -c -o $@ $<
69 %.o16: %.s16
70 $(CC) $(SFLAGS) -x assembler -c -o $@ $<
72 %.o: %.c
73 $(CC) $(INCLUDE) $(CFLAGS) -c -o $@ $<
75 %.s16: %.s
76 echo '.code16gcc' | cat - $< > $@
78 %.s: %.S
79 $(CC) $(INCLUDE) $(SFLAGS) -E -o $@ $<
81 %.s16: %.S16
82 $(CC) $(INCLUDE) $(SFLAGS) -x assembler-with-cpp -E -o $@ $<
84 %.s: %.c
85 $(CC) $(INCLUDE) $(CFLAGS) -S -o $@ $<
87 %.i: %.c
88 $(CC) $(INCLUDE) $(CFLAGS) -E -o $@ $<
90 # Cancel default rule
91 %.o: %.c
93 %.bin: %.asm
94 $(NASM) -f bin $(NASMOPT) $(NFLAGS) $(NINCLUDE) -o $@ -l $*.lst $<
96 memdisk16.elf: $(OBJS16)
97 $(LD) -Ttext 0 -o $@ $^
99 memdisk32.elf: $(OBJS32)
100 $(LD) -Ttext 0x100000 -o $@ $^
102 %.bin: %.elf
103 $(OBJCOPY) -O binary $< $@
105 memdisk: memdisk16.bin memdisk32.bin postprocess.pl
106 $(PERL) postprocess.pl $@ memdisk16.bin memdisk32.bin
108 e820test: e820func.o msetup.o e820test.o memdisk.o
109 $(CC) $(LDFLAGS) -o $@ $^
111 memdisk.o: memdisk.bin
112 $(LD) -r -b binary -o $@ $<
114 .depend:
115 rm -f .depend
116 for csrc in *.c ; do $(CC) $(INCLUDE) $(CFLAGS) -MM $$csrc >> .depend ; done
117 for ssrc in *.S ; do $(CC) $(INCLUDE) $(SFLAGS) -MM $$ssrc >> .depend ; done
118 for nsrc in $(NASMSRC) ; do $(NASM) -DDEPEND $(NINCLUDE) -o `echo $$nsrc | sed -e 's/\.asm/\.bin/'` -M $$nsrc >> .depend ; done
120 depend:
121 rm -f .depend
122 $(MAKE) .depend
124 # This file contains the version number, so add a dependency for it
125 setup.s: ../version
127 # Include dependencies file
128 include .depend