Tasmota/lib/libesp32/berry/Makefile

94 lines
2.3 KiB
Makefile
Raw Permalink Normal View History

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
CC = gcc
2022-07-02 15:27:37 +01:00
MKDIR = mkdir
LFLAGS =
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
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)
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)
debug: all
2022-07-02 15:27:37 +01:00
test: CFLAGS += $(TEST_FLAGS)
test: LFLAGS += $(TEST_FLAGS)
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)
$(MSG) [Prebuild] generate resources
2022-07-02 15:27:37 +01:00
$(Q) $(COC) -o $(GENERATE) $(SRCPATH) -c $(CONFIG)
$(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)
$(MSG) [Prebuild] generate resources
2022-07-02 15:27:37 +01:00
$(Q) $(COC) -o $(GENERATE) $(SRCPATH) -c $(CONFIG)
$(MSG) done
clean:
$(MSG) [Clean...]
$(Q) $(RM) $(OBJS) $(DEPS) $(GENERATE)/* berry.lib
$(MSG) done