BUILD_ROOT=$(shell cd ../../..; pwd)
LUADIR = $(BUILD_ROOT)/submodules/lua
COMMONDIR = ../include
REPORTED_PLATFORM=$(shell (uname -o || uname -s) 2> /dev/null)
ifeq ($(REPORTED_PLATFORM), Darwin)
PLATFORM=macosx
else ifeq ($(REPORTED_PLATFORM), GNU/Linux)
PLATFORM=linux
else
PLATFORM=none
endif
ndebug_flag=-DNDEBUG
ifdef DEBUG
debug_flag=-DDEBUG
ndebug_flag=
endif
ifdef LLDB
debugger_flag=-O0 -g
ndebug_flag=
endif
ifdef FILEDEBUG
filedebug='-DFILEDEBUG=1'
endif
ifdef VMEBUG
vmdebug='-DVMDEBUG=1'
endif
ifdef BUFDEBUG
bufdebug='-DBUFDEBUG=1'
endif
COPT = -O2 $(debug_flag) $(ndebug_flag) $(debugger_flag) $(filedebug) $(vmdebug) $(bufdebug)
FILES = buf.o vm.o ktable.o capture.o file.o json.o rplx.o
ifeq ($(PLATFORM), macosx)
CC= cc
Cstd= c99
else
CC= gcc
Cstd= c99
endif
ifdef ROSIE_DEBUG
COPT += -DROSIE_DEBUG
endif
CWARNS = -Wall -Wextra -pedantic \
-Waggregate-return \
-Wcast-align \
-Wcast-qual \
-Wdisabled-optimization \
-Wpointer-arith \
-Wshadow \
-Wsign-compare \
-Wundef \
-Wwrite-strings \
-Wbad-function-cast \
-Wmissing-prototypes \
-Wnested-externs \
-Wstrict-prototypes \
-Wunreachable-code \
-Wno-missing-declarations \
CFLAGS = -fvisibility=hidden $(CWARNS) $(COPT) -std=$(Cstd) -I$(COMMONDIR) -I$(LUADIR)/include -fPIC $(ASAN_OPT)
default: $(FILES)
.PHONY: clean
clean:
rm -f $(FILES) rpeg.a *.o
buf.o: buf.c ../include/buf.h
capture.o: capture.c ../include/config.h ../include/buf.h \
../include/ktable.h ../include/capture.h ../include/rplx.h \
../include/vm.h
file.o: file.c ../include/ktable.h ../include/config.h ../include/file.h \
../include/rplx.h
json.o: json.c ../include/config.h ../include/buf.h ../include/ktable.h \
../include/capture.h ../include/rplx.h ../include/vm.h \
../include/json.h
ktable.o: ktable.c ../include/config.h ../include/ktable.h
rplx.o: rplx.c ../include/config.h ../include/rplx.h ../include/ktable.h
stack.o: stack.c
vm.o: vm.c ../include/config.h ../include/rplx.h ../include/ktable.h \
../include/str.h ../include/buf.h ../include/vm.h stack.c