fix(makefile): scanner.c isn't always available

certain parsers like `tree-sitter-go` only contain parser.{c|cc}
This commit is contained in:
kylo252 2022-01-29 14:24:15 +01:00 committed by Stephan Seitz
parent 4e6cb69114
commit 8980197d61

View file

@ -22,21 +22,25 @@ else
rmf = rm -rf $(1)
endif
ifneq ($(wildcard src/*.cc),)
ifneq ($(wildcard $(SRC_DIR)/*.cc),)
LDFLAGS += -lstdc++
endif
OBJECTS := parser.o scanner.o
OBJECTS := parser.o
ifneq ($(wildcard $(SRC_DIR)/scanner.*),)
OBJECTS += scanner.o
endif
all: $(TARGET)
$(TARGET): $(OBJECTS)
$(CC) $(OBJECTS) -o $(TARGET) $(LDFLAGS)
%.o: src/%.c
%.o: $(SRC_DIR)/%.c
$(CC) -c $(CFLAGS) -I$(SRC_DIR) -o $@ $<
%.o: src/%.cc
%.o: $(SRC_DIR)/%.cc
$(CC) -c $(CXXFLAGS) -I$(SRC_DIR) -o $@ $<
clean: