]>
Commit | Line | Data |
---|---|---|
f083c6c3 A |
1 | DIR = boot1u |
2 | include ../MakePaths.dir | |
3 | ||
bba600dd | 4 | OPTIM = -Os -Oz |
f083c6c3 | 5 | CFLAGS = $(RC_CFLAGS) $(OPTIM) $(MORECPP) -arch i386 -g -Wmost -Werror \ |
57c72a9a | 6 | -fno-builtin -DSAIO_INTERNAL_USER -DBOOT1 -static \ |
f083c6c3 | 7 | -fomit-frame-pointer -mpreferred-stack-boundary=2 \ |
bba600dd | 8 | -fno-align-functions -mno-sse2 -mfpmath=387 |
f083c6c3 A |
9 | DEFINES= |
10 | CONFIG = hd | |
11 | SYMDIR = $(SYMROOT) | |
12 | LIBSADIR = ../libsa | |
13 | LIBSAIODIR = ../libsaio | |
14 | UTILDIR = ../util | |
15 | INC = -I. -I.. -I$(SYMDIR) -I$(LIBSADIR) -I$(LIBSAIODIR) -I$(UTILDIR) | |
16 | ifneq "" "$(wildcard /bin/mkdirs)" | |
17 | MKDIRS = /bin/mkdirs | |
18 | else | |
19 | MKDIRS = /bin/mkdir -p | |
20 | endif | |
21 | AS = as | |
bba600dd | 22 | LD = gcc |
57c72a9a | 23 | LIBS= -L$(SYMDIR) -lsa |
f083c6c3 A |
24 | #LIBS= -L$(SYMDIR) |
25 | ||
26 | OTHER_FILES = | |
27 | ||
28 | INSTALLDIR = $(DSTROOT)/usr/standalone/i386 | |
57c72a9a A |
29 | VPATH = $(SYMROOT):$(OBJROOT) |
30 | vpath %.c ../libsaio | |
31 | vpath % $(SYMROOT) | |
32 | vpath %.h ../libsaio | |
33 | vpath % $(SYMROOT) | |
f083c6c3 A |
34 | |
35 | # The ordering is important; | |
36 | # boot1u.o must be first. | |
57c72a9a A |
37 | OBJS = boot1u.o asm.o bios.o boot.o string.o malloc.o disk.o put.o \ |
38 | ufs.o cache.o misc.o ufs_byteorder.o table.o | |
f083c6c3 A |
39 | |
40 | # OBJS += $(OBJROOT)/../libsa/prf.o $(OBJROOT)/../libsa/printf.o | |
41 | ||
57c72a9a | 42 | # We build the following source files from the libsaio directory: |
f083c6c3 | 43 | # ufs.o cache.o ufs_byteorder.o table.o |
57c72a9a | 44 | # and get these object files from libsa: |
f083c6c3 A |
45 | # prf.o printf.o |
46 | # If they increase in size, or if other accidental dependencies | |
57c72a9a A |
47 | # are created with other .o files in libsa.a, then boot1u can get too large. |
48 | # Use care in changing libsaio and libsa. | |
f083c6c3 A |
49 | |
50 | UTILDIR = ../util | |
51 | SFILES = boot1u.s bios.s asm.s | |
57c72a9a A |
52 | CFILES = boot.c disk.c malloc.c put.c string.c \ |
53 | ufs.c cache.c misc.c ufs_byteorder.c table.c | |
f083c6c3 A |
54 | HFILES = |
55 | OTHERFILES = Makefile | |
56 | ALLSRC = $(FOREIGNSRC) $(FOREIGNBIN) $(SFILES) $(CFILES) \ | |
57 | $(HFILES) $(OTHERFILES) | |
58 | DIRS_NEEDED = $(OBJROOT) $(SYMROOT) | |
59 | BOOT1UADDR = 10200 | |
57c72a9a A |
60 | |
61 | # Max boot1u code size is 7k (to leave room for the disk label) | |
62 | # minus 512 bytes for the partition booter, | |
63 | # for a total of 6.5k. | |
64 | MAXBOOTSIZE = 6656 | |
65 | ||
f083c6c3 A |
66 | NASM = $(SYMROOT)/nasm |
67 | ||
68 | all: $(DIRS_NEEDED) boot1u0 boot1u | |
69 | ||
70 | boot1u0: boot1u0.s Makefile $(NASM) | |
71 | $(NASM) boot1u0.s -o $(SYMROOT)/$@ | |
72 | ||
57c72a9a | 73 | boot1u: $(SYMROOT)/machOconv boot1u0 $(OBJS) |
bba600dd | 74 | $(LD) -arch i386 -fno-builtin -static -Wl,-preload -Wl,-segaddr,__TEXT,$(BOOT1UADDR) -nostdlib -Wl,-segalign,20 \ |
57c72a9a A |
75 | -o $(SYMROOT)/$(@F).sys $(filter %.o,$^) $(LIBS) -lcc_kext |
76 | size $(SYMROOT)/$(@F).sys | |
77 | $(SYMROOT)/machOconv $(SYMROOT)/$(@F).sys $(SYMROOT)/$(@F).post | |
78 | ls -l $(SYMROOT)/$(@F).post | |
79 | @( size=`ls -l $(SYMROOT)/$(@F).post | awk '{ print $$5}'` ; \ | |
f083c6c3 A |
80 | if expr "$$size" ">" "$(MAXBOOTSIZE)" > /dev/null ;\ |
81 | then \ | |
82 | echo "Booter executable larger than $(MAXBOOTSIZE) bytes" ;\ | |
83 | exit 1;\ | |
84 | fi) | |
57c72a9a A |
85 | cat $(SYMROOT)/boot1u0 $(SYMROOT)/$(@F).post | dd obs=7k conv=osync of=$(SYMROOT)/$(@F) |
86 | rm $(SYMROOT)/$(@F).post | |
f083c6c3 A |
87 | |
88 | ||
89 | install_i386:: all $(INSTALLDIR) | |
90 | cp $(SYMROOT)/boot1u $(OTHER_FILES) $(INSTALLDIR) | |
91 | cd $(INSTALLDIR); chmod u+w boot1u $(OTHER_FILES) | |
92 | ||
93 | clean:: | |
57c72a9a | 94 | rm -f $(SYMROOT)/boot1u.sys $(SYMROOT)/boot1u $(SYMROOT)/boot1u0 |
f083c6c3 A |
95 | |
96 | include ../MakeInc.dir | |
97 | ||
98 | #dependencies | |
99 | -include $(OBJROOT)/Makedep |