Year update.
[dhcpcd-ui] / mk / lib.mk
1 # rules to build a library
2
3 SHLIB=                  lib${LIB}.so.${SHLIB_MAJOR}
4 SHLIB_LINK=             lib${LIB}.so
5 LIBNAME=                lib${LIB}.a
6 SONAME?=                ${SHLIB}
7
8 OBJS+=                  ${SRCS:.c=.o}
9 SOBJS+=                 ${OBJS:.o=.So}
10 LIBS?=                  ${LIBNAME} ${SHLIB}
11
12 CLEANFILES+=            ${OBJS} ${SOBJS} ${LIBS} ${SHLIB_LINK}
13
14 LIBINSTALL?=            _libinstall
15
16 .SUFFIXES:              .So
17
18 .c.o:
19         ${CC} ${CFLAGS} ${CPPFLAGS} -c $< -o $@
20
21 .c.So:
22         ${CC} ${PICFLAG} -DPIC ${CPPFLAGS} ${CFLAGS} -c $< -o $@
23
24 all: depend ${LIBS}
25
26 ${LIBNAME}:     ${OBJS} ${STATICOBJS}
27         @${ECHO} building static library $@
28         ${AR} cr $@ ${STATICOBJS} ${OBJS}
29         ${RANLIB} $@
30
31 ${SHLIB}:       ${SOBJS}
32         @${ECHO} building shared library $@
33         @rm -f $@ ${SHLIB_LINK}
34         @ln -fs $@ ${SHLIB_LINK}
35         ${CC} ${LDFLAGS} -shared -Wl,-x -o $@ -Wl,-soname,${SONAME} \
36                 ${SOBJS} ${LDADD}
37
38 _libinstall:    all
39         ${INSTALL} -d ${DESTDIR}${LIBDIR}
40         ${INSTALL} -m ${LIBMODE} ${LIBNAME} ${DESTDIR}${LIBDIR}
41         ${INSTALL} -d ${DESTDIR}${SHLIBDIR}
42         ${INSTALL} -m ${LIBMODE} ${SHLIB} ${DESTDIR}${SHLIBDIR}
43         ln -fs ${SHLIB} ${DESTDIR}${SHLIBDIR}/${SHLIB_LINK}
44         ${INSTALL} -d ${DESTDIR}${INCDIR}
45         for x in ${INCS}; do ${INSTALL} -m ${INCMODE} $$x ${DESTDIR}${INCDIR}; done
46
47 install: ${LIBINSTALL}
48
49 proginstall: install
50
51 clean:
52         rm -f ${OBJS} ${SOBJS} ${LIBS} ${SHLIB_LINK} ${CLEANFILES}
53
54 extra_depend:
55         @TMP=depend.$$$$; \
56         ${SED} -e 's/^\([^\.]*\).o[ ]*:/\1.o \1.So:/' .depend > $${TMP}; \
57         mv $${TMP} .depend
58
59 include ${MKDIR}/sys.mk
60 include ${MKDIR}/depend.mk