From fee8d69e82e09c67215c8fb0129c7e924170d00f Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Sat, 24 Sep 2016 16:44:14 -0700 Subject: Angled-include zxcvbn.h To build as a shared/static library. --- test.c | 2 +- zxcvbn.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test.c b/test.c index 9d74ce5..bb0f8bd 100644 --- a/test.c +++ b/test.c @@ -34,7 +34,7 @@ #include #include #include -#include "zxcvbn.h" +#include /* For pre-compiled headers under windows */ #ifdef _WIN32 diff --git a/zxcvbn.c b/zxcvbn.c index c29c20c..aa0a881 100644 --- a/zxcvbn.c +++ b/zxcvbn.c @@ -30,7 +30,7 @@ * **********************************************************************************/ -#include "zxcvbn.h" +#include #include #include #include -- cgit v1.2.3 From 802dd8326752ca0892be4ecafc59a139d33cbef0 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Sat, 24 Sep 2016 18:17:44 -0700 Subject: Targets to build shlib --- makefile | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/makefile b/makefile index 2007411..4b265be 100644 --- a/makefile +++ b/makefile @@ -1,9 +1,25 @@ CFLAGS = -O2 -Wall -Wextra -Wdeclaration-after-statement CPPFLAGS = -O2 -Wall -Wextra +# need zxcvbn.h prior to package installation +CFLAGS += -I. +CPPFLAGS += -I. + +# library metadata +TARGET_LIB = libzxcvbn.so.0.0.0 +SONAME = libzxcvbn.so.0 + WORDS = words-10k-pass.txt words-english.txt words-female.txt words-male.txt words-surname.txt -all: test-file test-inline test-c++inline test-c++file +all: test-file test-inline test-c++inline test-c++file test-shlib + +test-shlib: test.c $(TARGET_LIB) + if [ ! -e libzxcvbn.so ]; then ln -s $(TARGET_LIB) libzxcvbn.so; fi + gcc $(CFLAGS) -o $@ $< -L. -lzxcvbn -lm + +$(TARGET_LIB): zxcvbn-inline-pic.o + gcc $(CFLAGS) $(LDFLAGS) -fPIC -shared -Wl,-soname,$(SONAME) -o $@ $^ -lm + if [ ! -e $(SONAME) ]; then ln -s $(TARGET_LIB) $(SONAME); fi test-file: test.c zxcvbn-file.o gcc $(CFLAGS) -DUSE_DICT_FILE -o test-file test.c zxcvbn-file.o -lm @@ -14,6 +30,9 @@ zxcvbn-file.o: zxcvbn.c dict-crc.h zxcvbn.h test-inline: test.c zxcvbn-inline.o gcc $(CFLAGS) -o test-inline test.c zxcvbn-inline.o -lm +zxcvbn-inline-pic.o: zxcvbn.c dict-src.h zxcvbn.h + gcc $(CFLAGS) -fPIC -c -o $@ $< + zxcvbn-inline.o: zxcvbn.c dict-src.h zxcvbn.h gcc $(CFLAGS) -c -o zxcvbn-inline.o zxcvbn.c @@ -42,11 +61,13 @@ zxcvbn-c++file.o: zxcvbn.c dict-crc.h zxcvbn.h if [ ! -e zxcvbn.cpp ]; then ln -s zxcvbn.c zxcvbn.cpp; fi g++ $(CPPFLAGS) -DUSE_DICT_FILE -c -o zxcvbn-c++file.o zxcvbn.cpp -test: test-file test-inline test-c++inline test-c++file testcases.txt +test: test-file test-inline test-c++inline test-c++file test-shlib testcases.txt @echo Testing C build, dictionary from file ./test-file -t testcases.txt @echo Testing C build, dictionary in executable ./test-inline -t testcases.txt + @echo Testing C shlib, dictionary in shlib + LD_LIBRARY_PATH=. ./test-shlib -t testcases.txt @echo Testing C++ build, dictionary from file ./test-c++file -t testcases.txt @echo Testing C++ build, dictionary in executable @@ -55,6 +76,6 @@ test: test-file test-inline test-c++inline test-c++file testcases.txt clean: rm -f test-file zxcvbn-file.o test-c++file zxcvbn-c++file.o - rm -f test-inline zxcvbn-inline.o test-c++inline zxcvbn-c++inline.o + rm -f test-inline zxcvbn-inline.o zxcvbn-inline-pic.o test-c++inline zxcvbn-c++inline.o rm -f dictgen - \ No newline at end of file + rm -f ${TARGET_LIB} ${SONAME} libzxcvbn.so test-shlib -- cgit v1.2.3 From cd587a1613cb0904ec3c7118d4d6b7d04d070c05 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Sat, 24 Sep 2016 18:18:29 -0700 Subject: Targets to build static lib --- makefile | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/makefile b/makefile index 4b265be..1d7cc59 100644 --- a/makefile +++ b/makefile @@ -11,7 +11,7 @@ SONAME = libzxcvbn.so.0 WORDS = words-10k-pass.txt words-english.txt words-female.txt words-male.txt words-surname.txt -all: test-file test-inline test-c++inline test-c++file test-shlib +all: test-file test-inline test-c++inline test-c++file test-shlib test-statlib test-shlib: test.c $(TARGET_LIB) if [ ! -e libzxcvbn.so ]; then ln -s $(TARGET_LIB) libzxcvbn.so; fi @@ -21,6 +21,12 @@ $(TARGET_LIB): zxcvbn-inline-pic.o gcc $(CFLAGS) $(LDFLAGS) -fPIC -shared -Wl,-soname,$(SONAME) -o $@ $^ -lm if [ ! -e $(SONAME) ]; then ln -s $(TARGET_LIB) $(SONAME); fi +test-statlib: test.c libzxcvbn.a + gcc $(CFLAGS) $(LDFLAGS) -o $@ $^ -lm + +libzxcvbn.a: zxcvbn-inline.o + ar cvq $@ $^ + test-file: test.c zxcvbn-file.o gcc $(CFLAGS) -DUSE_DICT_FILE -o test-file test.c zxcvbn-file.o -lm @@ -61,13 +67,15 @@ zxcvbn-c++file.o: zxcvbn.c dict-crc.h zxcvbn.h if [ ! -e zxcvbn.cpp ]; then ln -s zxcvbn.c zxcvbn.cpp; fi g++ $(CPPFLAGS) -DUSE_DICT_FILE -c -o zxcvbn-c++file.o zxcvbn.cpp -test: test-file test-inline test-c++inline test-c++file test-shlib testcases.txt +test: test-file test-inline test-c++inline test-c++file test-shlib test-statlib testcases.txt @echo Testing C build, dictionary from file ./test-file -t testcases.txt @echo Testing C build, dictionary in executable ./test-inline -t testcases.txt @echo Testing C shlib, dictionary in shlib LD_LIBRARY_PATH=. ./test-shlib -t testcases.txt + @echo Testing C static lib, dictionary in lib + ./test-statlib -t testcases.txt @echo Testing C++ build, dictionary from file ./test-c++file -t testcases.txt @echo Testing C++ build, dictionary in executable @@ -78,4 +86,4 @@ clean: rm -f test-file zxcvbn-file.o test-c++file zxcvbn-c++file.o rm -f test-inline zxcvbn-inline.o zxcvbn-inline-pic.o test-c++inline zxcvbn-c++inline.o rm -f dictgen - rm -f ${TARGET_LIB} ${SONAME} libzxcvbn.so test-shlib + rm -f ${TARGET_LIB} ${SONAME} libzxcvbn.so test-shlib libzxcvbn.a test-statlib -- cgit v1.2.3