aboutsummaryrefslogtreecommitdiffhomepage
path: root/debian/patches/targets-to-build-static-lib.patch
blob: 35da165d3b1b6f276acf4def565c3f9e1254d0b2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
From: Sean Whitton <spwhitton@spwhitton.name>
Date: Sat, 24 Sep 2016 15:20:43 -0700
Subject: targets to build static lib

Per Debian Policy, it's usual to provide the static lib in the -dev
package.

Forwarded: https://github.com/tsyrogit/zxcvbn-c/pull/8
---
 makefile | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/makefile b/makefile
index d74b139..b44b6e6 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.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
 
@@ -58,13 +64,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
@@ -76,4 +84,4 @@ clean:
 	rm -f test-inline zxcvbn-inline.o test-c++inline zxcvbn-c++inline.o
 	rm -f dict-*.h zxcvbn.dict zxcvbn.cpp test.cpp
 	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