]> git.saurik.com Git - apple/libc.git/blob - Makefile.xbs
bd098dde528d74745b3af2d1ffc0f8a1afc51241
[apple/libc.git] / Makefile.xbs
1 # This is a replacement for bsd.lib.mk for the libc project to get it
2 # doing the Right Thing in XBS, which is substantially different than
3 # the BSD build system.
4 #
5 # The main problems arise when libc.a isn't meant to be static, but
6 # libc_static.a is. We also build a debug version of the library
7 # in addition to shared, static, and profile. Also, we build all
8 # versions of libc with debugging enabled, unstripped. The BSD style
9 # is to strip every object file after it is built but here, libc.a
10 # will get merged into the larger libSystem.dylib, which will eventually
11 # be stripped. We also don't build a libc.dylib, since it will be
12 # munged into libSystem.dylib.
13 #
14 # And another difference, B&I wishes to build the 4 incarnations of Libc
15 # in parallel on different machines. To do this, we must look at the
16 # RC_ProjectName variable (which B&I sets) to determine which of the 4
17 # versions of Libc we will be building. Remember that the installhdrs
18 # pass should only be invoked on one of the 4 versions, and man pages
19 # should only be installed once as well. Both of these get done when
20 # we're invoked as "Libc".
21
22 .PATH: .
23 .MAIN: all
24 all: libc.a libc_static.a libc_debug.a libc_profile.a
25 install: installhdrs install_libc.a install_libc_static.a \
26 install_libc_profile.a install_libc_debug.a autopatchman maninstall
27
28 .SUFFIXES:
29 .SUFFIXES: .o .po .So .do .S .s .c .cc .cpp .cxx .m .C
30 .SUFFIXES: -fbsd.c -uuid.c .3-uuid.in .3
31 .SUFFIXES: .f .y .l .defs .h
32 .SUFFIXES: User.c User.o User.po User.So User.do
33 .SUFFIXES: Server.c Server.o Server.po Server.So Server.do
34
35 OBJS+= ${SRCS:N*.h:R:S/$/.o/g}
36 POBJS+= ${OBJS:.o=.po} ${STATICOBJS:.o=.po}
37 SOBJS+= ${OBJS:.o=.So}
38
39 #### FreeBSD Rules ##################################################
40 FBSDFLAGS= -I${.CURDIR}/fbsdcompat -include _fbsd_compat_.h
41
42 -fbsd.c.o:
43 ${CC} -static ${FBSDFLAGS} ${CFLAGS} ${CFLAGS-${.IMPSRC:T}} \
44 -Os -c ${.IMPSRC} -o ${.TARGET}
45 -fbsd.c.po:
46 ${CC} -pg -DPROFILE ${FBSDFLAGS} ${CFLAGS} ${CFLAGS-${.IMPSRC:T}} \
47 -Os -c ${.IMPSRC} -o ${.TARGET}
48 -fbsd.c.So:
49 ${CC} ${FBSDFLAGS} ${CFLAGS} ${CFLAGS-${.IMPSRC:T}} \
50 -Os -c ${.IMPSRC} -o ${.TARGET}
51 -fbsd.c.do:
52 ${CC} -g -DDEBUG ${FBSDFLAGS} ${CFLAGS} ${CFLAGS-${.IMPSRC:T}} \
53 -c ${.IMPSRC} -o ${.TARGET}
54
55 #### UUID Rules ######################################################
56 UUIDFLAGS= -I${.CURDIR}/uuid -include uuid-config.h
57
58 -uuid.c.o:
59 ${CC} -static ${UUIDFLAGS} ${CFLAGS} ${CFLAGS-${.IMPSRC:T}} \
60 -Os -c ${.IMPSRC} -o ${.TARGET}
61 -uuid.c.po:
62 ${CC} -pg -DPROFILE ${UUIDFLAGS} ${CFLAGS} ${CFLAGS-${.IMPSRC:T}} \
63 -Os -c ${.IMPSRC} -o ${.TARGET}
64 -uuid.c.So:
65 ${CC} ${UUIDFLAGS} ${CFLAGS} ${CFLAGS-${.IMPSRC:T}} \
66 -Os -c ${.IMPSRC} -o ${.TARGET}
67 -uuid.c.do:
68 ${CC} -g -DDEBUG ${UUIDFLAGS} ${CFLAGS} ${CFLAGS-${.IMPSRC:T}} \
69 -c ${.IMPSRC} -o ${.TARGET}
70 .3-uuid.in.3:
71 sed -f ${.CURDIR}/uuid/uuidman.sed ${.IMPSRC} > ${.TARGET}
72
73 #### Standard C Rules #################################################
74 .c.o User.cUser.o Server.cServer.o:
75 ${CC} -static ${CFLAGS} ${CFLAGS-${.IMPSRC:T}} \
76 -Os -c ${.IMPSRC} -o ${.TARGET}
77 .c.po User.cUser.po Server.cServer.po:
78 ${CC} -pg -DPROFILE ${CFLAGS} ${CFLAGS-${.IMPSRC:T}} \
79 -Os -c ${.IMPSRC} -o ${.TARGET}
80 .c.So User.cUser.So Server.cServer.So:
81 ${CC} ${CFLAGS} ${CFLAGS-${.IMPSRC:T}} \
82 -Os -c ${.IMPSRC} -o ${.TARGET}
83 .c.do User.cUser.do Server.cServer.do:
84 ${CC} -g -DDEBUG ${CFLAGS} ${CFLAGS-${.IMPSRC:T}} \
85 -c ${.IMPSRC} -o ${.TARGET}
86
87 #### Standard Assembler Rules #########################################
88 .s.o:
89 ${CC} -static -x assembler-with-cpp ${CFLAGS:M-[BIDF]*} \
90 ${CFLAGS-${.IMPSRC:T}:M-[BIDF]*} ${AINC} \
91 -Os -c ${.IMPSRC} -o ${.TARGET}
92 .s.po:
93 ${CC} -pg -DPROFILE -x assembler-with-cpp ${CFLAGS:M-[BIDF]*} \
94 ${CFLAGS-${.IMPSRC:T}:M-[BIDF]*} ${AINC} \
95 -Os -c ${.IMPSRC} -o ${.TARGET}
96 .s.So:
97 ${CC} -x assembler-with-cpp ${CFLAGS:M-[BIDF]*} \
98 ${CFLAGS-${.IMPSRC:T}:M-[BIDF]*} ${AINC} \
99 -Os -c ${.IMPSRC} -o ${.TARGET}
100 .s.do:
101 ${CC} -g -DDEBUG -x assembler-with-cpp ${CFLAGS:M-[BIDF]*} \
102 ${CFLAGS-${.IMPSRC:T}:M-[BIDF]*} ${AINC} \
103 -c ${.IMPSRC} -o ${.TARGET}
104
105 #### mig Rules ########################################################
106 .defs.h .defsUser.c .defsServer.c:
107 mig -arch ${MACHINE_ARCH} -user ${.PREFIX}User.c -server ${.PREFIX}Server.c -header ${.PREFIX}.h ${.IMPSRC}
108
109 gen_mig_defs: ${SRVMIGHDRS} ${MIGHDRS}
110 gen_md_mig_defs: ${MD_MIGHDRS}
111
112 lib${LIB}_static.a:: ${OBJS} ${STATICOBJS}
113 @${ECHO} building static ${LIB} library
114 @rm -f lib${LIB}_static.a
115 @${AR} cq lib${LIB}_static.a `lorder ${OBJS} ${STATICOBJS} | tsort -q` ${ARADD}
116 ${RANLIB} lib${LIB}_static.a
117
118 lib${LIB}_profile.a:: ${POBJS}
119 @${ECHO} building profiled ${LIB} library
120 @rm -f lib${LIB}_profile.a
121 @${AR} cq lib${LIB}_profile.a `lorder ${POBJS} | tsort -q` ${ARADD}
122 ${RANLIB} lib${LIB}_profile.a
123
124 DOBJS+= ${OBJS:.o=.do}
125 lib${LIB}_debug.a:: ${DOBJS}
126 @${ECHO} building debug ${LIB} library
127 @rm -f lib${LIB}_debug.a
128 @${AR} cq lib${LIB}_debug.a `lorder ${DOBJS} | tsort -q` ${ARADD}
129 ${RANLIB} lib${LIB}_debug.a
130
131 lib${LIB}.a:: ${SOBJS}
132 @${ECHO} building standard ${LIB} library
133 @rm -f lib${LIB}.a
134 @${AR} cq lib${LIB}.a `lorder ${SOBJS} | tsort -q` ${ARADD}
135 ${RANLIB} lib${LIB}.a
136
137 CLEANFILES += ${DOBJS} libc_static.a libc_profile.a libc_debug.a
138
139 INCDIR = ${DESTDIR}/usr/include
140 LOCINCDIR = ${DESTDIR}/usr/local/include
141 SYSTEMFRAMEWORK = ${DESTDIR}/System/Library/Frameworks/System.framework
142 PRIVHDRS = ${SYSTEMFRAMEWORK}/Versions/B/PrivateHeaders
143
144 installhdrs-md: gen_md_mig_defs
145 mkdir -p ${INCDIR}/mach/${MACHINE_ARCH}
146 ${INSTALL} -c -m 444 ${MD_MIGHDRS} ${INCDIR}/mach/${MACHINE_ARCH}
147
148 installhdrs: autopatchhdrs gen_mig_defs
149 mkdir -p ${INCDIR}/arpa
150 mkdir -p ${INCDIR}/libkern
151 mkdir -p ${INCDIR}/mach
152 mkdir -p ${INCDIR}/malloc
153 mkdir -p ${INCDIR}/objc
154 mkdir -p ${INCDIR}/protocols
155 mkdir -p ${INCDIR}/servers
156 mkdir -p ${INCDIR}/sys
157 ${INSTALL} -c -m 444 ${INSTHDRS} ${INCDIR}
158 ${INSTALL} -c -m 444 ${ARPA_INSTHDRS} ${INCDIR}/arpa
159 ${INSTALL} -c -m 444 ${LIBKERN_INSTHDRS} ${INCDIR}/libkern
160 ${INSTALL} -c -m 444 ${MACH_INSTHDRS} ${INCDIR}/mach
161 ${INSTALL} -c -m 444 ${MALLOC_INSTHDRS} ${INCDIR}/malloc
162 ${INSTALL} -c -m 444 ${OBJC_INSTHDRS} ${INCDIR}/objc
163 ${INSTALL} -c -m 444 ${PROTO_INSTHDRS} ${INCDIR}/protocols
164 ${INSTALL} -c -m 444 ${SRVHDRS} ${INCDIR}/servers
165 ${INSTALL} -c -m 444 ${SYS_INSTHDRS} ${INCDIR}/sys
166 mkdir -p ${LOCINCDIR}
167 ${INSTALL} -c -m 444 ${LOCALHDRS} ${LOCINCDIR}
168 mkdir -p ${PRIVHDRS}/architecture/ppc
169 mkdir -p ${PRIVHDRS}/btree
170 mkdir -p ${PRIVHDRS}/machine
171 mkdir -p ${PRIVHDRS}/objc
172 mkdir -p ${PRIVHDRS}/sys
173 ${INSTALL} -c -m 444 ${SRCROOT}/ppc/sys/processor_facilities.h ${PRIVHDRS}/architecture/ppc
174 ${INSTALL} -c -m 444 ${SYMROOT}/btree.h ${PRIVHDRS}/btree
175 ${INSTALL} -c -m 444 ${SYMROOT}/bt_extern.h ${PRIVHDRS}/btree
176 ${INSTALL} -c -m 444 ${SRCROOT}/internat/NXCType.h ${PRIVHDRS}/objc
177 ${INSTALL} -c -m 444 ${SRCROOT}/gen/stack_logging.h ${PRIVHDRS}
178 mv ${DESTDIR}/usr/include/asm.h ${PRIVHDRS}/machine
179 mv ${INCDIR}/servers/srvbootstrap.h ${INCDIR}/servers/bootstrap.h
180 @for i in `find ${DESTDIR}/usr/include/mach ${DESTDIR}/usr/include/servers -name \*.h`; do \
181 x=`fgrep '<mach/mig.h>' $$i | uniq -d`; \
182 if [ -n "$$x" ]; then \
183 echo patching $$i; \
184 ed - $$i < ${SRCROOT}/fixdups.ed; \
185 fi; \
186 done
187 ${INSTALL} -c -m 444 ${SYS_INSTHDRS} ${PRIVHDRS}/sys
188 mkdir -p ${INCDIR}/uuid
189 ${INSTALL} -c -m 444 ${SYMROOT}/uuid.h ${INCDIR}/uuid
190
191 install_lib${LIB}_static.a:
192 ${INSTALL} -c -m 444 lib${LIB}_static.a ${DESTDIR}/usr/local/lib/system/
193 install_lib${LIB}_profile.a:
194 ${INSTALL} -c -m 444 lib${LIB}_profile.a ${DESTDIR}/usr/local/lib/system
195 install_lib${LIB}_debug.a:
196 ${INSTALL} -c -m 444 lib${LIB}_debug.a ${DESTDIR}/usr/local/lib/system/
197 install_lib${LIB}.a:
198 ${INSTALL} -c -m 444 lib${LIB}.a ${DESTDIR}/usr/local/lib/system/
199
200 autopatch: autopatchhdrs ${AUTOPATCHSRCS}
201 autopatchhdrs: ${AUTOPATCHHDRS}
202 autopatchman: ${AUTOPATCHMAN}
203
204 clean:
205 rm -f ${OBJS} ${POBJS} ${DOBJS} ${SOBJS} ${CLEANFILES}
206 rm -f lib${LIB}.a lib${LIB}_static.a lib${LIB}_profile.a \
207 lib${LIB}_debug.a