commit 4061bacc1d235591c553bb1ba8a0d8b116a12b4b
Author:     Max Schillinger <[email protected]>
AuthorDate: Thu Sep 30 21:36:53 2021 +0200
Commit:     Hiltjo Posthuma <[email protected]>
CommitDate: Fri Oct 1 12:32:38 2021 +0200

    create layout-dependent object files
    
    When you build svkbd with different layouts, you get one binary per
    layout but all binaries are identical:
    
        $ make LAYOUT=mobile-plain
        $ make LAYOUT=mobile-simple
        $ diff -s svkbd-mobile-plain svkbd-mobile-simple
        Files svkbd-mobile-plain and svkbd-mobile-simple are identical
    
    The problem is that svkbd.o from the first build is being reused in the
    second build.
    
    This commit changes the Makefile to create layout-dependent object files
    like svkbd-mobile-plain.o and svkbd-mobile-simple.o (instead of a shared
    svkbd.o).

diff --git a/Makefile b/Makefile
index 3478218..f9e7a38 100644
--- a/Makefile
+++ b/Makefile
@@ -9,7 +9,7 @@ include config.mk
 
 BIN = ${NAME}-${LAYOUT}
 SRC = drw.c ${NAME}.c util.c
-OBJ = ${SRC:.c=.o}
+OBJ = drw.o ${NAME}-${LAYOUT}.o util.o
 MAN1 = ${NAME}.1
 
 all: ${BIN}
@@ -24,7 +24,8 @@ options:
 config.h:
        cp config.def.h $@
 
-svkbd.o: config.h layout.${LAYOUT}.h
+svkbd-${LAYOUT}.o: config.h layout.${LAYOUT}.h
+       ${CC} ${SVKBD_CFLAGS} ${SVKBD_CPPFLAGS} -c svkbd.c -o $@
 
 .c.o:
        ${CC} ${SVKBD_CFLAGS} ${SVKBD_CPPFLAGS} -c $<
@@ -35,7 +36,7 @@ ${BIN}: ${OBJ}
        ${CC} -o ${BIN} ${OBJ} ${SVKBD_LDFLAGS}
 
 clean:
-       rm -f ${NAME}-?? ${NAME}-??.o ${OBJ} ${BIN}
+       rm -f ${NAME}-?? ${NAME}-*.o ${OBJ} ${BIN}
 
 dist:
        rm -rf "${NAME}-${VERSION}"

Reply via email to