From 89015b4ac16feae4f71f443b70c91a263e9946d3 Mon Sep 17 00:00:00 2001 From: Natanael Copa Date: Wed, 12 Sep 2012 14:41:40 +0200 Subject: misc fixes for Makefile - Get lua version and install dir from pkg-config - Use cflags and libs from pkg-config --- Makefile | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index f701ff2..f53b7f6 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ -LUA_LIBDIR = /usr/lib/lua/5.1 +PKGCONFIG ?= pkg-config VERSION = 0.1.1 GIT_REV := $(shell test -d .git && git describe || echo exported) @@ -10,7 +10,16 @@ else FULL_VERSION := $(VERSION) endif -AUGEAS_LIBS= $(shell pkg-config --libs augeas) +LUAPC := $(shell for pc in lua lua5.1; do \ + $(PKGCONFIG) --exists $$pc && echo $$pc && break; \ + done) + +LUA_VERSION := $(shell $(PKGCONFIG) --variable=V $(LUAPC)) +INSTALL_CMOD := $(shell $(PKGCONFIG) --variable=INSTALL_CMOD $(LUAPC)) + + +AUGEAS_LIBS := $(shell $(PKGCONFIG) --libs augeas) +AUGEAS_CFLAGS := $(shell $(PKGCONFIG) --cflags augeas) OBJS = laugeas.o LIBS = $(AUGEAS_LIBS) @@ -22,11 +31,14 @@ LDFLAGS += -L/lib all: augeas.so +laugeas.o: CFLAGS+=$(AUGEAS_CFLAGS) augeas.so: $(OBJS) - $(CC) $(LDFLAGS) -o $@ -fPIC -shared $^ $(LIBS) + $(CC) $(CFLAGS) $(LDFLAGS) -o $@ -fPIC -shared $^ $(LIBS) clean: rm -f augeas.so $(OBJS) +install: augeas.so + install -D augeas.so $(DESTDIR)$(INSTALL_CMOD)/augeas.so -- cgit v1.2.3