1# 2# This file is in the Public Domain. 3# 4 5PROJ= lpm 6 7CFLAGS+= -std=c99 -O2 -g -Wall -Wextra -Werror 8CFLAGS+= -D_POSIX_C_SOURCE=200809L 9CFLAGS+= -D_GNU_SOURCE -D_DEFAULT_SOURCE 10 11# 12# Extended warning flags. 13# 14CFLAGS+= -Wno-unknown-warning-option # gcc vs clang 15 16CFLAGS+= -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith 17CFLAGS+= -Wmissing-declarations -Wredundant-decls -Wnested-externs 18CFLAGS+= -Wshadow -Wcast-qual -Wcast-align -Wwrite-strings 19CFLAGS+= -Wold-style-definition 20CFLAGS+= -Wsuggest-attribute=noreturn -Wjump-misses-init 21 22# New GCC 6/7 flags: 23#CFLAGS+= -Wduplicated-cond -Wmisleading-indentation -Wnull-dereference 24#CFLAGS+= -Wduplicated-branches -Wrestrict 25 26ifeq ($(DEBUG),1) 27CFLAGS+= -Og -DDEBUG -fno-omit-frame-pointer 28CFLAGS+= -fsanitize=address 29LDFLAGS+= -fsanitize=address 30else 31CFLAGS+= -DNDEBUG 32endif 33 34# Lua module 35LUA_CFLAGS?= $(shell pkg-config --cflags lua) 36LUA_LDFLAGS?= $(shell pkg-config --cflags --libs lua) 37CFLAGS+= $(LUA_CFLAGS) -I.. -fPIC 38LDFLAGS+= $(LUA_LDFLAGS) 39LDFLAGS+= -L../.libs -llpm 40 41OBJS= lpm_lua.o 42LIB= lpm 43 44install: LUA_ILIBDIR= $(DESTDIR)/$(LUA_LIBDIR)/ 45 46obj: $(OBJS) 47 48lib: $(LIB).so 49 50%.o: %.c 51 $(CC) $(CFLAGS) -c $< 52 53$(LIB).so: $(OBJS) 54 $(CC) $(LDFLAGS) -fPIC -shared -o $@ $(notdir $^) 55 56install: 57 mkdir -p $(LUA_ILIBDIR) && install -c lpm.so $(LUA_ILIBDIR) 58 59clean: 60 rm -rf .libs *.so *.o *.lo *.la t_$(PROJ) 61 62.PHONY: all obj lib install clean 63