]> git.saurik.com Git - apple/libc.git/blob - Makefile.xbs
7409a24dfb3ef3baf4116d73dbc117a092dee831
[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 maninstall
27
28 .SUFFIXES:
29 .SUFFIXES: .o .po .So .do .S .s .c .cc .cpp .cxx .m .C .f .y .l .defs .h
30
31 OBJS+= ${SRCS:N*.h:R:S/$/.o/g}
32 POBJS+= ${OBJS:.o=.po} ${STATICOBJS:.o=.po}
33 SOBJS+= ${OBJS:.o=.So}
34
35 .c.o:
36 ${CC} -static ${CFLAGS} -c ${.IMPSRC} -o ${.TARGET}
37 .c.po:
38 ${CC} -pg -DPROFILE ${CFLAGS} -Os -c ${.IMPSRC} -o ${.TARGET}
39 .c.So:
40 ${CC} ${CFLAGS} -Os -c ${.IMPSRC} -o ${.TARGET}
41 .c.do:
42 ${CC} -g -DDEBUG ${CFLAGS} -c ${.IMPSRC} -o ${.TARGET}
43 .s.o:
44 ${CC} -x assembler-with-cpp ${CFLAGS:M-[BID]*} -static ${AINC} -c \
45 ${.IMPSRC} -o ${.TARGET}
46 .s.po:
47 ${CC} -pg -DPROFILE -x assembler-with-cpp ${CFLAGS:M-[BID]*} -Os \
48 ${AINC} -c ${.IMPSRC} -o ${.TARGET}
49 .s.So:
50 ${CC} -x assembler-with-cpp \
51 ${CFLAGS:M-[BID]*} -Os ${AINC} -c ${.IMPSRC} -o ${.TARGET}
52 .s.do:
53 ${CC} -DDEBUG -g -x assembler-with-cpp ${CFLAGS:M-[BID]*} ${AINC} -c \
54 ${.IMPSRC} -o ${.TARGET}
55 .defs.h:
56 mig -user ${.TARGET:S/.h$/User.c/} \
57 -server ${.TARGET:S/.h$/Server.c/} -header ${.TARGET} ${.IMPSRC}
58
59 gen_mig_defs: ${SRVMIGHDRS} ${MIGHDRS}
60 lib${LIB}_static.a:: ${OBJS} ${STATICOBJS}
61 @${ECHO} building static ${LIB} library
62 @rm -f lib${LIB}_static.a
63 @${AR} cq lib${LIB}_static.a `lorder ${OBJS} ${STATICOBJS} | tsort -q` ${ARADD}
64 ${RANLIB} lib${LIB}_static.a
65
66 lib${LIB}_profile.a:: ${POBJS}
67 @${ECHO} building profiled ${LIB} library
68 @rm -f lib${LIB}_profile.a
69 @${AR} cq lib${LIB}_profile.a `lorder ${POBJS} | tsort -q` ${ARADD}
70 ${RANLIB} lib${LIB}_profile.a
71
72 DOBJS+= ${OBJS:.o=.do}
73 lib${LIB}_debug.a:: ${DOBJS}
74 @${ECHO} building debug ${LIB} library
75 @rm -f lib${LIB}_debug.a
76 @${AR} cq lib${LIB}_debug.a `lorder ${DOBJS} | tsort -q` ${ARADD}
77 ${RANLIB} lib${LIB}_debug.a
78
79 lib${LIB}.a:: ${SOBJS}
80 @${ECHO} building standard ${LIB} library
81 @rm -f lib${LIB}.a
82 @${AR} cq lib${LIB}.a `lorder ${SOBJS} | tsort -q` ${ARADD}
83 ${RANLIB} lib${LIB}.a
84
85 CLEANFILES += ${DOBJS} libc_static.a libc_profile.a libc_debug.a
86
87 installhdrs: gen_mig_defs
88 mkdir -p ${DESTDIR}/usr/include/arpa
89 mkdir -p ${DESTDIR}/usr/include/protocols
90 mkdir -p ${DESTDIR}/usr/include/mach
91 mkdir -p ${DESTDIR}/usr/include/objc
92 mkdir -p ${DESTDIR}/usr/include/servers
93 ${INSTALL} -c -m 444 ${INSTHDRS} ${DESTDIR}/usr/include
94 ${INSTALL} -c -m 444 ${ARPA_INSTHDRS} ${DESTDIR}/usr/include/arpa
95 ${INSTALL} -c -m 444 ${PROTO_INSTHDRS} ${DESTDIR}/usr/include/protocols
96 ${INSTALL} -c -m 444 ${MACH_INSTHDRS} ${DESTDIR}/usr/include/mach
97 ${INSTALL} -c -m 444 ${OBJC_INSTHDRS} ${DESTDIR}/usr/include/objc
98 ${INSTALL} -c -m 444 ${SRVHDRS} ${DESTDIR}/usr/include/servers
99 mv ${DESTDIR}/usr/include/servers/srvbootstrap.h ${DESTDIR}/usr/include/servers/bootstrap.h
100 mkdir -p ${DESTDIR}/System/Library/Frameworks/System.framework/Versions/B/PrivateHeaders/
101 mkdir -p ${DESTDIR}/System/Library/Frameworks/System.framework/Versions/B/PrivateHeaders/architecture
102 mkdir -p ${DESTDIR}/System/Library/Frameworks/System.framework/Versions/B/PrivateHeaders/architecture/ppc
103 mkdir -p ${DESTDIR}/System/Library/Frameworks/System.framework/Versions/B/PrivateHeaders/btree
104 mkdir -p ${DESTDIR}/System/Library/Frameworks/System.framework/Versions/B/PrivateHeaders/machine
105 mkdir -p ${DESTDIR}/System/Library/Frameworks/System.framework/Versions/B/PrivateHeaders/objc
106 install -c -m 444 ${SRCROOT}/db/btree/btree.h ${DESTDIR}/System/Library/Frameworks/System.framework/Versions/B/PrivateHeaders/btree
107 install -c -m 444 ${SRCROOT}/db/btree/bt_extern.h ${DESTDIR}/System/Library/Frameworks/System.framework/Versions/B/PrivateHeaders/btree
108 install -c -m 444 ${SRCROOT}/ppc/sys/processor_facilities.h ${DESTDIR}/System/Library/Frameworks/System.framework/Versions/B/PrivateHeaders/architecture/ppc
109 install -c -m 444 ${SRCROOT}/internat/NXCType.h ${DESTDIR}/System/Library/Frameworks/System.framework/Versions/B/PrivateHeaders/objc
110 install -c -m 444 ${SRCROOT}/gen/stack_logging.h ${DESTDIR}/System/Library/Frameworks/System.framework/Versions/B/PrivateHeaders/
111 mv ${DESTDIR}/usr/include/asm.h ${DESTDIR}/System/Library/Frameworks/System.framework/Versions/B/PrivateHeaders/machine
112
113 install_lib${LIB}_static.a:
114 ${INSTALL} -c -m 444 lib${LIB}_static.a ${DESTDIR}/usr/local/lib/system/
115 install_lib${LIB}_profile.a:
116 ${INSTALL} -c -m 444 lib${LIB}_profile.a ${DESTDIR}/usr/local/lib/system
117 install_lib${LIB}_debug.a:
118 ${INSTALL} -c -m 444 lib${LIB}_debug.a ${DESTDIR}/usr/local/lib/system/
119 install_lib${LIB}.a:
120 ${INSTALL} -c -m 444 lib${LIB}.a ${DESTDIR}/usr/local/lib/system/
121
122 clean:
123 rm -f ${OBJS} ${POBJS} ${DOBJS} ${SOBJS} ${CLEANFILES}
124 rm -f lib${LIB}.a lib${LIB}_static.a lib${LIB}_profile.a \
125 lib${LIB}_debug.a