aboutsummaryrefslogtreecommitdiffstats
path: root/memdisk/Makefile
blob: 9dfa9b68a72c133dce546f73eb238078cb713120 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#ident "$Id$"
## -----------------------------------------------------------------------
##   
##   Copyright 2001 H. Peter Anvin - All Rights Reserved
##
##   This program is free software; you can redistribute it and/or modify
##   it under the terms of the GNU General Public License as published by
##   the Free Software Foundation, Inc., 53 Temple Place Ste 330,
##   Bostom MA 02111-1307, USA; either version 2 of the License, or
##   (at your option) any later version; incorporated herein by reference.
##
## -----------------------------------------------------------------------

VERSION := $(shell cat ../version)

CC      = gcc
CFLAGS  = -Wall -O2 -fomit-frame-pointer -march=i386 \
	  -malign-functions=0 -malign-jumps=0 -malign-loops=0 \
	  -DVERSION=\"$(VERSION)\" -DDATE=\"$(DATE)\"
LDFLAGS = 
AS      = as
LD	= ld
NASM    = nasm
OBJCOPY = objcopy
PERL    = perl

# Important: init.o16 must be first!!
OBJS    = init.o16 setup.o16 msetup.o16 e820func.o16 conio.o16 memdisk.o

all: memdisk e820test

# tidy removes everything except the final binary
tidy:
	rm -f *.o *.s *.o16 *.s16 *.bin *.lst *.elf e820test

# clean also removes the product binary
clean: tidy
	rm -f memdisk

%.o16: %.s16
	$(AS) -o $@ $<

%.s16: %.s
	echo '.code16gcc' | cat - $< > $@

%.s: %.S
	$(CC) -x c $(CFLAGS) -Wp,-traditional -E -o $@ $<

%.s16: %.S16
	$(CC) -x c $(CFLAGS) -Wp,-traditional -E -o $@ $<

%.s: %.c
	$(CC) $(CFLAGS) -S -o $@ $<

%.i: %.c
	$(CC) $(CFLAGS) -E -o $@ $<

%.o: %.c
	$(CC) $(CFLAGS) -c -o $@ $<

%.bin: %.asm
	$(NASM) -f bin -o $@ -l $*.lst $<

memdisk.elf: $(OBJS)
	$(LD) -Ttext 0 -o $@ $^

memdisk: memdisk.elf postprocess.pl
	$(OBJCOPY) -O binary $< $@
	$(PERL) postprocess.pl $@

e820test: e820func.o msetup.o e820test.o memdisk.o
	$(CC) $(LDFLAGS) -o $@ $^

memdisk.o: memdisk.bin
	$(LD) -r -b binary -o $@ $<