Skip to content

Commit

Permalink
Makefile: Add support for multiple Lua versions
Browse files Browse the repository at this point in the history
  • Loading branch information
grondo committed Sep 9, 2015
1 parent 3826c84 commit 230ecf4
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
LUA_VER ?= $(shell lua -e 'print (_VERSION:match("Lua (.+)"))')
LUA ?= lua
LUA_VER ?= $(shell $(LUA) -e 'print (_VERSION:match("Lua (.+)") )')
LIBDIR ?= /usr/local/lib
LUA_OBJDIR ?= $(LIBDIR)/lua/$(LUA_VER)
PREFIX ?= /usr/local

LUA_PKG_NAME := $(shell \
pkg-config --exists lua$(LUA_VER) && echo lua$(LUA_VER) \
|| pkg-config --exists lua && echo lua)
(pkg-config --exists lua$(LUA_VER) && echo lua$(LUA_VER)) \
|| (pkg-config --exists lua && echo lua) )

ifeq ($(LUA_PKG_NAME),)
$(error "No Lua pkg-config file found!")
endif

override CFLAGS+= -Wall -ggdb $(shell pkg-config --cflags $(LUA_PKG_NAME))
override LDFLAGS+= $(shell pkg-config --libs $(LUA_PKG_NAME))

LUA_CFLAGS := $(shell pkg-config --cflags $(LUA_PKG_NAME))
LUA_LIBS := $(shell pkg-config --libs $(LUA_PKG_NAME))

override CFLAGS+= -Wall -ggdb $(LUA_CFLAGS)
override LDFLAGS+= $(LUA_LIBS)

.SUFFIXES: .c .o .so

Expand All @@ -23,7 +28,7 @@ affinity.so: lua-affinity.o cpuset-str.o
$(CC) -shared -o $*.so $^ $(LDFLAGS)

check: affinity.so
@tests/test.lua
$(LUA) tests/test.lua

check-coverage:
make clean
Expand Down

0 comments on commit 230ecf4

Please sign in to comment.