diff options
author | Christian Hesse <mail@eworm.de> | 2014-02-25 12:12:30 +0100 |
---|---|---|
committer | Christian Hesse <mail@eworm.de> | 2014-02-25 12:12:30 +0100 |
commit | f5f01f3ff143edd87b7e36f1b3540cbc5d42c51f (patch) | |
tree | 5c2b6f5dbbb342ccc5ba770fd4bb4f73c151c246 /Makefile | |
parent | 0f32341ead4f1534270a82c4372d84a1aaa9b0cd (diff) | |
download | cqrlogo-f5f01f3ff143edd87b7e36f1b3540cbc5d42c51f.tar.gz cqrlogo-f5f01f3ff143edd87b7e36f1b3540cbc5d42c51f.tar.zst |
build a shared library and rework parts of the code
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 110 |
1 files changed, 59 insertions, 51 deletions
@@ -1,41 +1,46 @@ # cqrlogo - CGI QR-Code logo for web services -PREFIX := /usr -LIBDIR := $(PREFIX)/lib +# pathes +PREFIX := /usr APACHECONF := /etc/apache/conf/extra/ LIGHTTPDCONF := /etc/lighttpd/conf.d/ +# commands CC := gcc -MD := markdown -INSTALL := install CP := cp +FILE := file +GREP := grep +INSTALL := install +LN := ln +MD := markdown RM := rm -ZBARIMG := zbarimg SED := sed -GREP := grep -FILE := file +ZBARIMG := zbarimg +# flags CFLAGS += -O2 -Wall -Werror -CFLAGS += -liniparser -CFLAGS += $(shell pkg-config --cflags --libs libpng) -CFLAGS += $(shell pkg-config --cflags --libs zlib) -CFLAGS += $(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 # this is just a fallback in case you do not use git but downloaded # a release tarball... VERSION := 0.4.0 -all: cqrlogo.cgi cqrlogo.fcgi README.html cqrlogo.png +all: libcqrlogo cqrlogo.cgi cqrlogo.fcgi README.html cqrlogo.png + +libcqrlogo: lib/libcqrlogo.c lib/libcqrlogo.h config.h version.h + $(MAKE) -C lib -cqrlogo.cgi: cqrlogo.c config.h version.h - $(CC) $(CFLAGS) $(LDFLAGS) -DHAVE_FCGI=0 -o cqrlogo.cgi cqrlogo.c +cqrlogo.cgi: libcqrlogo cqrlogo.c cqrlogo.h config.h version.h + $(CC) -lcqrlogo -Llib/ -Ilib/ $(LDFLAGS) -DHAVE_FCGI=0 -o cqrlogo.cgi cqrlogo.c -cqrlogo.fcgi: cqrlogo.c config.h version.h - $(CC) $(CFLAGS) -lfcgi $(LDFLAGS) -DHAVE_FCGI=1 -o cqrlogo.fcgi cqrlogo.c +cqrlogo.fcgi: libcqrlogo cqrlogo.c cqrlogo.h config.h version.h + $(CC) -lcqrlogo -Llib/ -Ilib/ -lfcgi $(LDFLAGS) -DHAVE_FCGI=1 -o cqrlogo.fcgi cqrlogo.c 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})\"" >> $@ echo "#endif" >> $@ -config.h: +config.h: config.def.h $(CP) config.def.h config.h README.html: README.md @@ -43,21 +48,24 @@ README.html: README.md cqrlogo.png: cqrlogo.cgi SERVER_NAME="github.com" HTTP_REFERER="https://github.com/eworm-de/cqrlogo" \ - QUERY_STRING='scale=4' \ - ./cqrlogo.cgi | $(SED) '1,/^$$/d' > cqrlogo.png + QUERY_STRING='scale=4' \ + $(CQRLOGO_CGI) | $(SED) '1,/^$$/d' > cqrlogo.png install: install-bin install-config install-doc -install-bin: cqrlogo.cgi cqrlogo.fcgi - $(INSTALL) -D -m0755 cqrlogo.cgi $(DESTDIR)$(LIBDIR)/cqrlogo/cqrlogo.cgi - $(INSTALL) -D -m0755 cqrlogo.fcgi $(DESTDIR)$(LIBDIR)/cqrlogo/cqrlogo.fcgi +install-bin: libcqrlogo lib/libcqrlogo.h cqrlogo.cgi cqrlogo.fcgi cqrlogo.conf + $(INSTALL) -D -m0755 lib/libcqrlogo.so.$(SOVERSION) $(DESTDIR)$(PREFIX)/lib/libcqrlogo.so.$(SOVERSION) + $(INSTALL) -D -m0755 lib/libcqrlogo.h $(DESTDIR)$(PREFIX)/include/libcqrlogo.h + $(LN) -sf libcqrlogo.so.$(SOVERSION) $(DESTDIR)$(PREFIX)/lib/libcqrlogo.so + $(INSTALL) -D -m0755 cqrlogo.cgi $(DESTDIR)$(PREFIX)/lib/cqrlogo/cqrlogo.cgi + $(INSTALL) -D -m0755 cqrlogo.fcgi $(DESTDIR)$(PREFIX)/lib/cqrlogo/cqrlogo.fcgi $(INSTALL) -D -m0644 cqrlogo.conf $(DESTDIR)/etc/cqrlogo.conf install-config: config/apache.conf config/lighttpd.conf $(INSTALL) -D -m0644 config/apache.conf $(DESTDIR)$(APACHECONF)/cqrlogo.conf $(INSTALL) -D -m0644 config/lighttpd.conf $(DESTDIR)$(LIGHTTPDCONF)/cqrlogo.conf -install-doc: README.html cqrlogo.png +install-doc: README.md README.html cqrlogo.png $(INSTALL) -D -m0644 README.md $(DESTDIR)$(PREFIX)/share/doc/cqrlogo/README.md $(INSTALL) -D -m0644 README.html $(DESTDIR)$(PREFIX)/share/doc/cqrlogo/README.html $(INSTALL) -D -m0644 cqrlogo.png $(DESTDIR)$(PREFIX)/share/doc/cqrlogo/cqrlogo.png @@ -67,184 +75,184 @@ check: $(RM) -f check.png SERVER_NAME=$(SERVER) HTTP_REFERER=http://$(SERVER)/ \ - ./cqrlogo.cgi | $(SED) '1,/^$$/d' > check.png + $(CQRLOGO_CGI) | $(SED) '1,/^$$/d' > check.png $(FILE) check.png | $(GREP) 'PNG image data' $(ZBARIMG) --raw -q check.png | $(GREP) -e '^http://$(SERVER)/$$' SERVER_NAME=$(SERVER) HTTP_REFERER=https://$(SERVER)/ HTTPS=on \ - ./cqrlogo.cgi | $(SED) '1,/^$$/d' > check.png + $(CQRLOGO_CGI) | $(SED) '1,/^$$/d' > check.png $(FILE) check.png | $(GREP) 'PNG image data' $(ZBARIMG) --raw -q check.png | $(GREP) -e '^https://$(SERVER)/$$' SERVER_NAME=$(SERVER) HTTP_REFERER=http://$(SERVER)/ \ QUERY_STRING='scale=0' \ - ./cqrlogo.cgi | $(SED) '1,/^$$/d' > \ + $(CQRLOGO_CGI) | $(SED) '1,/^$$/d' > \ check.png $(FILE) check.png | $(GREP) 'PNG image data' $(ZBARIMG) --raw -q check.png | $(GREP) -e '^http://$(SERVER)/$$' SERVER_NAME=$(SERVER) HTTP_REFERER=http://$(SERVER)/ \ QUERY_STRING='scale=4' \ - ./cqrlogo.cgi | $(SED) '1,/^$$/d' > \ + $(CQRLOGO_CGI) | $(SED) '1,/^$$/d' > \ check.png $(FILE) check.png | $(GREP) 'PNG image data' $(ZBARIMG) --raw -q check.png | $(GREP) -e '^http://$(SERVER)/$$' SERVER_NAME=$(SERVER) HTTP_REFERER=http://$(SERVER)/ \ QUERY_STRING='scale=20' \ - ./cqrlogo.cgi | $(SED) '1,/^$$/d' > \ + $(CQRLOGO_CGI) | $(SED) '1,/^$$/d' > \ check.png $(FILE) check.png | $(GREP) 'PNG image data' $(ZBARIMG) --raw -q check.png | $(GREP) -e '^http://$(SERVER)/$$' SERVER_NAME=$(SERVER) HTTP_REFERER=http://$(SERVER)/ \ QUERY_STRING='scale=2&border=0' \ - ./cqrlogo.cgi | $(SED) '1,/^$$/d' > \ + $(CQRLOGO_CGI) | $(SED) '1,/^$$/d' > \ check.png $(FILE) check.png | $(GREP) 'PNG image data' $(ZBARIMG) --raw -q check.png | $(GREP) -e '^http://$(SERVER)/$$' SERVER_NAME=$(SERVER) HTTP_REFERER=http://$(SERVER)/ \ QUERY_STRING='scale=2&border=2' \ - ./cqrlogo.cgi | $(SED) '1,/^$$/d' > \ + $(CQRLOGO_CGI) | $(SED) '1,/^$$/d' > \ check.png $(FILE) check.png | $(GREP) 'PNG image data' $(ZBARIMG) --raw -q check.png | $(GREP) -e '^http://$(SERVER)/$$' SERVER_NAME=$(SERVER) HTTP_REFERER=http://$(SERVER)/ \ QUERY_STRING='scale=2&border=10' \ - ./cqrlogo.cgi | $(SED) '1,/^$$/d' > \ + $(CQRLOGO_CGI) | $(SED) '1,/^$$/d' > \ check.png $(FILE) check.png | $(GREP) 'PNG image data' $(ZBARIMG) --raw -q check.png | $(GREP) -e '^http://$(SERVER)/$$' SERVER_NAME=$(SERVER) HTTP_REFERER=http://$(SERVER)/ \ QUERY_STRING='scale=2&border=10&level=0' \ - ./cqrlogo.cgi | $(SED) '1,/^$$/d' > \ + $(CQRLOGO_CGI) | $(SED) '1,/^$$/d' > \ check.png $(FILE) check.png | $(GREP) 'PNG image data' $(ZBARIMG) --raw -q check.png | $(GREP) -e '^http://$(SERVER)/$$' SERVER_NAME=$(SERVER) HTTP_REFERER=http://$(SERVER)/ \ QUERY_STRING='scale=2&border=10&level=2' \ - ./cqrlogo.cgi | $(SED) '1,/^$$/d' > \ + $(CQRLOGO_CGI) | $(SED) '1,/^$$/d' > \ check.png $(FILE) check.png | $(GREP) 'PNG image data' $(ZBARIMG) --raw -q check.png | $(GREP) -e '^http://$(SERVER)/$$' SERVER_NAME=$(SERVER) HTTP_REFERER=http://$(SERVER)/ \ QUERY_STRING='scale=2&border=10&level=4' \ - ./cqrlogo.cgi | $(SED) '1,/^$$/d' > \ + $(CQRLOGO_CGI) | $(SED) '1,/^$$/d' > \ check.png $(FILE) check.png | $(GREP) 'PNG image data' $(ZBARIMG) --raw -q check.png | $(GREP) -e '^http://$(SERVER)/$$' SERVER_NAME=eworm.net HTTP_REFERER=http://$(SERVER)/ \ - ./cqrlogo.cgi | $(SED) '1,/^$$/d' > \ + $(CQRLOGO_CGI) | $(SED) '1,/^$$/d' > \ check.png $(FILE) check.png | $(GREP) 'PNG image data' $(ZBARIMG) --raw -q check.png | \ $(GREP) -e '^This QR Code has been stolen from http://eworm.net/!$$' SERVER_NAME=eworm.net HTTP_REFERER=https://$(SERVER)/ HTTPS=on \ - ./cqrlogo.cgi | $(SED) '1,/^$$/d' > \ + $(CQRLOGO_CGI) | $(SED) '1,/^$$/d' > \ check.png $(FILE) check.png | $(GREP) 'PNG image data' $(ZBARIMG) --raw -q check.png | \ $(GREP) -e '^This QR Code has been stolen from https://eworm.net/!$$' SERVER_NAME=$(SERVER) HTTP_REFERER=http://$(SERVER)/ \ - ./cqrlogo.fcgi | $(SED) '1,/^$$/d' > check.png + $(CQRLOGO_FCGI) | $(SED) '1,/^$$/d' > check.png $(FILE) check.png | $(GREP) 'PNG image data' $(ZBARIMG) --raw -q check.png | $(GREP) -e '^http://$(SERVER)/$$' SERVER_NAME=$(SERVER) HTTP_REFERER=https://$(SERVER)/ HTTPS=on \ - ./cqrlogo.fcgi | $(SED) '1,/^$$/d' > check.png + $(CQRLOGO_FCGI) | $(SED) '1,/^$$/d' > check.png $(FILE) check.png | $(GREP) 'PNG image data' $(ZBARIMG) --raw -q check.png | $(GREP) -e '^https://$(SERVER)/$$' SERVER_NAME=$(SERVER) HTTP_REFERER=http://$(SERVER)/ \ QUERY_STRING='scale=0' \ - ./cqrlogo.fcgi | $(SED) '1,/^$$/d' > \ + $(CQRLOGO_FCGI) | $(SED) '1,/^$$/d' > \ check.png $(FILE) check.png | $(GREP) 'PNG image data' $(ZBARIMG) --raw -q check.png | $(GREP) -e '^http://$(SERVER)/$$' SERVER_NAME=$(SERVER) HTTP_REFERER=http://$(SERVER)/ \ QUERY_STRING='scale=4' \ - ./cqrlogo.fcgi | $(SED) '1,/^$$/d' > \ + $(CQRLOGO_FCGI) | $(SED) '1,/^$$/d' > \ check.png $(FILE) check.png | $(GREP) 'PNG image data' $(ZBARIMG) --raw -q check.png | $(GREP) -e '^http://$(SERVER)/$$' SERVER_NAME=$(SERVER) HTTP_REFERER=http://$(SERVER)/ \ QUERY_STRING='scale=20' \ - ./cqrlogo.fcgi | $(SED) '1,/^$$/d' > \ + $(CQRLOGO_FCGI) | $(SED) '1,/^$$/d' > \ check.png $(FILE) check.png | $(GREP) 'PNG image data' $(ZBARIMG) --raw -q check.png | $(GREP) -e '^http://$(SERVER)/$$' SERVER_NAME=$(SERVER) HTTP_REFERER=http://$(SERVER)/ \ QUERY_STRING='scale=2&border=0' \ - ./cqrlogo.fcgi | $(SED) '1,/^$$/d' > \ + $(CQRLOGO_FCGI) | $(SED) '1,/^$$/d' > \ check.png $(FILE) check.png | $(GREP) 'PNG image data' $(ZBARIMG) --raw -q check.png | $(GREP) -e '^http://$(SERVER)/$$' SERVER_NAME=$(SERVER) HTTP_REFERER=http://$(SERVER)/ \ QUERY_STRING='scale=2&border=2' \ - ./cqrlogo.fcgi | $(SED) '1,/^$$/d' > \ + $(CQRLOGO_FCGI) | $(SED) '1,/^$$/d' > \ check.png $(FILE) check.png | $(GREP) 'PNG image data' $(ZBARIMG) --raw -q check.png | $(GREP) -e '^http://$(SERVER)/$$' SERVER_NAME=$(SERVER) HTTP_REFERER=http://$(SERVER)/ \ QUERY_STRING='scale=2&border=10' \ - ./cqrlogo.fcgi | $(SED) '1,/^$$/d' > \ + $(CQRLOGO_FCGI) | $(SED) '1,/^$$/d' > \ check.png $(FILE) check.png | $(GREP) 'PNG image data' $(ZBARIMG) --raw -q check.png | $(GREP) -e '^http://$(SERVER)/$$' SERVER_NAME=$(SERVER) HTTP_REFERER=http://$(SERVER)/ \ QUERY_STRING='scale=2&border=10&level=0' \ - ./cqrlogo.fcgi | $(SED) '1,/^$$/d' > \ + $(CQRLOGO_FCGI) | $(SED) '1,/^$$/d' > \ check.png $(FILE) check.png | $(GREP) 'PNG image data' $(ZBARIMG) --raw -q check.png | $(GREP) -e '^http://$(SERVER)/$$' SERVER_NAME=$(SERVER) HTTP_REFERER=http://$(SERVER)/ \ QUERY_STRING='scale=2&border=10&level=2' \ - ./cqrlogo.fcgi | $(SED) '1,/^$$/d' > \ + $(CQRLOGO_FCGI) | $(SED) '1,/^$$/d' > \ check.png $(FILE) check.png | $(GREP) 'PNG image data' $(ZBARIMG) --raw -q check.png | $(GREP) -e '^http://$(SERVER)/$$' SERVER_NAME=$(SERVER) HTTP_REFERER=http://$(SERVER)/ \ QUERY_STRING='scale=2&border=10&level=4' \ - ./cqrlogo.fcgi | $(SED) '1,/^$$/d' > \ + $(CQRLOGO_FCGI) | $(SED) '1,/^$$/d' > \ check.png $(FILE) check.png | $(GREP) 'PNG image data' $(ZBARIMG) --raw -q check.png | $(GREP) -e '^http://$(SERVER)/$$' SERVER_NAME=eworm.net HTTP_REFERER=http://$(SERVER)/ \ - ./cqrlogo.fcgi | $(SED) '1,/^$$/d' > \ + $(CQRLOGO_FCGI) | $(SED) '1,/^$$/d' > \ check.png $(FILE) check.png | $(GREP) 'PNG image data' $(ZBARIMG) --raw -q check.png | \ $(GREP) -e '^This QR Code has been stolen from http://eworm.net/!$$' SERVER_NAME=eworm.net HTTP_REFERER=https://$(SERVER)/ HTTPS=on \ - ./cqrlogo.fcgi | $(SED) '1,/^$$/d' > \ + $(CQRLOGO_FCGI) | $(SED) '1,/^$$/d' > \ check.png $(FILE) check.png | $(GREP) 'PNG image data' $(ZBARIMG) --raw -q check.png | \ $(GREP) -e '^This QR Code has been stolen from https://eworm.net/!$$' clean: - $(RM) -f *.o *~ *.png README.html cqrlogo.cgi cqrlogo.fcgi version.h + $(RM) -f *.o *~ *.png README.html lib/libcqrlogo.so lib/libcqrlogo.so.* cqrlogo.cgi cqrlogo.fcgi version.h distclean: - $(RM) -f *.o *~ *.png README.html cqrlogo.cgi cqrlogo.fcgi version.h config.h + $(RM) -f *.o *~ *.png README.html lib/libcqrlogo.so lib/libcqrlogo.so.* cqrlogo.cgi cqrlogo.fcgi version.h config.h release: git archive --format=tar.xz --prefix=cqrlogo-$(VERSION)/ $(VERSION) > cqrlogo-$(VERSION).tar.xz |