aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2014-09-09 12:38:27 +0200
committerGravatar Christian Hesse <mail@eworm.de>2014-09-09 12:38:27 +0200
commit750903c2014a04bcbca2c4463be67a422b443587 (patch)
tree97f729ad2131f70d242b1a3a16dc97de5526208a
parent8e08071f6a23e0975746922420fa94cd4a4c3092 (diff)
downloadcqrlogo-750903c2014a04bcbca2c4463be67a422b443587.tar.gz
cqrlogo-750903c2014a04bcbca2c4463be67a422b443587.tar.zst
allow to build binaries statically linked against libcqrlogo
-rw-r--r--.gitignore2
-rw-r--r--Makefile26
-rw-r--r--lib/.gitignore1
-rw-r--r--lib/Makefile12
4 files changed, 34 insertions, 7 deletions
diff --git a/.gitignore b/.gitignore
index f7f46a3..f822cb3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,7 +1,9 @@
config.h
cqrlogo
cqrlogo.cgi
+cqrlogo.cgi.static
cqrlogo.fcgi
+cqrlogo.fcgi.static
*.png
README.html
version.h
diff --git a/Makefile b/Makefile
index ae1762f..98bdfc6 100644
--- a/Makefile
+++ b/Makefile
@@ -17,6 +17,11 @@ SED := sed
ZBARIMG := zbarimg
# flags
CFLAGS += -O2 -Wall -Werror
+CFLAGSSTATIC = $(CFLAGS)
+CFLAGSSTATIC += -liniparser
+CFLAGSSTATIC += $(shell pkg-config --cflags --libs libpng)
+CFLAGSSTATIC += $(shell pkg-config --cflags --libs zlib)
+CFLAGSSTATIC += $(shell pkg-config --cflags --libs libqrencode)
# calls to compiled binary files
CQRLOGO_CGI += LD_LIBRARY_PATH=lib/ ./cqrlogo.cgi
CQRLOGO_FCGI += LD_LIBRARY_PATH=lib/ ./cqrlogo.fcgi
@@ -28,15 +33,26 @@ SOVERSION := 0
all: lib/libcqrlogo.so cqrlogo.cgi cqrlogo.fcgi README.html cqrlogo.png
-lib/libcqrlogo.so: lib/libcqrlogo.c lib/libcqrlogo.h config.h version.h
- SOVERSION=$(SOVERSION) $(MAKE) -C lib
+static: cqrlogo.cgi.static cqrlogo.fcgi.static
+
+lib/libcqrlogo.so: lib/Makefile lib/libcqrlogo.c lib/libcqrlogo.h config.h version.h
+ SOVERSION=$(SOVERSION) $(MAKE) -C lib libcqrlogo.so
+
+lib/libcqrlogo.o: lib/Makefile lib/libcqrlogo.c lib/libcqrlogo.h config.h version.h
+ $(MAKE) -C lib libcqrlogo.o
cqrlogo.cgi: lib/libcqrlogo.so cqrlogo.c cqrlogo.h config.h version.h
$(CC) $(CFLAGS) -lcqrlogo -Llib/ -Ilib/ $(LDFLAGS) -DHAVE_FCGI=0 -o cqrlogo.cgi cqrlogo.c
+cqrlogo.cgi.static: lib/libcqrlogo.o cqrlogo.c cqrlogo.h config.h version.h
+ $(CC) $(CFLAGSSTATIC) -Ilib/ $(LDFLAGS) -DHAVE_FCGI=0 -o cqrlogo.cgi.static cqrlogo.c lib/libcqrlogo.o
+
cqrlogo.fcgi: lib/libcqrlogo.so cqrlogo.c cqrlogo.h config.h version.h
$(CC) $(CFLAGS) -lcqrlogo -Llib/ -Ilib/ -lfcgi $(LDFLAGS) -DHAVE_FCGI=1 -o cqrlogo.fcgi cqrlogo.c
+cqrlogo.fcgi.static: lib/libcqrlogo.o cqrlogo.c cqrlogo.h config.h version.h
+ $(CC) $(CFLAGSSTATIC) -Ilib/ -lfcgi $(LDFLAGS) -DHAVE_FCGI=1 -o cqrlogo.fcgi.static cqrlogo.c lib/libcqrlogo.o
+
version.h: $(wildcard .git/HEAD .git/index .git/refs/tags/*) Makefile
echo "#ifndef VERSION" > $@
echo "#define VERSION \"$(shell git describe --tags --long 2>/dev/null || echo ${VERSION})\"" >> $@
@@ -251,10 +267,12 @@ check:
$(GREP) -e '^This QR Code has been stolen from https://eworm.net/!$$'
clean:
- $(RM) -f *.o *~ *.png README.html lib/libcqrlogo.so lib/libcqrlogo.so.* cqrlogo.cgi cqrlogo.fcgi version.h
+ $(RM) -f *.png README.html cqrlogo.cgi cqrlogo.fcgi cqrlogo.cgi.static cqrlogo.fcgi.static version.h
+ $(MAKE) -C lib clean
distclean:
- $(RM) -f *.o *~ *.png README.html lib/libcqrlogo.so lib/libcqrlogo.so.* cqrlogo.cgi cqrlogo.fcgi version.h config.h
+ $(RM) -f *~ *.png README.html cqrlogo.cgi cqrlogo.fcgi cqrlogo.cgi.static cqrlogo.fcgi.static version.h config.h
+ $(MAKE) -C lib distclean
release:
git archive --format=tar.xz --prefix=cqrlogo-$(VERSION)/ $(VERSION) > cqrlogo-$(VERSION).tar.xz
diff --git a/lib/.gitignore b/lib/.gitignore
index 6842a0a..14d8bbb 100644
--- a/lib/.gitignore
+++ b/lib/.gitignore
@@ -1,2 +1,3 @@
+libcqrlogo.o
libcqrlogo.so
libcqrlogo.so.*
diff --git a/lib/Makefile b/lib/Makefile
index b4bf444..93cd374 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -10,9 +10,15 @@ CFLAGS += $(shell pkg-config --cflags --libs libqrencode)
all: libcqrlogo.so
-libcqrlogo.so: libcqrlogo.c libcqrlogo.h ../config.h ../version.h
- $(CC) $(CFLAGS) $(LDFLAGS) -shared -fPIC -Wl,-soname,libcqrlogo.so.$(SOVERSION) -o libcqrlogo.so.$(SOVERSION) libcqrlogo.c
+libcqrlogo.o: libcqrlogo.c libcqrlogo.h ../config.h ../version.h Makefile
+ $(CC) -c $(CFLAGS) $(LDFLAGS) -fPIC -o libcqrlogo.o libcqrlogo.c
+
+libcqrlogo.so: libcqrlogo.o
+ $(CC) $(CFLAGS) $(LDFLAGS) -shared -fPIC -Wl,-soname,libcqrlogo.so.$(SOVERSION) -o libcqrlogo.so.$(SOVERSION) libcqrlogo.o
$(LN) -sf libcqrlogo.so.$(SOVERSION) libcqrlogo.so
clean:
- $(RM) -f *.o *~ libcqrlogo.so libcqrlogo.so.*
+ $(RM) -f libcqrlogo.o libcqrlogo.so libcqrlogo.so.*
+
+distclean:
+ $(RM) -f *~ libcqrlogo.o libcqrlogo.so libcqrlogo.so.*