mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-18 11:20:07 -04:00
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
This commit is contained in:
parent
91fdda9b5c
commit
67f5acb882
1 changed files with 43 additions and 11 deletions
|
|
@ -1,18 +1,50 @@
|
||||||
#
|
#
|
||||||
# compile_parsers.makefile
|
# 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
|
ifeq ($(OS),Windows_NT)
|
||||||
$(CC) -c src/parser.c -std=$(C_STANDARD) -fPIC -I./src
|
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
|
ifneq ($(wildcard src/*.cc),)
|
||||||
$(CC) -c src/scanner.cc -std=$(CXX_STANDARD) -fPIC -I./src
|
LDFLAGS += -lstdc++
|
||||||
|
endif
|
||||||
|
|
||||||
parser.so: parser.o scanner.o
|
OBJECTS := parser.o scanner.o
|
||||||
$(CC) parser.o scanner.o -o parser.so -shared -Os -lstdc++
|
|
||||||
|
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
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue