Files
ljkiwi/Makefile
John K. Luebs e43272487f Guard against most egregious mistakes in calling the library
LuaJIT FFI is not inherently memory safe and there is no way
to completely guard against the caller doing something that
will trample over memory, but we can get pretty close. Biggest
issue is that an empty table will stand-in for a ref struct with
a null ref. So check for that in all the calls. In the calls that
raise errors we now have a specific error for it. In the other
functions the "nil" object is handled quietly but without a nullptr
dereference and hopefully no UB.
2024-02-13 16:58:59 -06:00

40 lines
819 B
Makefile

SRCDIR := .
CC := $(CROSS)gcc
CFLAGS := -fPIC -O2
CFLAGS += -Wall -I$(SRCDIR)/kiwi
LIBFLAG := -shared
LIB_EXT := so
ifeq ($(findstring gcc, $(CC)), gcc)
CXX := $(subst gcc, g++, $(CC))
CXXFLAGS += -std=c++14
ifneq ($(SANITIZE),)
CFLAGS += -fsanitize=undefined -fsanitize=address
endif
else
ifeq ($(CC), clang)
CXX := clang++
CXXFLAGS += -std=c++14
ifneq ($(SANITIZE),)
CFLAGS += -fsanitize=undefined -fsanitize=address
endif
else
CXX := $(CC)
endif
endif
all: ckiwi.$(LIB_EXT)
install:
cp -f ckiwi.$(LIB_EXT) $(INST_LIBDIR)/ckiwi.$(LIB_EXT)
cp -f kiwi.lua $(INST_LUADIR)/kiwi.lua
clean:
rm -f ckiwi.$(LIB_EXT)
ckiwi.$(LIB_EXT): $(SRCDIR)/ckiwi/ckiwi.cpp $(SRCDIR)/ckiwi/ckiwi.h
$(CXX) $(CXXFLAGS) $(CFLAGS) -fPIC -Wall -I$(SRCDIR)/kiwi $(LIBFLAG) -o $@ $<
.PHONY: all install clean