@ -51,8 +51,9 @@ CFLAGS += -O1
# ---- Targets to build ----
LIBSRC = qrcodegen
LIBFILE = libqrcodegen.so
LIB = qrcodegen
LIBFILE = lib$( LIB) .a
LIBOBJ = qrcodegen.o
MAINS = qrcodegen-demo qrcodegen-test qrcodegen-worker
# Build all binaries
@ -60,16 +61,29 @@ all: $(LIBFILE) $(MAINS)
# Delete build output
clean :
rm -f -- $( LIBFILE) $( MAINS)
# Shared library
$(LIBFILE) : $( LIBSRC :=.c ) $( LIBSRC :=.h )
$( CC) $( CFLAGS) -fPIC -shared -o $@ $( LIBSRC:= .c)
rm -f -- $( LIBOBJ) $( LIBFILE) $( MAINS:= .o) $( MAINS)
rm -rf .deps
# Executable files
% : %.c $( LIBFILE )
$( CC) $( CFLAGS) -o $@ $^
% : %.o $( LIBFILE )
$( CC) $( CFLAGS) -o $@ $< -L . -l $( LIB)
# Special executable
qrcodegen-test : qrcodegen -test .c $( LIBSRC :=.c ) $( LIBSRC :=.h )
$( CC) $( CFLAGS) -DQRCODEGEN_TEST -o $@ $< $( LIBSRC:= .c)
qrcodegen-test : qrcodegen -test .c $( LIBOBJ :%.o =%.c )
$( CC) $( CFLAGS) -DQRCODEGEN_TEST -o $@ $^
# The library
$(LIBFILE) : $( LIBOBJ )
$( AR) -crs $@ -- $^
# Object files
%.o : %.c .deps /timestamp
$( CC) $( CFLAGS) -c -o $@ -MMD -MF .deps/$* .d $<
# Have a place to store header dependencies automatically generated by compiler
.deps/timestamp :
mkdir -p .deps
touch .deps/timestamp
# Make use of said dependencies if available
- i n c l u d e . d e p s / * . d