]> git.saurik.com Git - apple/boot.git/blob - i386/boot1u/Makefile
0f479cacf874eed33ecd9f0d4f889057ff46a56a
[apple/boot.git] / i386 / boot1u / Makefile
1 DIR = boot1u
2 include ../MakePaths.dir
3
4 OPTIM = -Os
5 CFLAGS = $(RC_CFLAGS) $(OPTIM) $(MORECPP) -arch i386 -g -Wmost -Werror \
6 -fno-builtin -DSAIO_INTERNAL_USER -DBOOT1 -static \
7 -fomit-frame-pointer -mpreferred-stack-boundary=2 \
8 -fno-align-functions
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
22 LD = ld
23 LIBS= -L$(SYMDIR) -lsa
24 #LIBS= -L$(SYMDIR)
25
26 OTHER_FILES =
27
28 INSTALLDIR = $(DSTROOT)/usr/standalone/i386
29 VPATH = $(SYMROOT):$(OBJROOT)
30 vpath %.c ../libsaio
31 vpath % $(SYMROOT)
32 vpath %.h ../libsaio
33 vpath % $(SYMROOT)
34
35 # The ordering is important;
36 # boot1u.o must be first.
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
39
40 # OBJS += $(OBJROOT)/../libsa/prf.o $(OBJROOT)/../libsa/printf.o
41
42 # We build the following source files from the libsaio directory:
43 # ufs.o cache.o ufs_byteorder.o table.o
44 # and get these object files from libsa:
45 # prf.o printf.o
46 # If they increase in size, or if other accidental dependencies
47 # are created with other .o files in libsa.a, then boot1u can get too large.
48 # Use care in changing libsaio and libsa.
49
50 UTILDIR = ../util
51 SFILES = boot1u.s bios.s asm.s
52 CFILES = boot.c disk.c malloc.c put.c string.c \
53 ufs.c cache.c misc.c ufs_byteorder.c table.c
54 HFILES =
55 OTHERFILES = Makefile
56 ALLSRC = $(FOREIGNSRC) $(FOREIGNBIN) $(SFILES) $(CFILES) \
57 $(HFILES) $(OTHERFILES)
58 DIRS_NEEDED = $(OBJROOT) $(SYMROOT)
59 BOOT1UADDR = 10200
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
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
73 boot1u: $(SYMROOT)/machOconv boot1u0 $(OBJS)
74 $(LD) -static -preload -segaddr __TEXT $(BOOT1UADDR) -segalign 20 \
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}'` ; \
80 if expr "$$size" ">" "$(MAXBOOTSIZE)" > /dev/null ;\
81 then \
82 echo "Booter executable larger than $(MAXBOOTSIZE) bytes" ;\
83 exit 1;\
84 fi)
85 cat $(SYMROOT)/boot1u0 $(SYMROOT)/$(@F).post | dd obs=7k conv=osync of=$(SYMROOT)/$(@F)
86 rm $(SYMROOT)/$(@F).post
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::
94 rm -f $(SYMROOT)/boot1u.sys $(SYMROOT)/boot1u $(SYMROOT)/boot1u0
95
96 include ../MakeInc.dir
97
98 #dependencies
99 -include $(OBJROOT)/Makedep