tree-sitter/Makefile

47 lines
1.2 KiB
Makefile
Raw Normal View History

2014-02-18 09:07:00 -08:00
.PHONY: all clean test debug valgrind
2013-11-05 22:15:19 -08:00
### install configuration ###
2014-02-18 12:38:29 -08:00
CXX ?= clang++
CC ?= clang
2013-11-05 22:15:19 -08:00
RM ?= rm -f
MKDIR ?= $(INSTALL) -d
SYMLINK ?= ln -s
### library configuration ###
2014-02-18 09:07:00 -08:00
LIB_NAME = tree_sitter
DIR = $(shell pwd)
SOURCES = $(shell find src -name '*.cpp' -or -name '*.c')
TESTS = $(shell find spec -name '*.cpp') $(shell find examples -name '*.c')
SRC_OBJECTS = $(foreach file, $(SOURCES), $(basename $(file)).o)
TEST_OBJECTS = $(foreach file, $(TESTS), $(basename $(file)).o)
LIB_FILE = lib$(LIB_NAME)$(SO)
TEST_BIN = spec/run.out
2013-11-05 22:15:19 -08:00
### build configuration ###
2014-02-18 09:07:00 -08:00
CFLAGS ?= -Wall -g -m64
2014-02-19 09:02:17 -08:00
CPPFLAGS ?= -Wall -std=c++11 -g -m64
2013-11-05 22:15:19 -08:00
### targets ###
all: $(LIB_FILE)
2014-02-18 09:07:00 -08:00
%.o: %.c
$(CC) $(CFLAGS) -Iinclude -Isrc/runtime -c $< -o $@
%.o: %.cpp
2014-02-18 12:38:29 -08:00
$(CXX) $(CPPFLAGS) -Iinclude -Isrc/compiler -Isrc/runtime -Iexternals/bandit -Ispec -c $< -o $@
2013-11-05 22:15:19 -08:00
test: $(TEST_BIN)
./$<
2014-02-18 09:07:00 -08:00
$(TEST_BIN): $(TEST_OBJECTS) $(SRC_OBJECTS)
2014-02-18 12:38:29 -08:00
$(CXX) $(CPPFLAGS) $(TEST_OBJECTS) $(SRC_OBJECTS) -o $@
2013-11-05 22:15:19 -08:00
debug: $(TEST_BIN)
gdb $<
valgrind: $(TEST_BIN)
valgrind --track-origins=yes $(TEST_BIN)
clean:
2014-02-18 09:07:00 -08:00
$(RM) $(SRC_OBJECTS) $(TEST_OBJECTS) $(LIB_FILE) $(TEST_BIN)