Skip to content

Commit

Permalink
Add Makefile logic to ease compilation against luajit
Browse files Browse the repository at this point in the history
Taken from lextlib and lua-term
  • Loading branch information
devurandom committed Jul 7, 2013
1 parent f084e51 commit 9910a46
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)

0 comments on commit 9910a46

Please sign in to comment.