1 # from: @(#)bsd.lib.mk 5.26 (Berkeley) 5/2/91
7 # Set up the variables controlling shared libraries. After this section,
8 # SHLIB_NAME will be defined only if we are to create a shared library.
9 # SHLIB_LINK will be defined only if we are to create a link to it.
10 # INSTALL_PIC_ARCHIVE will be defined only if we are to create a PIC archive.
13 .undef INSTALL_PIC_ARCHIVE
15 .if
!defined
(SHLIB
) && defined
(LIB
)
18 .if
!defined
(SHLIB_NAME
) && defined
(SHLIB
) && defined
(SHLIB_MAJOR
)
19 SHLIB_NAME
= lib
${SHLIB}.so.
${SHLIB_MAJOR}
21 .if defined
(SHLIB_NAME
) && !empty
(SHLIB_NAME
:M
*.so.
*)
22 SHLIB_LINK?
= ${SHLIB_NAME
:R
}
24 SONAME?
= ${SHLIB_NAME}
27 .if defined
(CRUNCH_CFLAGS
)
28 CFLAGS
+= ${CRUNCH_CFLAGS}
31 .if
${MK_ASSERT_DEBUG} == "no"
36 .if defined
(DEBUG_FLAGS
)
37 CFLAGS
+= ${DEBUG_FLAGS}
39 .if
!defined
(NO_CTF
) && (${DEBUG_FLAGS
:M-g
} != "")
44 .if
!defined
(DEBUG_FLAGS
)
48 .
include <bsd.libnames.mk
>
50 # prefer .s to a .c, add .po, remove stuff not used in the BSD libraries
51 # .So used for PIC object files
53 .SUFFIXES
: .out .o .po .So .S .asm .s .c .
cc .
cpp .
cxx .m .C .f .y .l .ln
56 .if
${MACHINE_ARCH} == "sparc64"
70 ${CC} ${PO_FLAG} ${CFLAGS} -c
${.IMPSRC
} -o
${.TARGET
}
71 .if defined
(CTFCONVERT
)
72 ${CTFCONVERT} ${CTFFLAGS} ${.TARGET
}
76 ${CC} ${PICFLAG} -DPIC
${CFLAGS} -c
${.IMPSRC
} -o
${.TARGET
}
77 .if defined
(CTFCONVERT
)
78 ${CTFCONVERT} ${CTFFLAGS} ${.TARGET
}
81 .
cc.po .C.po .
cpp.po .
cxx.po
:
82 ${CXX} ${PO_FLAG} ${CXXFLAGS} -c
${.IMPSRC
} -o
${.TARGET
}
84 .
cc.So .C.So .
cpp.So .
cxx.So
:
85 ${CXX} ${PICFLAG} -DPIC
${CXXFLAGS} -c
${.IMPSRC
} -o
${.TARGET
}
88 ${FC} -pg
${FFLAGS} -o
${.TARGET
} -c
${.IMPSRC
}
89 .if defined
(CTFCONVERT
)
90 ${CTFCONVERT} ${CTFFLAGS} ${.TARGET
}
94 ${FC} ${PICFLAG} -DPIC
${FFLAGS} -o
${.TARGET
} -c
${.IMPSRC
}
95 .if defined
(CTFCONVERT
)
96 ${CTFCONVERT} ${CTFFLAGS} ${.TARGET
}
100 ${OBJC} ${OBJCFLAGS} -pg
-c
${.IMPSRC
} -o
${.TARGET
}
101 .if defined
(CTFCONVERT
)
102 ${CTFCONVERT} ${CTFFLAGS} ${.TARGET
}
106 ${OBJC} ${PICFLAG} -DPIC
${OBJCFLAGS} -c
${.IMPSRC
} -o
${.TARGET
}
107 .if defined
(CTFCONVERT
)
108 ${CTFCONVERT} ${CTFFLAGS} ${.TARGET
}
112 ${AS} ${AFLAGS} -o
${.TARGET
} ${.IMPSRC
}
113 .if defined
(CTFCONVERT
)
114 ${CTFCONVERT} ${CTFFLAGS} ${.TARGET
}
118 ${CC} -x assembler-with-cpp
-DPROF
${CFLAGS} -c
${.IMPSRC
} -o
${.TARGET
}
119 .if defined
(CTFCONVERT
)
120 ${CTFCONVERT} ${CTFFLAGS} ${.TARGET
}
124 ${CC} -x assembler-with-cpp
${PICFLAG} -DPIC
${CFLAGS} \
125 -c
${.IMPSRC
} -o
${.TARGET
}
126 .if defined
(CTFCONVERT
)
127 ${CTFCONVERT} ${CTFFLAGS} ${.TARGET
}
131 ${CC} -DPROF
${CFLAGS} -c
${.IMPSRC
} -o
${.TARGET
}
132 .if defined
(CTFCONVERT
)
133 ${CTFCONVERT} ${CTFFLAGS} ${.TARGET
}
137 ${CC} ${PICFLAG} -DPIC
${CFLAGS} -c
${.IMPSRC
} -o
${.TARGET
}
138 .if defined
(CTFCONVERT
)
139 ${CTFCONVERT} ${CTFFLAGS} ${.TARGET
}
144 .
include <bsd.symver.mk
>
146 # Allow libraries to specify their own version map or have it
147 # automatically generated (see bsd.symver.mk above).
148 .if
${MK_SYMVER} == "yes" && !empty
(VERSION_MAP
)
149 ${SHLIB_NAME}: ${VERSION_MAP}
150 LDFLAGS
+= -Wl
,--version-script
=${VERSION_MAP}
153 .if defined
(LIB
) && !empty
(LIB
) || defined
(SHLIB_NAME
)
154 OBJS
+= ${SRCS
:N
*.h
:R
:S
/$/.o
/}
157 .if defined
(LIB
) && !empty
(LIB
)
160 lib
${LIB}.a
: ${OBJS} ${STATICOBJS}
161 @
${ECHO} building static
${LIB} library
164 @
${AR} cq
${.TARGET
} `lorder ${OBJS} ${STATICOBJS} | tsort -q` ${ARADD}
166 @
${AR} cq
${.TARGET
} `NM='${NM}' lorder ${OBJS} ${STATICOBJS} | tsort -q` ${ARADD}
171 .if
!defined
(INTERNALLIB
)
173 .if
${MK_PROFILE} != "no" && defined
(LIB
) && !empty
(LIB
)
174 _LIBS
+= lib
${LIB}_p.a
175 POBJS
+= ${OBJS
:.o
=.po
} ${STATICOBJS
:.o
=.po
}
177 lib
${LIB}_p.a
: ${POBJS}
178 @
${ECHO} building profiled
${LIB} library
181 @
${AR} cq
${.TARGET
} `lorder ${POBJS} | tsort -q` ${ARADD}
183 @
${AR} cq
${.TARGET
} `NM='${NM}' lorder ${POBJS} | tsort -q` ${ARADD}
188 .if defined
(SHLIB_NAME
) || \
189 defined
(INSTALL_PIC_ARCHIVE
) && defined
(LIB
) && !empty
(LIB
)
190 SOBJS
+= ${OBJS
:.o
=.So
}
193 .if defined
(SHLIB_NAME
)
194 _LIBS
+= ${SHLIB_NAME}
196 ${SHLIB_NAME}: ${SOBJS}
197 @
${ECHO} building shared library
${SHLIB_NAME}
198 @
rm -f
${.TARGET
} ${SHLIB_LINK}
199 .if defined
(SHLIB_LINK
)
200 @ln
-fs
${.TARGET
} ${SHLIB_LINK}
203 @
${CC} ${LDFLAGS} -shared
-Wl
,-x \
204 -o
${.TARGET
} -Wl
,-soname
,${SONAME} \
205 `lorder ${SOBJS} | tsort -q` ${LDADD}
207 @
${CC} ${LDFLAGS} -shared
-Wl
,-x \
208 -o
${.TARGET
} -Wl
,-soname
,${SONAME} \
209 `NM='${NM}' lorder ${SOBJS} | tsort -q` ${LDADD}
211 .if defined
(CTFMERGE
)
212 ${CTFMERGE} ${CTFFLAGS} -o
${.TARGET
} ${SOBJS}
216 .if defined
(INSTALL_PIC_ARCHIVE
) && defined
(LIB
) && !empty
(LIB
) && ${MK_TOOLCHAIN} != "no"
217 _LIBS
+= lib
${LIB}_pic.a
219 lib
${LIB}_pic.a
: ${SOBJS}
220 @
${ECHO} building special pic
${LIB} library
222 @
${AR} cq
${.TARGET
} ${SOBJS} ${ARADD}
226 .if defined
(WANT_LINT
) && !defined
(NO_LINT
) && defined
(LIB
) && !empty
(LIB
)
227 LINTLIB
= llib-l
${LIB}.ln
229 LINTOBJS
+= ${SRCS
:M
*.c
:.c
=.ln
}
231 ${LINTLIB}: ${LINTOBJS}
232 @
${ECHO} building lint library
${.TARGET
}
234 ${LINT} ${LINTLIBFLAGS} ${CFLAGS
:M-
[DIU
]*} ${.ALLSRC
}
237 .
endif # !defined(INTERNALLIB)
241 .if
${MK_MAN} != "no"
247 sed
-e
's/^\([^\.]*\).o[ ]*:/\1.o \1.po \1.So:/' < ${DEPENDFILE} \
249 mv
$$TMP ${DEPENDFILE}
250 .if
!defined
(NO_EXTRADEPEND
) && defined
(SHLIB_NAME
)
251 .if defined
(DPADD
) && !empty
(DPADD
)
252 echo
${SHLIB_NAME}: ${DPADD} >> ${DEPENDFILE}
258 .if defined
(PRECIOUSLIB
)
259 .if
!defined
(NO_FSCHG
)
260 SHLINSTALLFLAGS
+= -fschg
265 _INSTALLFLAGS
:= ${INSTALLFLAGS}
266 .for ie in
${INSTALLFLAGS_EDIT}
267 _INSTALLFLAGS
:= ${_INSTALLFLAGS
${ie}}
269 _SHLINSTALLFLAGS
:= ${SHLINSTALLFLAGS}
270 .for ie in
${INSTALLFLAGS_EDIT}
271 _SHLINSTALLFLAGS
:= ${_SHLINSTALLFLAGS
${ie}}
274 .if
!defined
(INTERNALLIB
)
275 realinstall
: _libinstall
276 .ORDER
: beforeinstall _libinstall
278 .if defined
(LIB
) && !empty
(LIB
) && ${MK_INSTALLLIB} != "no"
279 ${INSTALL} -C
-o
${LIBOWN} -g
${LIBGRP} -m
${LIBMODE} \
280 ${_INSTALLFLAGS} lib
${LIB}.a
${DESTDIR}${LIBDIR}
282 .if
${MK_PROFILE} != "no" && defined
(LIB
) && !empty
(LIB
)
283 ${INSTALL} -C
-o
${LIBOWN} -g
${LIBGRP} -m
${LIBMODE} \
284 ${_INSTALLFLAGS} lib
${LIB}_p.a
${DESTDIR}${LIBDIR}
286 .if defined
(SHLIB_NAME
)
287 ${INSTALL} ${STRIP} -o
${LIBOWN} -g
${LIBGRP} -m
${LIBMODE} \
288 ${_INSTALLFLAGS} ${_SHLINSTALLFLAGS} \
289 ${SHLIB_NAME} ${DESTDIR}${SHLIBDIR}
290 .if defined
(SHLIB_LINK
)
291 .if
${SHLIBDIR} == ${LIBDIR}
292 ln
-fs
${SHLIB_NAME} ${DESTDIR}${LIBDIR}/${SHLIB_LINK}
294 ln
-fs
${_SHLIBDIRPREFIX}${SHLIBDIR}/${SHLIB_NAME} \
295 ${DESTDIR}${LIBDIR}/${SHLIB_LINK}
296 .if exists
(${DESTDIR}${LIBDIR}/${SHLIB_NAME})
297 -chflags noschg
${DESTDIR}${LIBDIR}/${SHLIB_NAME}
298 rm -f
${DESTDIR}${LIBDIR}/${SHLIB_NAME}
303 .if defined
(INSTALL_PIC_ARCHIVE
) && defined
(LIB
) && !empty
(LIB
) && ${MK_TOOLCHAIN} != "no"
304 ${INSTALL} -o
${LIBOWN} -g
${LIBGRP} -m
${LIBMODE} \
305 ${_INSTALLFLAGS} lib
${LIB}_pic.a
${DESTDIR}${LIBDIR}
307 .if defined
(WANT_LINT
) && !defined
(NO_LINT
) && defined
(LIB
) && !empty
(LIB
)
308 ${INSTALL} -o
${LIBOWN} -g
${LIBGRP} -m
${LIBMODE} \
309 ${_INSTALLFLAGS} ${LINTLIB} ${DESTDIR}${LINTLIBDIR}
311 .
endif # !defined(INTERNALLIB)
313 .
include <bsd.nls.mk
>
314 .
include <bsd.files.mk
>
315 .
include <bsd.incs.mk
>
316 .
include <bsd.links.mk
>
318 .if
${MK_MAN} != "no"
319 realinstall
: _maninstall
320 .ORDER
: beforeinstall _maninstall
327 ${LINT} ${LINTFLAGS} ${CFLAGS
:M-
[DIU
]*} ${.ALLSRC
}
330 .if
${MK_MAN} != "no"
331 .
include <bsd.man.mk
>
334 .
include <bsd.dep.mk
>
336 .if
!exists
(${.OBJDIR
}/${DEPENDFILE})
337 .if defined
(LIB
) && !empty
(LIB
)
338 ${OBJS} ${STATICOBJS} ${POBJS}: ${SRCS
:M
*.h
}
339 .for _S in
${SRCS
:N
*.
[hly
]}
343 .if defined
(SHLIB_NAME
) || \
344 defined
(INSTALL_PIC_ARCHIVE
) && defined
(LIB
) && !empty
(LIB
)
345 ${SOBJS}: ${SRCS
:M
*.h
}
346 .for _S in
${SRCS
:N
*.
[hly
]}
354 .if defined
(CLEANFILES
) && !empty
(CLEANFILES
)
357 .if defined
(LIB
) && !empty
(LIB
)
358 rm -f a.out
${OBJS} ${OBJS
:S
/$/.tmp
/} ${STATICOBJS}
360 .if
!defined
(INTERNALLIB
)
361 .if
${MK_PROFILE} != "no" && defined
(LIB
) && !empty
(LIB
)
362 rm -f
${POBJS} ${POBJS
:S
/$/.tmp
/}
364 .if defined
(SHLIB_NAME
) || \
365 defined
(INSTALL_PIC_ARCHIVE
) && defined
(LIB
) && !empty
(LIB
)
366 rm -f
${SOBJS} ${SOBJS
:.So
=.so
} ${SOBJS
:S
/$/.tmp
/}
368 .if defined
(SHLIB_NAME
)
369 .if defined
(SHLIB_LINK
)
372 .if defined
(LIB
) && !empty
(LIB
)
373 rm -f lib
${LIB}.so.
* lib
${LIB}.so
376 .if defined
(WANT_LINT
) && defined
(LIB
) && !empty
(LIB
)
379 .
endif # !defined(INTERNALLIB)
380 .if defined
(_LIBS
) && !empty
(_LIBS
)
383 .if defined
(CLEANDIRS
) && !empty
(CLEANDIRS
)
386 .if
!empty
(VERSION_DEF
) && !empty
(SYMBOL_MAPS
)
391 .
include <bsd.obj.mk
>
393 .
include <bsd.sys.mk
>