Add static library as make target

This commit is contained in:
Max Brunsfeld 2014-03-02 00:07:00 -08:00
parent 8797c9097f
commit 3c646d707a

View file

@ -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 $<