blob: 7b557e11d24b6d058b9f91734c1b8ee412486b72 (
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
|
## -----------------------------------------------------------------------
##
## Copyright 2001-2009 H. Peter Anvin - All Rights Reserved
## Copyright 2009 Intel Corporation; author: H. Peter Anvin
##
## 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,
## Boston MA 02111-1307, USA; either version 2 of the License, or
## (at your option) any later version; incorporated herein by reference.
##
## -----------------------------------------------------------------------
topdir = ..
include $(topdir)/MCONFIG.embedded
-include $(topdir)/version.mk
CFLAGS = $(GCCOPT) -g -W -Wall -Wno-sign-compare -DDATE='"$(DATE)"'
SFLAGS = $(GCCOPT) -D__ASSEMBLY__
LDFLAGS = $(GCCOPT) -g
INCLUDE = -I$(topdir)/com32/include
NASM = nasm
NASMOPT = -O9999
NFLAGS = -dDATE='"$(DATE)"'
NINCLUDE =
SRCS = $(wildcard *.asm *.c *.h)
# The DATE is set on the make command line when building binaries for
# official release. Otherwise, substitute a hex string that is pretty much
# guaranteed to be unique to be unique from build to build.
ifndef HEXDATE
HEXDATE := $(shell $(PERL) ../now.pl $(SRCS))
endif
ifndef DATE
DATE := $(shell sh ../gen-id.sh $(VERSION) $(HEXDATE))
endif
# Important: init.o16 must be first!!
OBJS16 = init.o16 init32.o
OBJS32 = start32.o setup.o msetup.o e820func.o conio.o memcpy.o memset.o \
unzip.o memdisk_chs.o memdisk_edd.o
CSRC = setup.c msetup.c e820func.c conio.c unzip.c
SSRC = start32.S memcpy.S memset.S
NASMSRC = memdisk_chs.asm memdisk_edd.asm memdisk16.asm
all: memdisk # e820test
# tidy, clean removes everything except the final binary
tidy dist:
rm -f *.o *.s *.tmp *.o16 *.s16 *.bin *.lst *.elf e820test
clean: tidy
# spotless also removes the product binary
spotless: clean
rm -f memdisk .depend
memdisk16.o: memdisk16.asm
$(NASM) $(NASMOPT) $(NFLAGS) $(NINCLUDE) -f elf -l $*.lst -o $@ $<
%.o: %.s
$(CC) $(SFLAGS) -c -o $@ $<
%.o: %.S
$(CC) $(INCLUDE) $(SFLAGS) -c -o $@ $<
%.o16: %.s16
$(CC) $(SFLAGS) -x assembler -c -o $@ $<
%.o: %.c
$(CC) $(INCLUDE) $(CFLAGS) -c -o $@ $<
%.s16: %.s
echo '.code16gcc' | cat - $< > $@
%.s: %.S
$(CC) $(INCLUDE) $(SFLAGS) -E -o $@ $<
%.s16: %.S16
$(CC) $(INCLUDE) $(SFLAGS) -x assembler-with-cpp -E -o $@ $<
%.s: %.c
$(CC) $(INCLUDE) $(CFLAGS) -S -o $@ $<
%.i: %.c
$(CC) $(INCLUDE) $(CFLAGS) -E -o $@ $<
# Cancel default rule
%.o: %.c
%.bin: %.asm
$(NASM) -f bin $(NASMOPT) $(NFLAGS) $(NINCLUDE) -o $@ -l $*.lst $<
memdisk_%.o: memdisk_%.bin
$(LD) -r -b binary -o $@ $<
memdisk16.elf: $(OBJS16)
$(LD) -Ttext 0 -o $@ $^
memdisk32.elf: memdisk.ld $(OBJS32)
$(LD) -o $@ -T $^
%.bin: %.elf
$(OBJCOPY) -O binary $< $@
memdisk: memdisk16.bin memdisk32.bin postprocess.pl
$(PERL) postprocess.pl $@ memdisk16.bin memdisk32.bin
e820test: e820test.c e820func.c msetup.c
$(CC) -m32 -g -W -Wall -DTEST -o $@ $^
.depend:
rm -f .depend
for csrc in *.c ; do $(CC) $(INCLUDE) $(CFLAGS) -MM $$csrc >> .depend ; done ; true
for ssrc in *.S ; do $(CC) $(INCLUDE) $(SFLAGS) -MM $$ssrc >> .depend ; done ; true
for nsrc in $(NASMSRC) ; do \
( $(NASM) -DDEPEND $(NINCLUDE) -o \
`echo $$nsrc | sed -e 's/\.asm/\.bin/'` -M $$nsrc ; \
echo '' ) >> .depend ; done ; true
depend:
rm -f .depend
$(MAKE) .depend
# This file contains the version number, so add a dependency for it
setup.s: ../version
# Include dependencies file
-include .depend
|