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.
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.
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".
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 fbsdman maninstall
29 .SUFFIXES: .o .po .So .do .S .s -fbsd.c .c .cc .cpp .cxx .m .C .f .y .l .defs .h
30 .SUFFIXES: User.c User.o User.po User.So User.do
31 .SUFFIXES: Server.c Server.o Server.po Server.So Server.do
33 OBJS+= ${SRCS:N*.h:R:S/$/.o/g}
34 POBJS+= ${OBJS:.o=.po} ${STATICOBJS:.o=.po}
35 SOBJS+= ${OBJS:.o=.So}
36 FBSDFLAGS= -I${.CURDIR}/fbsdcompat -include _fbsd_compat_.h
39 ${CC} -static ${FBSDFLAGS} ${CFLAGS} -Os -c ${.IMPSRC} -o ${.TARGET}
40 .c.o User.cUser.o Server.cServer.o:
41 ${CC} -static ${CFLAGS} -Os -c ${.IMPSRC} -o ${.TARGET}
43 ${CC} -pg -DPROFILE ${FBSDFLAGS} ${CFLAGS} -Os -c ${.IMPSRC} \
45 .c.po User.cUser.po Server.cServer.po:
46 ${CC} -pg -DPROFILE ${CFLAGS} -Os -c ${.IMPSRC} -o ${.TARGET}
48 ${CC} ${FBSDFLAGS} ${CFLAGS} -Os -c ${.IMPSRC} -o ${.TARGET}
49 .c.So User.cUser.So Server.cServer.So:
50 ${CC} ${CFLAGS} -Os -c ${.IMPSRC} -o ${.TARGET}
52 ${CC} -g -DDEBUG ${FBSDFLAGS} ${CFLAGS} -c ${.IMPSRC} -o ${.TARGET}
53 .c.do User.cUser.do Server.cServer.do:
54 ${CC} -g -DDEBUG ${CFLAGS} -c ${.IMPSRC} -o ${.TARGET}
56 ${CC} -x assembler-with-cpp ${FBSDFLAGS} ${CFLAGS:M-[BID]*} \
57 -static ${AINC} -c ${.IMPSRC} -o ${.TARGET}
59 ${CC} -x assembler-with-cpp ${CFLAGS:M-[BID]*} -static ${AINC} -c \
60 ${.IMPSRC} -o ${.TARGET}
62 ${CC} -pg -DPROFILE -x assembler-with-cpp ${FBSDFLAGS} \
63 ${CFLAGS:M-[BID]*} -Os ${AINC} -c ${.IMPSRC} -o ${.TARGET}
65 ${CC} -pg -DPROFILE -x assembler-with-cpp ${CFLAGS:M-[BID]*} -Os \
66 ${AINC} -c ${.IMPSRC} -o ${.TARGET}
68 ${CC} -x assembler-with-cpp ${FBSDFLAGS} \
69 ${CFLAGS:M-[BID]*} -Os ${AINC} -c ${.IMPSRC} -o ${.TARGET}
71 ${CC} -x assembler-with-cpp \
72 ${CFLAGS:M-[BID]*} -Os ${AINC} -c ${.IMPSRC} -o ${.TARGET}
74 ${CC} -DDEBUG -g -x assembler-with-cpp ${FBSDFLAGS} ${CFLAGS:M-[BID]*} \
75 ${AINC} -c ${.IMPSRC} -o ${.TARGET}
77 ${CC} -DDEBUG -g -x assembler-with-cpp ${CFLAGS:M-[BID]*} ${AINC} -c \
78 ${.IMPSRC} -o ${.TARGET}
79 .defs.h .defsUser.c .defsServer.c:
80 mig -arch ${MACHINE_ARCH} -user ${.PREFIX}User.c -server ${.PREFIX}Server.c -header ${.PREFIX}.h ${.IMPSRC}
82 gen_mig_defs: ${SRVMIGHDRS} ${MIGHDRS}
83 gen_md_mig_defs: ${MD_MIGHDRS}
85 lib${LIB}_static.a:: ${FBSDHDRS} ${OBJS} ${STATICOBJS}
86 @${ECHO} building static ${LIB} library
87 @rm -f lib${LIB}_static.a
88 @${AR} cq lib${LIB}_static.a `lorder ${OBJS} ${STATICOBJS} | tsort -q` ${ARADD}
89 ${RANLIB} lib${LIB}_static.a
91 lib${LIB}_profile.a:: ${FBSDHDRS} ${POBJS}
92 @${ECHO} building profiled ${LIB} library
93 @rm -f lib${LIB}_profile.a
94 @${AR} cq lib${LIB}_profile.a `lorder ${POBJS} | tsort -q` ${ARADD}
95 ${RANLIB} lib${LIB}_profile.a
97 DOBJS+= ${OBJS:.o=.do}
98 lib${LIB}_debug.a:: ${FBSDHDRS} ${DOBJS}
99 @${ECHO} building debug ${LIB} library
100 @rm -f lib${LIB}_debug.a
101 @${AR} cq lib${LIB}_debug.a `lorder ${DOBJS} | tsort -q` ${ARADD}
102 ${RANLIB} lib${LIB}_debug.a
104 lib${LIB}.a:: ${FBSDHDRS} ${SOBJS}
105 @${ECHO} building standard ${LIB} library
107 @${AR} cq lib${LIB}.a `lorder ${SOBJS} | tsort -q` ${ARADD}
108 ${RANLIB} lib${LIB}.a
110 CLEANFILES += ${DOBJS} libc_static.a libc_profile.a libc_debug.a
112 INCDIR = ${DESTDIR}/usr/include
113 LOCINCDIR = ${DESTDIR}/usr/local/include
114 SYSTEMFRAMEWORK = ${DESTDIR}/System/Library/Frameworks/System.framework
115 PRIVHDRS = ${SYSTEMFRAMEWORK}/Versions/B/PrivateHeaders
117 installhdrs-md: gen_md_mig_defs
118 mkdir -p ${INCDIR}/mach/${MACHINE_ARCH}
119 ${INSTALL} -c -m 444 ${MD_MIGHDRS} ${INCDIR}/mach/${MACHINE_ARCH}
121 installhdrs: ${FBSDHDRS} gen_mig_defs
122 mkdir -p ${INCDIR}/arpa
123 mkdir -p ${INCDIR}/mach
124 mkdir -p ${INCDIR}/malloc
125 mkdir -p ${INCDIR}/objc
126 mkdir -p ${INCDIR}/protocols
127 mkdir -p ${INCDIR}/servers
128 ${INSTALL} -c -m 444 ${INSTHDRS} ${INCDIR}
129 ${INSTALL} -c -m 444 ${ARPA_INSTHDRS} ${INCDIR}/arpa
130 ${INSTALL} -c -m 444 ${MACH_INSTHDRS} ${INCDIR}/mach
131 ${INSTALL} -c -m 444 ${MALLOC_INSTHDRS} ${INCDIR}/malloc
132 ${INSTALL} -c -m 444 ${OBJC_INSTHDRS} ${INCDIR}/objc
133 ${INSTALL} -c -m 444 ${PROTO_INSTHDRS} ${INCDIR}/protocols
134 ${INSTALL} -c -m 444 ${SRVHDRS} ${INCDIR}/servers
135 mkdir -p ${LOCINCDIR}
136 ${INSTALL} -c -m 444 ${LOCALHDRS} ${LOCINCDIR}
137 mkdir -p ${PRIVHDRS}/architecture/ppc
138 mkdir -p ${PRIVHDRS}/btree
139 mkdir -p ${PRIVHDRS}/machine
140 mkdir -p ${PRIVHDRS}/objc
141 ${INSTALL} -c -m 444 ${SRCROOT}/ppc/sys/processor_facilities.h ${PRIVHDRS}/architecture/ppc
142 ${INSTALL} -c -m 444 ${SRCROOT}/db/btree/btree.h ${PRIVHDRS}/btree
143 ${INSTALL} -c -m 444 ${SRCROOT}/db/btree/bt_extern.h ${PRIVHDRS}/btree
144 ${INSTALL} -c -m 444 ${SRCROOT}/internat/NXCType.h ${PRIVHDRS}/objc
145 ${INSTALL} -c -m 444 ${SRCROOT}/gen/stack_logging.h ${PRIVHDRS}
146 mv ${DESTDIR}/usr/include/asm.h ${PRIVHDRS}/machine
147 mv ${INCDIR}/servers/srvbootstrap.h ${INCDIR}/servers/bootstrap.h
149 install_lib${LIB}_static.a:
150 ${INSTALL} -c -m 444 lib${LIB}_static.a ${DESTDIR}/usr/local/lib/system/
151 install_lib${LIB}_profile.a:
152 ${INSTALL} -c -m 444 lib${LIB}_profile.a ${DESTDIR}/usr/local/lib/system
153 install_lib${LIB}_debug.a:
154 ${INSTALL} -c -m 444 lib${LIB}_debug.a ${DESTDIR}/usr/local/lib/system/
156 ${INSTALL} -c -m 444 lib${LIB}.a ${DESTDIR}/usr/local/lib/system/
158 fbsdman: ${FBSDPATCHMAN}
161 rm -f ${OBJS} ${POBJS} ${DOBJS} ${SOBJS} ${CLEANFILES}
162 rm -f lib${LIB}.a lib${LIB}_static.a lib${LIB}_profile.a \