Commit | Line | Data |
---|---|---|
15637ed4 RG |
1 | # @(#)bsd.lib.mk 5.26 (Berkeley) 5/2/91 |
2 | # | |
78ed81a3 | 3 | # $Log: bsd.lib.mk,v $ |
4 | # Revision 1.11 1993/08/15 01:27:28 nate | |
5 | # 1) Finishedup my DPSRCS fixes from way back. Now any .h files will | |
6 | # automatically be depended and stripped out of the SRCS line | |
7 | # (I also left the external definition as well, in case of non-src | |
8 | # dependencies) | |
9 | # | |
10 | # 2) Cleaned up some of the clean/cleandirs to have a more pleasing format | |
11 | # (rm -f on every line rather than line-continuations) | |
12 | # | |
13 | # 3) Added Charles Hannum's dependency fixes for a cleaner make depend that | |
14 | # works for both c/c++ files | |
15 | # | |
16 | # 4) Added default targets for (file.cc|cxx|C) -> file.o in the all | |
17 | # affected make macros. However, these as well as Charles c++ | |
18 | # dependency fixes are commented out so that groff won't be broken. | |
19 | # I'll uncomment them after further testing on my box and seeing if | |
20 | # groff should be modified rather than relying on gcc2 doing the right | |
21 | # thing (subject to group vote) | |
22 | # | |
23 | # Revision 1.10 1993/08/11 03:15:20 alm | |
24 | # added rules .f.po (and .f.o) from Jonas. | |
25 | # | |
26 | # Revision 1.9 1993/08/05 18:45:53 nate | |
27 | # Removed the ranlib statements from before the install (since it's done | |
28 | # after the install as well), and changed ranlib -> ${RANLIB} | |
29 | # | |
30 | # Revision 1.8 1993/08/03 20:57:34 nate | |
31 | # Fixed macros so that you can do a | |
32 | # make maninstall at all times and have it not blow up | |
33 | # | |
34 | # Revision 1.7 1993/07/23 20:44:38 nate | |
35 | # Fixed a boo-boo and made the NOMAN environment variable work correctly with | |
36 | # both programs and libraries. | |
37 | # | |
38 | # Revision 1.6 1993/07/09 00:38:35 jkh | |
39 | # Removed $History$ line from hell (no leading #). | |
40 | # | |
41 | # Revision 1.5 1993/07/08 12:17:07 paul | |
42 | # Removed the core.* before disaster strikes. | |
43 | # I removed core as well since it's pretty redundant. | |
44 | # | |
45 | # Revision 1.4 1993/07/07 21:42:45 nate | |
46 | # Cleaned up header files and added core.* to clean directives | |
47 | # | |
48 | # Revision 1.3 1993/07/02 06:44:30 root | |
49 | # New manual page system | |
50 | # | |
51 | # Revision 1.2 1993/06/17 02:01:11 rgrimes | |
52 | # Make clean in src/lib/libc failed due to too many arguments to /bin/sh, | |
53 | # this was fixed for make cleandir in the patchkit, this fixes it for | |
54 | # make clean. | |
15637ed4 | 55 | # |
15637ed4 RG |
56 | |
57 | .if exists(${.CURDIR}/../Makefile.inc) | |
58 | .include "${.CURDIR}/../Makefile.inc" | |
59 | .endif | |
60 | ||
61 | LIBDIR?= /usr/lib | |
62 | LINTLIBDIR?= /usr/libdata/lint | |
63 | LIBGRP?= bin | |
64 | LIBOWN?= bin | |
65 | LIBMODE?= 444 | |
66 | ||
67 | STRIP?= -s | |
68 | ||
69 | BINGRP?= bin | |
70 | BINOWN?= bin | |
71 | BINMODE?= 555 | |
72 | ||
73 | .MAIN: all | |
74 | ||
75 | # prefer .s to a .c, add .po, remove stuff not used in the BSD libraries | |
78ed81a3 | 76 | #.SUFFIXES: .out .o .po .s .c .cc .cxx .C .f .y .l |
15637ed4 | 77 | .SUFFIXES: |
78ed81a3 | 78 | .SUFFIXES: .out .o .po .s .c .f .y .l |
15637ed4 RG |
79 | |
80 | .c.o: | |
81 | ${CC} ${CFLAGS} -c ${.IMPSRC} | |
82 | @${LD} -x -r ${.TARGET} | |
83 | @mv a.out ${.TARGET} | |
84 | ||
85 | .c.po: | |
86 | ${CC} -p ${CFLAGS} -c ${.IMPSRC} -o ${.TARGET} | |
87 | @${LD} -X -r ${.TARGET} | |
88 | @mv a.out ${.TARGET} | |
89 | ||
78ed81a3 | 90 | #.cc.o .cxx.o .C.o: |
91 | # ${CXX} ${CXXFLAGS} -c ${.IMPSRC} | |
92 | # @${LD} -x -r ${.TARGET} | |
93 | # @mv a.out ${.TARGET} | |
94 | ||
95 | #.cc.po .C.po .cxx.o: | |
96 | # ${CXX} -p ${CXXFLAGS} -c ${.IMPSRC} -o ${.TARGET} | |
97 | # @${LD} -X -r ${.TARGET} | |
98 | # @mv a.out ${.TARGET} | |
99 | ||
100 | .f.o: | |
101 | ${FC} ${RFLAGS} -o ${.TARGET} -c ${.IMPSRC} | |
102 | @${LD} -x -r ${.TARGET} | |
103 | @mv a.out ${.TARGET} | |
104 | ||
105 | .f.po: | |
106 | ${FC} -p ${RFLAGS} -o ${.TARGET} -c ${.IMPSRC} | |
107 | @${LD} -X -r ${.TARGET} | |
108 | @mv a.out ${.TARGET} | |
109 | ||
15637ed4 RG |
110 | .s.o: |
111 | ${CPP} -E ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} | \ | |
112 | ${AS} -o ${.TARGET} | |
113 | @${LD} -x -r ${.TARGET} | |
114 | @mv a.out ${.TARGET} | |
115 | ||
116 | .s.po: | |
117 | ${CPP} -E -DPROF ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} | \ | |
118 | ${AS} -o ${.TARGET} | |
119 | @${LD} -X -r ${.TARGET} | |
120 | @mv a.out ${.TARGET} | |
121 | ||
15637ed4 RG |
122 | .if !defined(NOPROFILE) |
123 | _LIBS=lib${LIB}.a lib${LIB}_p.a | |
124 | .else | |
125 | _LIBS=lib${LIB}.a | |
126 | .endif | |
127 | ||
78ed81a3 | 128 | all: ${_LIBS} # llib-l${LIB}.ln |
15637ed4 | 129 | |
78ed81a3 | 130 | OBJS+= ${SRCS:N*.h:R:S/$/.o/g} |
15637ed4 RG |
131 | |
132 | lib${LIB}.a:: ${OBJS} | |
133 | @echo building standard ${LIB} library | |
134 | @rm -f lib${LIB}.a | |
135 | @${AR} cTq lib${LIB}.a `lorder ${OBJS} | tsort` ${LDADD} | |
78ed81a3 | 136 | ${RANLIB} lib${LIB}.a |
15637ed4 RG |
137 | |
138 | POBJS+= ${OBJS:.o=.po} | |
139 | lib${LIB}_p.a:: ${POBJS} | |
140 | @echo building profiled ${LIB} library | |
141 | @rm -f lib${LIB}_p.a | |
142 | @${AR} cTq lib${LIB}_p.a `lorder ${POBJS} | tsort` ${LDADD} | |
78ed81a3 | 143 | ${RANLIB} lib${LIB}_p.a |
15637ed4 RG |
144 | |
145 | llib-l${LIB}.ln: ${SRCS} | |
146 | ${LINT} -C${LIB} ${CFLAGS} ${.ALLSRC:M*.c} | |
147 | ||
148 | .if !target(clean) | |
149 | clean: | |
78ed81a3 | 150 | rm -f a.out Errs errs mklog ${CLEANFILES} ${OBJS} |
151 | rm -f lib${LIB}.a llib-l${LIB}.ln | |
152 | rm -f ${POBJS} profiled/*.o lib${LIB}_p.a | |
15637ed4 RG |
153 | .endif |
154 | ||
155 | .if !target(cleandir) | |
156 | cleandir: | |
78ed81a3 | 157 | rm -f a.out Errs errs mklog ${CLEANFILES} ${OBJS} |
158 | rm -f lib${LIB}.a llib-l${LIB}.ln | |
159 | rm -f ${.CURDIR}/tags .depend | |
15637ed4 RG |
160 | rm -f ${POBJS} profiled/*.o lib${LIB}_p.a |
161 | cd ${.CURDIR}; rm -rf obj; | |
162 | .endif | |
163 | ||
164 | .if !target(depend) | |
165 | depend: .depend | |
166 | .depend: ${SRCS} | |
78ed81a3 | 167 | rm -f .depend |
168 | files="${.ALLSRC:M*.c}"; \ | |
169 | if [ "$$files" != "" ]; then \ | |
170 | mkdep -a ${MKDEP} ${CFLAGS:M-[ID]*} $$files; \ | |
171 | fi | |
172 | # files="${.ALLSRC:M*.cc} ${.ALLSRC:M*.C} ${.ALLSRC:M*.cxx}"; \ | |
173 | # if [ "$$files" != " " ]; then \ | |
174 | # mkdep -a ${MKDEP} -+ ${CXXFLAGS:M-[ID]*} $$files; \ | |
175 | # fi | |
15637ed4 | 176 | @(TMP=/tmp/_depend$$$$; \ |
78ed81a3 | 177 | sed -e 's/^\([^\.]*\).o[ ]*:/\1.o \1.po:/' < .depend > $$TMP; \ |
15637ed4 RG |
178 | mv $$TMP .depend) |
179 | .endif | |
180 | ||
181 | .if !target(install) | |
182 | .if !target(beforeinstall) | |
183 | beforeinstall: | |
184 | .endif | |
185 | ||
186 | realinstall: beforeinstall | |
15637ed4 RG |
187 | install ${COPY} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} lib${LIB}.a \ |
188 | ${DESTDIR}${LIBDIR} | |
189 | ${RANLIB} -t ${DESTDIR}${LIBDIR}/lib${LIB}.a | |
190 | .if !defined(NOPROFILE) | |
15637ed4 RG |
191 | install ${COPY} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ |
192 | lib${LIB}_p.a ${DESTDIR}${LIBDIR} | |
193 | ${RANLIB} -t ${DESTDIR}${LIBDIR}/lib${LIB}_p.a | |
194 | .endif | |
195 | # install ${COPY} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ | |
196 | # llib-l${LIB}.ln ${DESTDIR}${LINTLIBDIR} | |
197 | .if defined(LINKS) && !empty(LINKS) | |
198 | @set ${LINKS}; \ | |
199 | while test $$# -ge 2; do \ | |
200 | l=${DESTDIR}$$1; \ | |
201 | shift; \ | |
202 | t=${DESTDIR}$$1; \ | |
203 | shift; \ | |
204 | echo $$t -\> $$l; \ | |
205 | rm -f $$t; \ | |
206 | ln $$l $$t; \ | |
207 | done; true | |
208 | .endif | |
209 | ||
210 | install: afterinstall | |
78ed81a3 | 211 | .if !defined(NOMAN) |
15637ed4 | 212 | afterinstall: realinstall maninstall |
78ed81a3 | 213 | .else |
214 | afterinstall: realinstall | |
215 | .endif | |
15637ed4 RG |
216 | .endif |
217 | ||
218 | .if !target(lint) | |
219 | lint: | |
220 | .endif | |
221 | ||
222 | .if !target(tags) | |
223 | tags: ${SRCS} | |
224 | -cd ${.CURDIR}; ctags -f /dev/stdout ${.ALLSRC:M*.c} | \ | |
225 | sed "s;\${.CURDIR}/;;" > tags | |
226 | .endif | |
227 | ||
78ed81a3 | 228 | .if !defined(NOMAN) |
15637ed4 | 229 | .include <bsd.man.mk> |
78ed81a3 | 230 | .elif !target(maninstall) |
231 | maninstall: | |
232 | .endif | |
233 | ||
15637ed4 RG |
234 | .if !target(obj) |
235 | .if defined(NOOBJ) | |
236 | obj: | |
237 | .else | |
238 | obj: | |
239 | @cd ${.CURDIR}; rm -rf obj; \ | |
240 | here=`pwd`; dest=/usr/obj/`echo $$here | sed 's,/usr/src/,,'`; \ | |
241 | echo "$$here -> $$dest"; ln -s $$dest obj; \ | |
242 | if test -d /usr/obj -a ! -d $$dest; then \ | |
243 | mkdir -p $$dest; \ | |
244 | else \ | |
245 | true; \ | |
246 | fi; | |
247 | .endif | |
248 | .endif |