vessel/Makefile
Arija A. 0a8709bf31
refact: Rename src->core
Signed-off-by: Arija A. <ari@ari.lt>
2025-06-14 02:27:39 +03:00

51 lines
2.6 KiB
Makefile

LIBS := -lpthread
ifneq ($(SEC),)
CFLAGS += -O2 -fstack-protector-all -fstack-protector-strong -fstack-clash-protection -UDEBUG -DSECURITY -Wstack-protector --param ssp-buffer-size=4 -ftrapv -fPIC -fcf-protection=full -s -Wno-unused-command-line-argument -fsanitize=address,undefined,leak,signed-integer-overflow -fsanitize-undefined-trap-on-error -fanalyzer-verbose-edges -fanalyzer-verbose-state-changes -funsigned-char -fno-builtin -fharden-compares -fharden-conditional-branches -fhardened -fharden-control-flow-redundancy -fhardcfr-check-exceptions -fhardcfr-check-returning-calls -fstrub=all
LDFLAGS += -Wl,-z,relro -Wl,-z,now -Wl,-z,noexecstack -Wl,--as-needed
endif
ifneq ($(DEBUG),)
CFLAGS += -DDEBUG
endif
ifeq ($(NOQA),)
CFLAGS += -std=c99 -Wall -Wextra -Wpedantic -pedantic -Wshadow -Werror -Wconversion -Wformat -Wuninitialized -Wmissing-prototypes -Wmissing-declarations -Wstrict-prototypes -Wredundant-decls -Wfloat-equal -Wcast-qual -Wnested-externs -Wvla -Winline -Wmissing-format-attribute -Wmissing-noreturn -pedantic-errors -Wformat-security -Wsign-conversion
endif
ifneq ($(ANALYZER),)
CC = gcc
CFLAGS += -fanalyzer -Wno-analyzer-fd-leak -Wno-analyzer-unsafe-call-within-signal-handler
endif
ifneq ($(OPTI),)
CC = clang
CFLAGS += -fno-trapping-math -fstrict-aliasing -fno-math-errno -fno-stack-check -funroll-loops -fvisibility-inlines-hidden -mfancy-math-387 -fomit-frame-pointer -fstrict-overflow -fno-exceptions -fno-signed-zeros -pedantic -O3 -ffast-math -std=c99 -fno-asynchronous-unwind-tables -fdiscard-value-names -femit-all-decls -fmerge-all-constants -fno-use-cxa-atexit -fno-use-init-array -march=native -mtune=native
endif
SRC_DIRS := core web
OBJ_DIR := obj
SRC_FILES := $(shell find $(SRC_DIRS) -name '*.c')
OBJ_FILES := $(patsubst %.c,$(OBJ_DIR)/%.o,$(SRC_FILES))
SHARED_OBJ_FILES := $(filter-out $(OBJ_DIR)/main.o, $(OBJ_FILES))
vessel: $(OBJ_FILES)
$(CC) -o $@ $(CFLAGS) $(F_CFLAGS) $^ $(LIBS) $(LDFLAGS) $(F_LDFLAGS)
libvessel.so: $(SHARED_OBJ_FILES)
$(CC) -shared -o $@ $(CFLAGS) $(F_CFLAGS) $^ $(LIBS) $(LDFLAGS) $(F_LDFLAGS)
$(OBJ_DIR)/%.o: %.c
@mkdir -p $(@D)
$(CC) -c -o $@ $(CFLAGS) $<
.PHONY: clean
clean:
rm -rf vessel libvessel.so $(OBJ_DIR)
strip:
strip --remove-section=.note.gnu.gold-version --remove-section=.note --remove-section=.gnu.version --remove-section=.eh_frame --remove-section=.note.gnu.build-id --remove-section=.note.ABI-tag --strip-symbol=__gmon_start__ --remove-section=.comment --remove-section=.eh_frame_ptr --strip-unneeded --strip-all --strip-debug --merge-notes --strip-dwo --discard-all --discard-locals --verbose vessel libvessel.so