diff options
| author | Stephan Seitz <stephan.seitz@fau.de> | 2022-02-07 22:06:50 +0100 |
|---|---|---|
| committer | Stephan Seitz <stephan.seitz@fau.de> | 2022-02-08 23:37:59 +0100 |
| commit | 5639b74db0f379c159afcc6ab14bf5dffddae4e8 (patch) | |
| tree | 1f8a4c9f23dd4c02f67872a2d684c6f51fd591f2 /scripts | |
| parent | fix(makefile): fallback to c++14 when parser does not have cxx_standard set (diff) | |
| download | nvim-treesitter-5639b74db0f379c159afcc6ab14bf5dffddae4e8.tar nvim-treesitter-5639b74db0f379c159afcc6ab14bf5dffddae4e8.tar.gz nvim-treesitter-5639b74db0f379c159afcc6ab14bf5dffddae4e8.tar.bz2 nvim-treesitter-5639b74db0f379c159afcc6ab14bf5dffddae4e8.tar.lz nvim-treesitter-5639b74db0f379c159afcc6ab14bf5dffddae4e8.tar.xz nvim-treesitter-5639b74db0f379c159afcc6ab14bf5dffddae4e8.tar.zst nvim-treesitter-5639b74db0f379c159afcc6ab14bf5dffddae4e8.zip | |
chore(makefile): apply fixes to original makefile
Diffstat (limited to 'scripts')
| -rw-r--r-- | scripts/compile_parsers.makefile | 56 |
1 files changed, 47 insertions, 9 deletions
diff --git a/scripts/compile_parsers.makefile b/scripts/compile_parsers.makefile index 4e689841e..1ad3458ea 100644 --- a/scripts/compile_parsers.makefile +++ b/scripts/compile_parsers.makefile @@ -1,13 +1,51 @@ -CC?=cc -CXX_STANDARD?=c++14 +CFLAGS ?= -Os -std=c99 -fPIC +CXXFLAGS ?= -Os -std=c++14 -fPIC +LDFLAGS ?= +SRC_DIR ?= ./src +DEST_DIR ?= ./dest -all: parser.so +ifeq ($(OS),Windows_NT) + SHELL := powershell.exe + .SHELLFLAGS := -NoProfile -command + CP := Copy-Item -Recurse -ErrorAction SilentlyContinue + MKDIR := New-Item -ItemType directory -ErrorAction SilentlyContinue + TARGET := parser.dll + rmf = Write-Output $(1) | foreach { if (Test-Path $$_) { Remove-Item -Force } } +else + CP := cp + MKDIR := mkdir -p + TARGET := parser.so + rmf = rm -rf $(1) +endif -parser.o: src/parser.c - $(CC) -c src/parser.c -std=c99 -Os -fPIC -I./src +ifneq ($(wildcard $(SRC_DIR)/*.cc),) + LDFLAGS += -lstdc++ +endif -scanner.o: src/scanner.cc - $(CC) -c src/scanner.cc -std=$(CXX_STANDARD) -Os -fPIC -I./src +OBJECTS := parser.o -parser.so: parser.o scanner.o - $(CC) parser.o scanner.o -o parser.so -shared -lstdc++ +ifneq ($(wildcard $(SRC_DIR)/scanner.*),) + OBJECTS += scanner.o +endif + +all: $(TARGET) + +$(TARGET): $(OBJECTS) + $(CC) $(OBJECTS) -o $(TARGET) -shared $(LDFLAGS) + +%.o: $(SRC_DIR)/%.c + $(CC) -c $(CFLAGS) -I$(SRC_DIR) -o $@ $< + +%.o: $(SRC_DIR)/%.cc + $(CC) -c $(CXXFLAGS) -I$(SRC_DIR) -o $@ $< + +clean: + $(call rmf,$(TARGET) $(OBJECTS)) + +$(DEST_DIR): + @$(MKDIR) $(DEST_DIR) + +install: $(TARGET) $(DEST_DIR) + $(CP) $(TARGET) $(DEST_DIR)/ + +.PHONY: clean |
