Revamped C and C++ makefiles by copying structure from another library of mine, removed shared library output from C library (from commit a3dcc36dd4
) due to problematic linkage in some enviroments.
This commit is contained in:
parent
070daf8c9e
commit
be143456be
36
c/Makefile
36
c/Makefile
|
@ -51,8 +51,9 @@ CFLAGS += -O1
|
||||||
|
|
||||||
# ---- Targets to build ----
|
# ---- Targets to build ----
|
||||||
|
|
||||||
LIBSRC = qrcodegen
|
LIB = qrcodegen
|
||||||
LIBFILE = libqrcodegen.so
|
LIBFILE = lib$(LIB).a
|
||||||
|
LIBOBJ = qrcodegen.o
|
||||||
MAINS = qrcodegen-demo qrcodegen-test qrcodegen-worker
|
MAINS = qrcodegen-demo qrcodegen-test qrcodegen-worker
|
||||||
|
|
||||||
# Build all binaries
|
# Build all binaries
|
||||||
|
@ -60,16 +61,29 @@ all: $(LIBFILE) $(MAINS)
|
||||||
|
|
||||||
# Delete build output
|
# Delete build output
|
||||||
clean:
|
clean:
|
||||||
rm -f -- $(LIBFILE) $(MAINS)
|
rm -f -- $(LIBOBJ) $(LIBFILE) $(MAINS:=.o) $(MAINS)
|
||||||
|
rm -rf .deps
|
||||||
# Shared library
|
|
||||||
$(LIBFILE): $(LIBSRC:=.c) $(LIBSRC:=.h)
|
|
||||||
$(CC) $(CFLAGS) -fPIC -shared -o $@ $(LIBSRC:=.c)
|
|
||||||
|
|
||||||
# Executable files
|
# Executable files
|
||||||
%: %.c $(LIBFILE)
|
%: %.o $(LIBFILE)
|
||||||
$(CC) $(CFLAGS) -o $@ $^
|
$(CC) $(CFLAGS) -o $@ $< -L . -l $(LIB)
|
||||||
|
|
||||||
# Special executable
|
# Special executable
|
||||||
qrcodegen-test: qrcodegen-test.c $(LIBSRC:=.c) $(LIBSRC:=.h)
|
qrcodegen-test: qrcodegen-test.c $(LIBOBJ:%.o=%.c)
|
||||||
$(CC) $(CFLAGS) -DQRCODEGEN_TEST -o $@ $< $(LIBSRC:=.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
|
||||||
|
-include .deps/*.d
|
||||||
|
|
29
cpp/Makefile
29
cpp/Makefile
|
@ -51,16 +51,35 @@ CXXFLAGS += -O1
|
||||||
|
|
||||||
# ---- Targets to build ----
|
# ---- Targets to build ----
|
||||||
|
|
||||||
LIBSRC = BitBuffer QrCode QrSegment
|
LIB = qrcodegen
|
||||||
|
LIBFILE = lib$(LIB).a
|
||||||
|
LIBOBJ = BitBuffer.o QrCode.o QrSegment.o
|
||||||
MAINS = QrCodeGeneratorDemo QrCodeGeneratorWorker
|
MAINS = QrCodeGeneratorDemo QrCodeGeneratorWorker
|
||||||
|
|
||||||
# Build all binaries
|
# Build all binaries
|
||||||
all: $(MAINS)
|
all: $(LIBFILE) $(MAINS)
|
||||||
|
|
||||||
# Delete build output
|
# Delete build output
|
||||||
clean:
|
clean:
|
||||||
rm -f -- $(MAINS)
|
rm -f -- $(LIBOBJ) $(LIBFILE) $(MAINS:=.o) $(MAINS)
|
||||||
|
rm -rf .deps
|
||||||
|
|
||||||
# Executable files
|
# Executable files
|
||||||
%: %.cpp $(LIBSRC:=.cpp) $(LIBSRC:=.hpp)
|
%: %.o $(LIBFILE)
|
||||||
$(CXX) $(CXXFLAGS) -o $@ $< $(LIBSRC:=.cpp)
|
$(CXX) $(CXXFLAGS) -o $@ $< -L . -l $(LIB)
|
||||||
|
|
||||||
|
# The library
|
||||||
|
$(LIBFILE): $(LIBOBJ)
|
||||||
|
$(AR) -crs $@ -- $^
|
||||||
|
|
||||||
|
# Object files
|
||||||
|
%.o: %.cpp .deps/timestamp
|
||||||
|
$(CXX) $(CXXFLAGS) -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
|
||||||
|
-include .deps/*.d
|
||||||
|
|
Loading…
Reference in New Issue