2024-04-11 21:18:59 +01:00
|
|
|
CFLAGS = -Wall -Wextra -std=c99 -O2 -Wno-zero-length-array -Wno-empty-translation-unit -DUSE_BERRY_INT64
|
2022-07-02 15:27:37 +01:00
|
|
|
DEBUG_FLAGS = -O0 -g -DBE_DEBUG
|
|
|
|
TEST_FLAGS = $(DEBUG_FLAGS) --coverage -fno-omit-frame-pointer -fsanitize=address -fsanitize=undefined
|
|
|
|
LIBS = -lm
|
|
|
|
TARGET = berry
|
2023-05-11 15:21:33 +01:00
|
|
|
CC = clang # install clang!! gcc seems to produce a defect berry binary
|
2022-07-02 15:27:37 +01:00
|
|
|
MKDIR = mkdir
|
|
|
|
LFLAGS =
|
|
|
|
|
2024-04-11 21:18:59 +01:00
|
|
|
INCPATH = src default ../re1.5 ../berry_mapping/src ../berry_int64/src generate
|
|
|
|
SRCPATH = src default ../re1.5 ../berry_mapping/src ../berry_int64/src
|
2022-07-02 15:27:37 +01:00
|
|
|
GENERATE = generate
|
|
|
|
CONFIG = default/berry_conf.h
|
|
|
|
COC = tools/coc/coc
|
|
|
|
CONST_TAB = $(GENERATE)/be_const_strtab.h
|
2021-04-19 07:40:11 +01:00
|
|
|
|
|
|
|
ifeq ($(OS), Windows_NT) # Windows
|
|
|
|
CFLAGS += -Wno-format # for "%I64d" warning
|
|
|
|
LFLAGS += -Wl,--out-implib,berry.lib # export symbols lib for dll linked
|
|
|
|
TARGET := $(TARGET).exe
|
2022-07-02 15:27:37 +01:00
|
|
|
PYTHON ?= python # only for windows and need python3
|
|
|
|
COC := $(PYTHON) $(COC)
|
2021-04-19 07:40:11 +01:00
|
|
|
else
|
|
|
|
CFLAGS += -DUSE_READLINE_LIB
|
|
|
|
LIBS += -lreadline -ldl
|
|
|
|
OS := $(shell uname)
|
|
|
|
ifeq ($(OS), Linux)
|
|
|
|
LFLAGS += -Wl,--export-dynamic
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifneq ($(V), 1)
|
|
|
|
Q=@
|
|
|
|
MSG=@echo
|
|
|
|
else
|
|
|
|
MSG=@true
|
|
|
|
endif
|
|
|
|
|
|
|
|
SRCS = $(foreach dir, $(SRCPATH), $(wildcard $(dir)/*.c))
|
|
|
|
OBJS = $(patsubst %.c, %.o, $(SRCS))
|
|
|
|
DEPS = $(patsubst %.c, %.d, $(SRCS))
|
|
|
|
INCFLAGS = $(foreach dir, $(INCPATH), -I"$(dir)")
|
|
|
|
|
|
|
|
.PHONY : clean
|
|
|
|
|
|
|
|
all: $(TARGET)
|
|
|
|
|
2022-07-02 15:27:37 +01:00
|
|
|
debug: CFLAGS += $(DEBUG_FLAGS)
|
2021-04-19 07:40:11 +01:00
|
|
|
debug: all
|
|
|
|
|
2022-07-02 15:27:37 +01:00
|
|
|
test: CFLAGS += $(TEST_FLAGS)
|
|
|
|
test: LFLAGS += $(TEST_FLAGS)
|
2021-04-19 07:40:11 +01:00
|
|
|
test: all
|
|
|
|
$(MSG) [Run Testcases...]
|
|
|
|
$(Q) ./testall.be
|
|
|
|
$(Q) $(RM) */*.gcno */*.gcda
|
|
|
|
|
|
|
|
$(TARGET): $(OBJS)
|
|
|
|
$(MSG) [Linking...]
|
|
|
|
$(Q) $(CC) $(OBJS) $(LFLAGS) $(LIBS) -o $@
|
|
|
|
$(MSG) done
|
|
|
|
|
|
|
|
$(OBJS): %.o: %.c
|
|
|
|
$(MSG) [Compile] $<
|
|
|
|
$(Q) $(CC) -MM $(CFLAGS) $(INCFLAGS) -MT"$*.d" -MT"$(<:.c=.o)" $< > $*.d
|
|
|
|
$(Q) $(CC) $(CFLAGS) $(INCFLAGS) -c $< -o $@
|
|
|
|
|
|
|
|
sinclude $(DEPS)
|
|
|
|
|
|
|
|
$(OBJS): $(CONST_TAB)
|
|
|
|
|
2022-07-02 15:27:37 +01:00
|
|
|
$(CONST_TAB): $(GENERATE) $(SRCS) $(CONFIG)
|
2021-04-19 07:40:11 +01:00
|
|
|
$(MSG) [Prebuild] generate resources
|
2022-07-02 15:27:37 +01:00
|
|
|
$(Q) $(COC) -o $(GENERATE) $(SRCPATH) -c $(CONFIG)
|
2021-04-19 07:40:11 +01:00
|
|
|
|
|
|
|
$(GENERATE):
|
|
|
|
$(Q) $(MKDIR) $(GENERATE)
|
|
|
|
|
|
|
|
install:
|
|
|
|
cp $(TARGET) /usr/local/bin
|
|
|
|
|
|
|
|
uninstall:
|
|
|
|
$(RM) /usr/local/bin/$(TARGET)
|
|
|
|
|
2022-07-02 15:27:37 +01:00
|
|
|
prebuild: $(GENERATE)
|
2021-04-19 07:40:11 +01:00
|
|
|
$(MSG) [Prebuild] generate resources
|
2022-07-02 15:27:37 +01:00
|
|
|
$(Q) $(COC) -o $(GENERATE) $(SRCPATH) -c $(CONFIG)
|
2021-04-19 07:40:11 +01:00
|
|
|
$(MSG) done
|
|
|
|
|
|
|
|
clean:
|
|
|
|
$(MSG) [Clean...]
|
|
|
|
$(Q) $(RM) $(OBJS) $(DEPS) $(GENERATE)/* berry.lib
|
|
|
|
$(MSG) done
|