nvim-treesitter/scripts/compile_parsers.makefile

52 lines
1.1 KiB
Text
Raw Normal View History

2021-09-09 22:11:07 +02:00
#
# compile_parsers.makefile
#
CFLAGS ?= -std=c99 -fPIC
CXXFLAGS ?= -std=c++14 -fPIC
LDFLAGS ?= -Os -shared
SRC_DIR ?= ./src
DEST_DIR ?= ./dest
2021-09-09 22:11:07 +02:00
ifeq ($(OS),Windows_NT)
2022-01-24 18:06:54 +01:00
SHELL := powershell.exe
.SHELLFLAGS := -NoProfile -command
CP := Copy-Item -Recurse -ErrorAction SilentlyContinue
MKDIR := New-Item -ItemType directory -ErrorAction SilentlyContinue
2022-01-24 18:06:54 +01:00
TARGET := parser.dll
rmf = Write-Output $(1) | foreach { if (Test-Path $$_) { Remove-Item -Force } }
else
2022-01-24 18:06:54 +01:00
CP := cp
MKDIR := mkdir -p
2022-01-24 18:06:54 +01:00
TARGET := parser.so
rmf = rm -rf $(1)
endif
2021-09-09 22:11:07 +02:00
ifneq ($(wildcard src/*.cc),)
LDFLAGS += -lstdc++
endif
2021-09-09 22:11:07 +02:00
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:
$(call rmf,$(TARGET) $(OBJECTS))
2022-01-24 18:06:54 +01:00
$(DEST_DIR):
@$(MKDIR) $(DEST_DIR)
2022-01-24 18:06:54 +01:00
install: $(TARGET) $(DEST_DIR)
$(CP) $(TARGET) $(DEST_DIR)/
2022-01-24 18:06:54 +01:00
.PHONY: clean