From 9910a464005afe5d4aa05e09125420e5cda0091b Mon Sep 17 00:00:00 2001 From: Dennis Schridde Date: Sun, 7 Jul 2013 16:03:04 +0200 Subject: [PATCH] Add Makefile logic to ease compilation against luajit Taken from lextlib and lua-term --- Makefile | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 501e309..2fdb20b 100644 --- a/Makefile +++ b/Makefile @@ -2,10 +2,24 @@ ifeq ($(LUA_VERSION),) LUA_VERSION=5.2 endif -CFLAGS=-Wall -Werror -std=c99 -g -fPIC -I/usr/include/lua$(LUA_VERSION) -D_XOPEN_SOURCE=700 -LDFLAGS=-Wl,--no-undefined -LIBS=-llua$(LUA_VERSION) -lpam +ifeq ($(LUA_CPPFLAGS),) +LUA_CPPFLAGS=-I/usr/include/lua$(LUA_VERSION) +endif + +ifeq ($(LUA_LIBS),) +LUA_LIBS=-llua$(LUA_VERSION) +endif +ifneq ($(DEBUG),) +EXTRA_CFLAGS+= -g -O0 +endif + +CFLAGS=-Wall -Werror -pedantic -std=c99 -fPIC -D_XOPEN_SOURCE=700 $(EXTRA_CFLAGS) +CPPFLAGS=$(LUA_CPPFLAGS) +LDFLAGS=-Wl,--no-undefined $(LUA_LDFLAGS) +LIBS=$(LUA_LIBS) -lpam + +.PHONY: all all: pam.so pam_util.so pam.o: pam.c lextlib/lextlib.h @@ -14,11 +28,10 @@ pam.so: pam.o lextlib/lextlib.o pam_util.o: pam_util.c lextlib/lextlib.h pam_util.so: pam_util.o lextlib/lextlib.o lua-term/term.o +.PHONY: clean clean: $(RM) *.so *.o -%.o: %.c - $(CC) $(CFLAGS) -o $@ -c $< - -%.so: %.o +.SUFFIXES: .o .so +.o.so: $(CC) $(CFLAGS) $(LDFLAGS) -shared -o $@ $^ $(LIBS)