From f58400c634eea6f865db8486e7e174f67bb555ce Mon Sep 17 00:00:00 2001 From: Alessandro Iezzi Date: Thu, 11 May 2023 17:25:52 +0200 Subject: Change the way how to build this library --- Makefile | 49 ++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 44 insertions(+), 5 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 3a8fc53..293ea93 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,49 @@ # See LICENSE file for copyright and license details. -PREFIX=/usr/local -INSTALL_DIR=${PREFIX}/include +include config.mk -install: - cp string2.h ${INSTALL_DIR}/string2.h +all: dist tests + +dist: static shared + ./build-pc.sh -p ${PREFIX} -n ${NAME} -ln ${LIBNAME} -d "${LIBDSCR}" -v ${LIBVER} ${PC_FILE} + +static: + @make OPT='-O2 -pipe -Werror' ${LIBNAME:=.a} + rm -f ${OBJ} + +shared: + @make OPT='-O2 -pipe -Werror -fPIC' ${LIBNAME:=.so} + rm -f ${OBJ} + +debug: + @make OPT=-g all + +${LIBNAME:=.so}: ${OBJ} + ${CC} ${LDFLAGS} -shared ${OBJ} -o $@ + +${LIBNAME:=.a}: ${OBJ} + ar rcs $@ ${OBJ} + +.c.o: + ${CC} ${CFLAGS} -c $< -o $@ + +clean: + rm -f ${OBJ} ${LIBNAME}.* *.core ${PC_FILE} + cd test && make clean + +tests: dist + @make -C test + +install: dist + mkdir -p ${PREFIX}/include + mkdir -p ${PREFIX}/lib + cp src/string2.h ${PREFIX}/include/string2.h + cp ${LIBNAME:=.so} ${PREFIX}/lib/${LIBNAME:=.so} + cp ${LIBNAME:=.a} ${PREFIX}/lib/${LIBNAME:=.a} + cp ${PC_FILE} ${PKG_CONFIG_PATH}/${PC_FILE} uninstall: - rm -f ${INSTALL_DIR}/string2.h + rm -f ${PREFIX}/include/string2.h + rm -f ${PREFIX}/lib/${LIBNAME:=.so} + rm -f ${PREFIX}/lib/${LIBNAME:=.a} + rm -f ${PKG_CONFIG_PATH}/${PC_FILE} -- cgit v1.2.3