diff --git a/Makefile b/Makefile index d93cd51f..0b47f4b2 100644 --- a/Makefile +++ b/Makefile @@ -12,7 +12,7 @@ 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) +LIB_FILE = lib$(LIB_NAME).a TEST_BIN = spec/run.out ### build configuration ### @@ -22,18 +22,21 @@ CPPFLAGS ?= -Wall -std=c++11 -g -m64 ### targets ### all: $(LIB_FILE) +$(LIB_FILE): $(SRC_OBJECTS) + ar rcs $@ $^ + +test: $(TEST_BIN) + ./$< + +$(TEST_BIN): $(TEST_OBJECTS) $(LIB_FILE) + $(CXX) $(CPPFLAGS) $^ -o $@ + %.o: %.c $(CC) $(CFLAGS) -Iinclude -Isrc/runtime -c $< -o $@ %.o: %.cpp $(CXX) $(CPPFLAGS) -Iinclude -Isrc/compiler -Isrc/runtime -Iexternals/bandit -Ispec -c $< -o $@ -test: $(TEST_BIN) - ./$< - -$(TEST_BIN): $(TEST_OBJECTS) $(SRC_OBJECTS) - $(CXX) $(CPPFLAGS) $(TEST_OBJECTS) $(SRC_OBJECTS) -o $@ - debug: $(TEST_BIN) gdb $<