From: Leandro Lucarella Date: Wed, 12 Nov 2008 17:21:51 +0000 (-0200) Subject: Add pkg-config support X-Git-Url: https://git.llucax.com/software/posixx.git/commitdiff_plain/5387a786e28fa507dff72c36aa9f973dfc211c43?ds=sidebyside Add pkg-config support Generate and install a pkg-config .pc definition file to ease compilation and linking of programs depending on posixx. --- diff --git a/src/.gitignore b/src/.gitignore index d1943c2..d930f66 100644 --- a/src/.gitignore +++ b/src/.gitignore @@ -1 +1,2 @@ +posixx.pc .*-stamp diff --git a/src/Makefile b/src/Makefile index 1a8fb03..cfea6e6 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,15 +1,37 @@ +# Build flags (include general stuff in the .pc file instead) +LOCAL_CFLAGS = +LOCAL_LDFLAGS = + # XXX: The cut pipe is to strip the leading "./" from find results. It's # a little ugly but I couldn't find a better way to get a list of all # headers in the directory (recursively). HEADERS = $(shell find -name '*.hpp' | cut -b3-) HDRPATH = posixx - +PCFILE = posixx.pc +PCTEMPLATE = $(PCFILE).template # prefix for installing the binaries prefix = /usr/local +# Flags fetched from pkg-config .pc file +ifneq ($(PCTEMPLATE), ) +PKG_LIB = $(shell grep Libs.private: $(PCTEMPLATE) | cut -d' ' -f2-) +PKG_REQ = $(shell grep Requires: $(PCTEMPLATE) | cut -d' ' -f2-) +ifneq ($(PKG_REQ), ) +PKG_REQ_CFLAGS = $(shell pkg-config --cflags $(PKG_REQ)) +PKG_REQ_LDFLAGS = $(shell pkg-config --libs $(PKG_REQ)) +endif +endif + +# XXX: LI_* variables are for internal use only +# (for the super-repository local-install target) +ALL_CFLAGS = $(LOCAL_CFLAGS) $(PKG_REQ_CFLAGS) $(LI_CFLAGS) $(CFLAGS) +ALL_LDFLAGS = $(LOCAL_LDFLAGS) $(PKG_LIB) $(PKG_REQ_LDFLAGS) $(LI_LDFLAGS) \ + $(LDFLAGS) + + # install command INSTALL = install -p -m 0644 -D @@ -36,15 +58,23 @@ default: all all: -install: install-headers +$(PCFILE): $(PCTEMPLATE) + @sed 's|PREFIX|$(prefix)|' $< > $@ + +install: install-headers install-pc install-headers: .install-headers-stamp .install-headers-stamp: $(HEADERS) $(call install_files,$^,$(prefix)/include/$(HDRPATH)) +install-pc: .install-pc-stamp + +.install-pc-stamp: $(PCFILE) + $(call install_files,$^,$(prefix)/lib/pkgconfig) + clean: - $(NICE_CLEAN) .*-stamp + $(NICE_CLEAN) $(PCFILE) .*-stamp -.PHONY: default all install install-headers clean +.PHONY: default all install install-headers install-pc clean diff --git a/src/posixx.pc.template b/src/posixx.pc.template new file mode 100644 index 0000000..a288288 --- /dev/null +++ b/src/posixx.pc.template @@ -0,0 +1,12 @@ + +prefix=PREFIX +exec_prefix=${prefix} +libdir=${exec_prefix}/lib +includedir=${prefix}/include + +Name: posixx +Description: Thin C++ wrapper for POSIX API +URL: https://spec-dev.integratech.net/redmine/projects/show/posixx +Version: 0.1 +Cflags: -I${includedir} +