1 # from: @(#)bsd.lib.mk 5.26 (Berkeley) 5/2/91
2 # $FreeBSD: src/share/mk/bsd.lib.mk,v 1.91.2.15 2002/08/07 16:31:50 ru Exp $
3 # $DragonFly: src/share/mk/bsd.lib.mk,v 1.17 2008/05/19 10:26:02 corecode Exp $
8 # Set up the variables controlling shared libraries. After this section,
9 # SHLIB_NAME will be defined only if we are to create a shared library.
10 # SHLIB_LINK will be defined only if we are to create a link to it.
11 # INSTALL_PIC_ARCHIVE will be defined only if we are to create a PIC archive.
14 .undef INSTALL_PIC_ARCHIVE
16 .if
!defined
(SHLIB_NAME
) && defined
(LIB
) && defined
(SHLIB_MAJOR
)
17 SHLIB_NAME
= lib
${LIB}.so.
${SHLIB_MAJOR}
19 .if defined
(SHLIB_NAME
) && ${SHLIB_NAME
:M
*.so.
*}
20 SHLIB_LINK?
= ${SHLIB_NAME
:R
}
22 SONAME?
= ${SHLIB_NAME}
25 .if defined
(DEBUG_FLAGS
)
26 CFLAGS
+= ${DEBUG_FLAGS}
29 .if
!defined
(DEBUG_FLAGS
)
33 .
include <bsd.libnames.mk
>
35 TARGET_LIBDIR?
= ${LIBDIR}
36 TARGET_DEBUGLIBDIR?
= ${DEBUGLIBDIR}
37 TARGET_PROFLIBDIR?
= ${PROFLIBDIR}
38 TARGET_SHLIBDIR?
= ${SHLIBDIR}
40 # prefer .s to a .c, add .po, remove stuff not used in the BSD libraries
41 # .So used for PIC object files
43 .SUFFIXES
: .out .o .po .So .S .s .c .
cc .
cpp .
cxx .m .C .f .y .l
52 ${CC} ${CFLAGS} -c
${.IMPSRC
} -o
${.TARGET
}
53 @
${LD} -o
${.TARGET
}.tmp
-x
-r
${.TARGET
}
54 @mv
${.TARGET
}.tmp
${.TARGET
}
57 ${CC} ${PO_FLAG} ${CFLAGS} -c
${.IMPSRC
} -o
${.TARGET
}
58 @
${LD} -o
${.TARGET
}.tmp
-X
-r
${.TARGET
}
59 @mv
${.TARGET
}.tmp
${.TARGET
}
62 ${CC} ${PICFLAG} -DPIC
${CFLAGS} -c
${.IMPSRC
} -o
${.TARGET
}
63 @
${LD} ${LDFLAGS} -o
${.TARGET
}.tmp
-x
-r
${.TARGET
}
64 @mv
${.TARGET
}.tmp
${.TARGET
}
66 .
cc.o .C.o .
cpp.o .
cxx.o
:
67 ${CXX} ${CXXFLAGS} -c
${.IMPSRC
} -o
${.TARGET
}
68 @
${LD} -o
${.TARGET
}.tmp
-x
-r
${.TARGET
}
69 @mv
${.TARGET
}.tmp
${.TARGET
}
71 .
cc.po .C.po .
cpp.po .
cxx.po
:
72 ${CXX} ${PO_FLAG} ${CXXFLAGS} -c
${.IMPSRC
} -o
${.TARGET
}
73 @
${LD} -o
${.TARGET
}.tmp
-X
-r
${.TARGET
}
74 @mv
${.TARGET
}.tmp
${.TARGET
}
76 .
cc.So .C.So .
cpp.So .
cxx.So
:
77 ${CXX} ${PICFLAG} -DPIC
${CXXFLAGS} -c
${.IMPSRC
} -o
${.TARGET
}
78 @
${LD} ${LDFLAGS} -o
${.TARGET
}.tmp
-x
-r
${.TARGET
}
79 @mv
${.TARGET
}.tmp
${.TARGET
}
82 ${FC} ${FFLAGS} -o
${.TARGET
} -c
${.IMPSRC
}
83 @
${LD} -o
${.TARGET
}.tmp
-x
-r
${.TARGET
}
84 @mv
${.TARGET
}.tmp
${.TARGET
}
87 ${FC} -pg
${FFLAGS} -o
${.TARGET
} -c
${.IMPSRC
}
88 @
${LD} -o
${.TARGET
}.tmp
-X
-r
${.TARGET
}
89 @mv
${.TARGET
}.tmp
${.TARGET
}
92 ${FC} ${PICFLAG} -DPIC
${FFLAGS} -o
${.TARGET
} -c
${.IMPSRC
}
93 @
${LD} ${LDFLAGS} -o
${.TARGET
}.tmp
-x
-r
${.TARGET
}
94 @mv
${.TARGET
}.tmp
${.TARGET
}
97 ${OBJC} ${OBJCFLAGS} -c
${.IMPSRC
} -o
${.TARGET
}
98 @
${LD} -o
${.TARGET
}.tmp
-x
-r
${.TARGET
}
99 @mv
${.TARGET
}.tmp
${.TARGET
}
102 ${OBJC} ${OBJCFLAGS} -pg
-c
${.IMPSRC
} -o
${.TARGET
}
103 @
${LD} -o
${.TARGET
}.tmp
-X
-r
${.TARGET
}
104 @mv
${.TARGET
}.tmp
${.TARGET
}
107 ${OBJC} ${PICFLAG} -DPIC
${OBJCFLAGS} -c
${.IMPSRC
} -o
${.TARGET
}
108 @
${LD} ${LDFLAGS} -o
${.TARGET
}.tmp
-x
-r
${.TARGET
}
109 @mv
${.TARGET
}.tmp
${.TARGET
}
112 ${CC} -x assembler-with-cpp
${CFLAGS} ${AINC} -c \
113 ${.IMPSRC
} -o
${.TARGET
}
114 @
${LD} ${LDFLAGS} -o
${.TARGET
}.tmp
-x
-r
${.TARGET
}
115 @mv
${.TARGET
}.tmp
${.TARGET
}
118 ${CC} -x assembler-with-cpp
-DPROF
${CFLAGS} ${AINC} -c \
119 ${.IMPSRC
} -o
${.TARGET
}
120 @
${LD} ${LDFLAGS} -o
${.TARGET
}.tmp
-X
-r
${.TARGET
}
121 @mv
${.TARGET
}.tmp
${.TARGET
}
124 ${CC} -x assembler-with-cpp
${PICFLAG} -DPIC
${CFLAGS} \
125 ${AINC} -c
${.IMPSRC
} -o
${.TARGET
}
126 @
${LD} -o
${.TARGET
}.tmp
-x
-r
${.TARGET
}
127 @mv
${.TARGET
}.tmp
${.TARGET
}
130 ${CC} ${CFLAGS} ${AINC} -c
${.IMPSRC
} -o
${.TARGET
}
131 @
${LD} ${LDFLAGS} -o
${.TARGET
}.tmp
-x
-r
${.TARGET
}
132 @mv
${.TARGET
}.tmp
${.TARGET
}
135 ${CC} -DPROF
${CFLAGS} ${AINC} -c
${.IMPSRC
} -o
${.TARGET
}
136 @
${LD} ${LDFLAGS} -o
${.TARGET
}.tmp
-X
-r
${.TARGET
}
137 @mv
${.TARGET
}.tmp
${.TARGET
}
140 ${CC} ${PICFLAG} -DPIC
${CFLAGS} ${AINC} -c
${.IMPSRC
} \
142 @
${LD} -o
${.TARGET
}.tmp
-x
-r
${.TARGET
}
143 @mv
${.TARGET
}.tmp
${.TARGET
}
147 .
include <bsd.patch.mk
>
149 .if defined
(LIB
) && !empty
(LIB
) || defined
(SHLIB_NAME
)
150 OBJS
+= ${SRCS
:N
*.h
:N
*.patch
:R
:S
/$/.o
/g
}
153 .if defined
(LIB
) && !empty
(LIB
)
156 lib
${LIB}.a
: ${OBJS} ${STATICOBJS}
157 @
${ECHO} building static
${LIB} library
159 ${AR} cq
${.TARGET
} `lorder ${OBJS} ${STATICOBJS} | tsort -q` ${ARADD}
163 .if
!defined
(INTERNALLIB
) && !defined
(NOPROFILE
) && defined
(LIB
) && !empty
(LIB
)
164 _LIBS
+= lib
${LIB}_p.a
165 POBJS
+= ${OBJS
:.o
=.po
} ${STATICOBJS
:.o
=.po
}
167 lib
${LIB}_p.a
: ${POBJS}
168 @
${ECHO} building profiled
${LIB} library
170 ${AR} cq
${.TARGET
} `lorder ${POBJS} | tsort -q` ${ARADD}
174 .if
!defined
(INTERNALLIB
) && defined
(SHLIB_NAME
) || \
175 defined
(INSTALL_PIC_ARCHIVE
) && defined
(LIB
) && !empty
(LIB
)
176 SOBJS
+= ${OBJS
:.o
=.So
}
179 .if
!defined
(INTERNALLIB
) && defined
(SHLIB_NAME
)
180 _LIBS
+= ${SHLIB_NAME}
182 ${SHLIB_NAME}: ${SOBJS}
183 @
${ECHO} building shared library
${SHLIB_NAME}
184 rm -f
${.TARGET
} ${SHLIB_LINK}
185 .if defined
(SHLIB_LINK
)
186 ${LN} -fs
${.TARGET
} ${SHLIB_LINK}
188 ${CC_LINK} ${LDFLAGS} -shared
-Wl
,-x \
189 -o
${.TARGET
} -Wl
,-soname
,${SONAME} \
190 `lorder ${SOBJS} | tsort -q` ${LDADD}
193 .if defined
(INSTALL_PIC_ARCHIVE
) && defined
(LIB
) && !empty
(LIB
)
194 _LIBS
+= lib
${LIB}_pic.a
196 lib
${LIB}_pic.a
: ${SOBJS}
197 @
${ECHO} building special pic
${LIB} library
199 ${AR} cq
${.TARGET
} ${SOBJS} ${ARADD}
211 sed
-e
's/^\([^\.]*\).o[ ]*:/\1.o \1.po \1.So:/' < ${DEPENDFILE} \
213 mv
$$TMP ${DEPENDFILE}
214 .if
!defined
(NOEXTRADEPEND
) && defined
(SHLIB_NAME
)
215 .if defined
(DPADD
) && !empty
(DPADD
)
216 echo
${SHLIB_NAME}: ${DPADD} >> ${DEPENDFILE}
222 .if defined
(PRECIOUSLIB
) && !defined
(NOFSCHG
)
223 SHLINSTALLFLAGS
+= -fschg
226 _INSTALLFLAGS
:= ${INSTALLFLAGS}
227 .for ie in
${INSTALLFLAGS_EDIT}
228 _INSTALLFLAGS
:= ${_INSTALLFLAGS
${ie}}
230 _SHLINSTALLFLAGS
:= ${SHLINSTALLFLAGS}
231 .for ie in
${INSTALLFLAGS_EDIT}
232 _SHLINSTALLFLAGS
:= ${_SHLINSTALLFLAGS
${ie}}
235 .if
!defined
(INTERNALLIB
)
236 realinstall
: _libinstall
237 .ORDER
: beforeinstall _libinstall
239 .if defined
(LIB
) && !empty
(LIB
) && !defined
(NOINSTALLLIB
)
240 ${INSTALL} -C
-o
${LIBOWN} -g
${LIBGRP} -m
${LIBMODE} \
241 ${_INSTALLFLAGS} lib
${LIB}.a
${DESTDIR}${TARGET_LIBDIR}
243 .if
!defined
(NOPROFILE
) && defined
(LIB
) && !empty
(LIB
)
244 ${INSTALL} -C
-o
${LIBOWN} -g
${LIBGRP} -m
${LIBMODE} \
245 ${_INSTALLFLAGS} lib
${LIB}_p.a
${DESTDIR}${TARGET_PROFLIBDIR}/lib
${LIB}.a
247 .if defined
(SHLIB_NAME
)
248 ${INSTALL} ${STRIP} -o
${LIBOWN} -g
${LIBGRP} -m
${LIBMODE} \
249 ${_INSTALLFLAGS} ${_SHLINSTALLFLAGS} \
250 ${SHLIB_NAME} ${DESTDIR}${TARGET_SHLIBDIR}
251 .if defined
(SHLIB_LINK
)
252 ${LN} -fs
${SHLIB_NAME} ${DESTDIR}${TARGET_SHLIBDIR}/${SHLIB_LINK}
255 .if defined
(INSTALL_PIC_ARCHIVE
) && defined
(LIB
) && !empty
(LIB
)
256 ${INSTALL} -o
${LIBOWN} -g
${LIBGRP} -m
${LIBMODE} \
257 ${_INSTALLFLAGS} lib
${LIB}_pic.a
${DESTDIR}${TARGET_LIBDIR}
259 .
endif # !defined(INTERNALLIB)
261 .
include <bsd.nls.mk
>
262 .
include <bsd.files.mk
>
263 .
include <bsd.incs.mk
>
264 .
include <bsd.links.mk
>
267 realinstall
: _maninstall
268 .ORDER
: beforeinstall _maninstall
274 .
include <bsd.man.mk
>
277 .
include <bsd.dep.mk
>
279 .if
!exists
(${.OBJDIR
}/${DEPENDFILE})
280 .if defined
(LIB
) && !empty
(LIB
)
281 ${OBJS} ${STATICOBJS} ${POBJS}: ${SRCS
:M
*.h
}
283 .if defined
(SHLIB_NAME
) || \
284 defined
(INSTALL_PIC_ARCHIVE
) && defined
(LIB
) && !empty
(LIB
)
285 ${SOBJS}: ${SRCS
:M
*.h
}
291 .if defined
(CLEANFILES
) && !empty
(CLEANFILES
)
294 .if defined
(LIB
) && !empty
(LIB
)
295 rm -f a.out
${OBJS} ${OBJS
:S
/$/.tmp
/} ${STATICOBJS}
297 .if defined
(SHLIB_NAME
) || \
298 defined
(INSTALL_PIC_ARCHIVE
) && defined
(LIB
) && !empty
(LIB
)
299 rm -f
${SOBJS} ${SOBJS
:.So
=.so
} ${SOBJS
:S
/$/.tmp
/}
301 .if
!defined
(INTERNALLIB
)
302 .if
!defined
(NOPROFILE
) && defined
(LIB
) && !empty
(LIB
)
303 rm -f
${POBJS} ${POBJS
:S
/$/.tmp
/}
305 .if defined
(SHLIB_NAME
)
306 .if defined
(SHLIB_LINK
)
309 .if defined
(LIB
) && !empty
(LIB
)
310 rm -f lib
${LIB}.so.
* lib
${LIB}.so
313 .
endif # !defined(INTERNALLIB)
314 .if defined
(_LIBS
) && !empty
(_LIBS
)
317 .if defined
(CLEANDIRS
) && !empty
(CLEANDIRS
)
322 .
include <bsd.obj.mk
>
324 .
include <bsd.sys.mk
>