diff options
| author | kylo252 <59826753+kylo252@users.noreply.github.com> | 2022-01-24 17:21:15 +0100 |
|---|---|---|
| committer | Stephan Seitz <stephan.seitz@fau.de> | 2022-01-25 09:04:57 +0100 |
| commit | 67f5acb882d72ca9c568c1a938f8d28100a1e753 (patch) | |
| tree | 2b97a63ca61ac2e68539d05831e6e417648afe60 /scripts | |
| parent | folds(c): fold at compound_statement (diff) | |
| download | nvim-treesitter-67f5acb882d72ca9c568c1a938f8d28100a1e753.tar nvim-treesitter-67f5acb882d72ca9c568c1a938f8d28100a1e753.tar.gz nvim-treesitter-67f5acb882d72ca9c568c1a938f8d28100a1e753.tar.bz2 nvim-treesitter-67f5acb882d72ca9c568c1a938f8d28100a1e753.tar.lz nvim-treesitter-67f5acb882d72ca9c568c1a938f8d28100a1e753.tar.xz nvim-treesitter-67f5acb882d72ca9c568c1a938f8d28100a1e753.tar.zst nvim-treesitter-67f5acb882d72ca9c568c1a938f8d28100a1e753.zip | |
refactor(installer): more modular makefile
- support both scanner.cc and scanner.c
- allow complete override for (CFLAGS,CXXFLAGS,LDFLAGS)
- add `clean` target
- add `install` target
- add windows support
Diffstat (limited to 'scripts')
| -rw-r--r-- | scripts/compile_parsers.makefile | 54 |
1 files changed, 43 insertions, 11 deletions
diff --git a/scripts/compile_parsers.makefile b/scripts/compile_parsers.makefile index 5d78d2493..c3bbcbbd8 100644 --- a/scripts/compile_parsers.makefile +++ b/scripts/compile_parsers.makefile @@ -1,18 +1,50 @@ # # compile_parsers.makefile -# Stephan Seitz, 2021-09-09 21:36 # -CC?=cc -CXX_STANDARD?=c++14 -C_STANDARD?=c99 -all: parser.so +CFLAGS ?= -std=c99 -fPIC +CXXFLAGS ?= -std=c++14 -fPIC +LDFLAGS ?= -Os -shared +SRC_DIR ?= ./src +DEST_DIR ?= ./dest -parser.o: src/parser.c - $(CC) -c src/parser.c -std=$(C_STANDARD) -fPIC -I./src +ifeq ($(OS),Windows_NT) + MKDIR ?= mkdir + RM ?= cmd /C rmdir /Q /S + CP ?= copy + TARGET ?= parser.dll +else + MKDIR ?= mkdir -p + RM ?= rm -rf + CP ?= cp + TARGET ?= parser.so +endif -scanner.o: src/scanner.cc - $(CC) -c src/scanner.cc -std=$(CXX_STANDARD) -fPIC -I./src +ifneq ($(wildcard src/*.cc),) + LDFLAGS += -lstdc++ +endif -parser.so: parser.o scanner.o - $(CC) parser.o scanner.o -o parser.so -shared -Os -lstdc++ +OBJECTS := parser.o scanner.o + +all: $(TARGET) + +$(TARGET): $(OBJECTS) + $(CC) $(OBJECTS) -o $(TARGET) $(LDFLAGS) + +%.o: src/%.c + $(CC) -c $(CFLAGS) -I$(SRC_DIR) -o $@ $< + +%.o: src/%.cc + $(CC) -c $(CXXFLAGS) -I$(SRC_DIR) -o $@ $< + +clean: + $(RM) $(OBJECTS) $(TARGET) + +install: $(TARGET) + $(MKDIR) $(DEST_DIR) + $(CP) $^ $(DEST_DIR) + +uninstall: + $(RM) $(DEST_DIR)/$(TARGET) + +.PHONY: clean uninstall |
