mnist-classify/Makefile
Arija A. e32b0ba0c3
Update flags.
Signed-off-by: Arija A. <ari@ari.lt>
2025-05-18 18:35:30 +03:00

42 lines
1.7 KiB
Makefile

LIBS := -lm
ifeq ($(NOQA),)
CXXFLAGS += -std=c++17 -Wall -Wextra -Wpedantic -pedantic -Wshadow -Werror -Wconversion -Wformat -Wuninitialized -Wmissing-declarations -Wredundant-decls -Wfloat-equal -Wcast-qual -Wvla -Winline -pedantic-errors -Wformat-security -Wno-sign-conversion
endif
ifeq ($(DEBUG),)
CXXFLAGS += -ffast-math -O3 -funroll-loops
F_CXXFLAGS += -s
endif
ifneq ($(NOSECURITY),)
CXX := clang++
CXXFLAGS += -flto=full -fno-trapping-math -fstrict-aliasing -fno-math-errno -fno-stack-check -fno-strict-overflow -fno-stack-protector -mfancy-math-387 -fomit-frame-pointer -fstrict-overflow -D_FORTIFY_SOURCE=0 -fno-signed-zeros -fno-strict-aliasing -funsafe-math-optimizations -fno-asynchronous-unwind-tables -fdiscard-value-names -femit-all-decls -fmerge-all-constants -fno-use-cxa-atexit -fno-use-init-array
CLANG = 1
endif
ifneq ($(CLANG),)
CXX := clang++
CXXFLAFS += -fvectorise
STRIP = llvm-strip
endif
SRC_DIR := src
OBJ_DIR := obj
SRC_FILES := $(wildcard $(SRC_DIR)/*.cc)
OBJ_FILES := $(patsubst $(SRC_DIR)/%.cc,$(OBJ_DIR)/%.o,$(SRC_FILES))
mnist-classify: $(OBJ_FILES)
$(CXX) -o $@ $(CXXFLAGS) $(F_CFLAGS) $^ $(LIBS) $(LDFLAGS) $(F_LDFLAGS)
$(OBJ_DIR):
mkdir -p $(OBJ_DIR)
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.cc $(SRC_DIR)/%.hh | $(OBJ_DIR)
$(CXX) -c -o $@ $(CXXFLAGS) $< $(LDFLAGS)
clean:
rm -rf mnist-classify $(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 mnist-classify