-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
66 lines (49 loc) · 1.83 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
BASE_DIR=$(shell pwd)
SWIG_DIR=$(BASE_DIR)/swig
SRC_DIR=$(BASE_DIR)/src
INC_DIR=$(BASE_DIR)/include
TEST_DIR=$(BASE_DIR)/test
BIN_DIR=$(BASE_DIR)/bin
OBJ_DIR=$(BASE_DIR)/obj
CC=g++
PYFLAGS=-c -fPIC -O3 -I$(INC_DIR) $$(pkg-config --cflags --libs python)
CFLAGS=-c -fPIC -Wall -O3 -I$(INC_DIR)
OUTFLAGS=-Wall -O3 -I$(INC_DIR)
CLA_SOURCE=Cell.cpp Column.cpp Cortex.cpp DendriteSegment.cpp DistalSegment.cpp ProximalSegment.cpp Region.cpp Synapse.cpp CLA.cpp Classifier.cpp
CLA_SOURCE_FILES=$(addprefix $(SRC_DIR)/,$(CLA_SOURCE))
CLA_INCLUDE=$(CLA_SOURCE:.cpp=.h)
CLA_INCLUDE_FILES=$(addprefix $(INC_DIR)/,$(CLA_INCLUDE))
CLA_OBJECTS=$(CLA_SOURCE:.cpp=.o)
CLA_OBJECT_FILES=$(addprefix $(OBJ_DIR)/,$(CLA_OBJECTS))
PY_SOURCE=cla_wrap.cxx
PY_SOURCE_FILES=$(addprefix $(SWIG_DIR)/,$(PY_SOURCE))
PY_OBJECTS=$(PY_SOURCE:.cxx=.o)
PY_OBJECT_FILES=$(addprefix $(SWIG_DIR)/,$(PY_OBJECTS))
PY_SO=clamodule.so
TEST_SOURCE=main.cpp
TEST_SOURCE_FILES=$(addprefix $(TEST_DIR)/,$(TEST_SOURCE))
TEST_EXEC=test_cla
.PHONY: all build_obj build_test build_py clean unbuild
all: build_obj build_test
build_obj: $(CLA_SOURCE_FILES) $(CLA_INCLUDE_FILES)
$(info ==========BUILDING CLA LIBRARY==========)
$(CC) $(CFLAGS) $(CLA_SOURCE_FILES)
mv *.o $(OBJ_DIR)
build_test: build_obj $(TEST_SOURCE_FILES)
$(info ==========BUILDING TEST SUITE===========)
$(CC) $(TEST_SOURCE_FILES) $(CLA_OBJECT_FILES) $(OUTFLAGS) -o $(BIN_DIR)/$(TEST_EXEC)
build_py: build_obj
$(info ========BUILDING PYTHON FRONTEND========)
swig -c++ -python -lembed.i $(SWIG_DIR)/cla.i
g++ -DHAVE_CONFIG_H $(PYFLAGS) $(PY_SOURCE_FILES)
mv *.o $(SWIG_DIR)
g++ -shared -fPIC $(CLA_OBJECT_FILES) $(PY_OBJECT_FILES) -o $(SWIG_DIR)/$(PY_SO)
clean:
rm -f $(CLA_OBJECT_FILES)
rm -f ./*.stackdump
unbuild: clean
rm -f $(TEST_EXEC_FILE)
test: all
$(BIN_DIR)/$(TEST_EXEC)
test_win: all
$(BIN_DIR)/$(TEST_EXEC).exe