makefile 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. CC = g++
  2. SRC := src
  3. BUILD_DIR := cate/build
  4. CFLAGS := -std=c++17 -fpermissive -lstdc++fs -pthread -march=native -Ofast -Iinclude
  5. SIZE_OPTIMIZATION_FLAGS := -ffunction-sections -fdata-sections -Wl,--gc-sections -fno-exceptions \
  6. -fno-ident -fomit-frame-pointer -fmerge-all-constants -Wl,--build-id=none
  7. SOURCES := $(wildcard $(SRC)/*.cpp)
  8. OBJECTS := $(patsubst $(SRC)/%.cpp, $(BUILD_DIR)/%.o, $(SOURCES))
  9. all: build_directory out/cate
  10. smol: build_directory smol_cate
  11. build_directory:
  12. @mkdir -p $(BUILD_DIR)
  13. out/cate: $(OBJECTS)
  14. @$(CC) $^ -o out/cate $(CFLAGS) externals/linux_amd64_libfl.a
  15. smol_cate: $(OBJECTS)
  16. @$(CC) $^ -o out/cate $(SIZE_OPTIMIZATION_FLAGS) $(CFLAGS) externals/linux_amd64_libfl.a
  17. strip -S --strip-unneeded --remove-section=.note.gnu.gold-version --remove-section=.comment --remove-section=.note --remove-section=.note.gnu.build-id --remove-section=.note.ABI-tag out/cate
  18. lex: src/lexer.l
  19. flex --full --noyywrap -osrc/Lexer.cpp --header-file=src/Lexer.hpp src/lexer.l
  20. sed -i 's/int yyFlexLexer::yywrap() { return 1;}/ /g' src/Lexer.hpp
  21. $(BUILD_DIR)/%.o: $(SRC)/%.cpp
  22. @$(CC) -I$(SRC) -c $< -o $@ $(CFLAGS) $(SIZE_OPTIMIZATION_FLAGS)
  23. install:
  24. @cp out/cate /usr/bin/cate
  25. @echo "Installed cate!"
  26. uninstall:
  27. @rm /usr/bin/cate
  28. @echo "Uninstalled cate!"
  29. clean:
  30. @rm -rf $(BUILD_DIR)/*.o