.PHONY: all clean test install # Add .lo to the list of implicit rules suffixes. .SUFFIXES: .lo LIBNAME= sitalibs VERSION= 1 DESTDIR?= SRCS= socket.c strl.c INCLS= socket.h strl.h DEBUG?= -g CFLAGS?= -W -Werror -Wall -std=c99 -posix INSTALLFLAGS?= -o root -g root CFLAGS+= ${DEBUG} LIB_A= lib${LIBNAME}.a LIB_SO= lib${LIBNAME}.la OBJS_A= ${SRCS:.c=.o} OBJS_SO= ${SRCS:.c=.lo} OBJS= ${LIB_A} ${LIB_SO} ${OBJS_A} ${OBJS_SO} all: ${LIB_A} ${LIB_SO} clean: libtool --mode=clean /bin/rm rm -f ${OBJS} test: ${LIB_A} make -C tests install: ${LIB_A} ${LIB_SO} mkdir -p ${DESTDIR}/usr/lib chmod 755 ${DESTDIR}/usr/lib mkdir -p ${DESTDIR}/usr/include/${LIBNAME} chmod 755 ${DESTDIR}/usr/include/${LIBNAME} for lib in ${LIB_A} ${LIB_SO} ; do \ libtool --mode=install install ${INSTALLFLAGS} -m 644 $$lib ${DESTDIR}/usr/lib ;\ done for incl in ${INCLS} ; do \ libtool --mode=install install ${INSTALLFLAGS} -m 644 $$incl ${DESTDIR}/usr/include/${LIBNAME} ;\ done # Common dependency for all generated files. ${OBJS}: Makefile ${LIB_A}: ${OBJS_A} libtool --mode=link ${CC} -o $@ $^ -static # -rpath is mandatory, libtool --mode=install will fail otherwise. ${LIB_SO}: ${OBJS_SO} libtool --mode=link ${CC} -o $@ $^ -version-number ${VERSION} -rpath ${DESTDIR}/usr/lib %.o %.lo : %.c %.h libtool --mode=compile ${CC} -c ${CPPFLAGS} ${CFLAGS} -o $@ $<