git » libjio » commit 97c8dc5

Add a pkg-config support

author Alberto Bertogli
2009-02-22 21:36:15 UTC
committer Alberto Bertogli
2009-02-22 21:36:15 UTC
parent 3fd76c54a0a2cd4a6b611cb428b5143a5f86f6e4

Add a pkg-config support

This patch adds pkg-config support by generating a libjio.pc file and
installing it accordingly.

Signed-off-by: Alberto Bertogli <albertito@blitiri.com.ar>

.gitignore +1 -0
Makefile +15 -4
libjio.skel.pc +12 -0

diff --git a/.gitignore b/.gitignore
index 32bd6d9..7857c16 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,3 +2,4 @@
 *.a
 *.so
 jiofsck
+libjio.pc
diff --git a/Makefile b/Makefile
index 6e4b9f9..2813aca 100644
--- a/Makefile
+++ b/Makefile
@@ -3,12 +3,14 @@ VERSION="0.23"
 
 CFLAGS = -std=c99 -pedantic -Wall -O3
 
-ALL_CFLAGS += $(CFLAGS) -fPIC \
+MANDATORY_CFLAGS := \
 	-D_LARGEFILE_SOURCE=1 -D_LARGEFILE64_SOURCE=1 \
 	-D_LFS_LARGEFILE=1 -D_LFS64_LARGEFILE=1 \
-	-D_FILE_OFFSET_BITS=64 `getconf LFS_CFLAGS 2>/dev/null` \
+	-D_FILE_OFFSET_BITS=64 $(shell getconf LFS_CFLAGS 2>/dev/null) \
 	-D_XOPEN_SOURCE=500
 
+ALL_CFLAGS += $(CFLAGS) $(MANDATORY_CFLAGS) -fPIC
+
 ifdef DEBUG
 ALL_CFLAGS += -g -pg -fprofile-arcs -ftest-coverage
 endif
@@ -33,7 +35,7 @@ OBJS = checksum.o common.o trans.o check.o unix.o ansi.o
 # rules
 default: all
 
-all: libjio.so libjio.a jiofsck
+all: libjio.so libjio.a libjio.pc jiofsck
 
 libjio.so: $(OBJS)
 	$(NICE_CC) -shared $(ALL_CFLAGS) $(OBJS) -o libjio.so
@@ -41,6 +43,13 @@ libjio.so: $(OBJS)
 libjio.a: $(OBJS)
 	$(NICE_AR) cr libjio.a $(OBJS)
 
+libjio.pc: libjio.skel.pc
+	@echo "generating libjio.pc"
+	@cat libjio.skel.pc | \
+		sed 's@++PREFIX++@$(PREFIX)@g' | \
+		sed 's@++CFLAGS++@$(MANDATORY_CFLAGS)@g' \
+		> libjio.pc
+
 jiofsck: jiofsck.o libjio.a
 	$(NICE_CC) jiofsck.o libjio.a -lpthread -o jiofsck
 
@@ -50,6 +59,8 @@ install: all
 	install -m 0644 libjio.a $(PREFIX)/lib
 	install -d $(PREFIX)/include
 	install -m 0644 libjio.h $(PREFIX)/include
+	install -d $(PREFIX)/lib/pkgconfig
+	install -m 644 libjio.pc $(PREFIX)/lib/pkgconfig
 	install -d $(PREFIX)/bin
 	install -m 0775 jiofsck $(PREFIX)/bin
 	install -d $(PREFIX)/man/man3
@@ -83,7 +94,7 @@ preload_install: preload
 
 
 clean:
-	rm -f $(OBJS) libjio.a libjio.so jiofsck.o jiofsck
+	rm -f $(OBJS) libjio.a libjio.so libjio.pc jiofsck.o jiofsck
 	rm -f *.bb *.bbg *.da *.gcov gmon.out
 	rm -rf bindings/python/build/
 	rm -rf bindings/preload/build/
diff --git a/libjio.skel.pc b/libjio.skel.pc
new file mode 100644
index 0000000..3a7b0f1
--- /dev/null
+++ b/libjio.skel.pc
@@ -0,0 +1,12 @@
+
+prefix=++PREFIX++
+libdir=${prefix}/lib
+includedir=${prefix}/include
+
+Name: libjio
+Description: A library for Journaled I/O
+URL: http://blitiri.com.ar/p/libjio/
+Version: 0.23
+Libs: -L${libdir} -ljio
+Cflags: -I${includedir} ++CFLAGS++
+