commit 3fe7bcc7a48ead2aa6246d2e78de64c74d8508f9
parent 13d20da8efda2fc025279cf22b8b66bd0beff6c7
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date: Sun, 2 Aug 2020 18:23:30 +0200
Makefile, config.mk: use pkg-config, fix config.h rule + tweaks
Diffstat:
2 files changed, 19 insertions(+), 8 deletions(-)
diff --git a/Makefile b/Makefile
@@ -9,7 +9,7 @@ include config.mk
BIN = ${NAME}-${LAYOUT}
SRC = drw.c ${NAME}.c util.c
-OBJ = ${NAME}-${LAYOUT}.o
+OBJ = ${SRC:.c=.o}
MAN1 = ${NAME}.1
all: ${BIN}
@@ -24,11 +24,16 @@ options:
config.h:
cp config.def.h $@
-${BIN}:
- ${CC} -o $@ ${SRC} ${SVKBD_CFLAGS} ${SVKBD_CPPFLAGS} ${SVKBD_LDFLAGS}
+.c.o:
+ ${CC} ${SVKBD_CFLAGS} ${SVKBD_CPPFLAGS} -c $<
+
+${OBJ}: config.h config.mk
+
+${BIN}: ${OBJ}
+ ${CC} -o ${BIN} ${OBJ} ${SVKBD_LDFLAGS}
clean:
- rm -f ${NAME}-?? ${NAME}-??.o ${OBJ}
+ rm -f ${NAME}-?? ${NAME}-??.o ${OBJ} ${BIN}
dist:
rm -rf "${NAME}-${VERSION}"
diff --git a/config.mk b/config.mk
@@ -7,15 +7,21 @@ MANPREFIX = ${PREFIX}/share/man
X11INC = /usr/X11R6/include
X11LIB = /usr/X11R6/lib
+PKG_CONFIG = pkg-config
+
# Xinerama, comment if you don't want it
XINERAMALIBS = -L${X11LIB} -lXinerama
XINERAMAFLAGS = -DXINERAMA
# includes and libs
-INCS = -I. -I./layouts -I${X11INC} -I/usr/include/freetype2
-LIBS = -L${X11LIB} -lX11 -lXtst -lfontconfig -lXft ${XINERAMALIBS}
+INCS = -I. -I./layouts -I${X11INC} \
+ `$(PKG_CONFIG) --cflags fontconfig` \
+ `$(PKG_CONFIG) --cflags freetype2`
+LIBS = -L${X11LIB} -lX11 -lXtst -lXft ${XINERAMALIBS} \
+ `$(PKG_CONFIG) --libs fontconfig` \
+ `$(PKG_CONFIG) --libs freetype2`
# use system flags
-SVKBD_CFLAGS = ${CFLAGS}
+SVKBD_CFLAGS = ${CFLAGS} ${INCS}
SVKBD_LDFLAGS = ${LDFLAGS} ${LIBS}
-SVKBD_CPPFLAGS = ${CPPFLAGS} ${INCS} -DVERSION=\"VERSION\" ${XINERAMAFLAGS} -DLAYOUT=\"layout.${LAYOUT}.h\"
+SVKBD_CPPFLAGS = ${CPPFLAGS} -DVERSION=\"VERSION\" ${XINERAMAFLAGS} -DLAYOUT=\"layout.${LAYOUT}.h\"