Commit f40568ba1e1ff68176a54300fad592b4b83a6fea

Steffen Jaeckel 2017-05-09T14:25:11

add pkg-config file for shared library

diff --git a/.gitignore b/.gitignore
index 4fa170a..e84e296 100644
--- a/.gitignore
+++ b/.gitignore
@@ -45,6 +45,7 @@ mtest.exe
 *.pdf
 *.out
 tommath.tex
+libtommath.pc
 
 # ignore files generated by testme.sh
 gcc_errors_*.txt
diff --git a/libtommath.pc.in b/libtommath.pc.in
new file mode 100644
index 0000000..099b1cd
--- /dev/null
+++ b/libtommath.pc.in
@@ -0,0 +1,10 @@
+prefix=@to-be-replaced@
+exec_prefix=${prefix}
+libdir=${exec_prefix}/lib
+includedir=${prefix}/include
+
+Name: LibTomMath
+Description: public domain library for manipulating large integer numbers
+Version: @to-be-replaced@
+Libs: -L${libdir} -ltommath
+Cflags: -I${includedir}
diff --git a/makefile.shared b/makefile.shared
index 02d6fcc..13c8eaf 100644
--- a/makefile.shared
+++ b/makefile.shared
@@ -55,6 +55,9 @@ install: $(LIBNAME)
 	install -d $(INCPATH)
 	$(LT) --mode=install install -c $(LIBNAME) $(LIBPATH)/$(LIBNAME)
 	install -m 644 $(HEADERS_PUB) $(INCPATH)
+	sed -e 's,^prefix=.*,prefix=$(DESTDIR),' -e 's,^Version:.*,Version: $(VERSION),' libtommath.pc.in > libtommath.pc
+	install -d $(LIBPATH)/pkgconfig
+	install -m 644 libtommath.pc $(LIBPATH)/pkgconfig/
 
 test: $(LIBNAME) demo/demo.o
 	$(CC) $(CFLAGS) -c demo/demo.c -o demo/demo.o