-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
executable file
·55 lines (55 loc) · 1.45 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
ifeq ($(OS),Windows_NT)
LIB=libmat.dll
PATHSEP=\
EXEC=mat.exe
CP=copy
else
UNAME_S:= $(shell uname -s)
ifeq ($(UNAME_S),Linux)
LIB=libmat.so
endif
ifeq ($(UNAME_S),Darwin)
LIB=libmat.dylib
endif
PATHSEP=/
EXEC=mat.out
CP=cp
endif
ifneq ($(CXX),)
CXX=g++
CPPFLAGS=-Wall -fexceptions -Iinclude -Linclude -lmat
LIBFLAGS=-shared -fPIC -Wall -fexceptions
else
ifeq ($(CXX),g++)
CPPFLAGS=-Wall -fexceptions -Iinclude -Linclude -lmat
LIBFLAGS=-shared -fPIC -Wall -fexceptions
endif
endif
all: $(LIB)
$(EXEC): $(LIB)
@echo "Building $(EXEC)"
$(CXX) examples$(PATHSEP)mat.cpp $(CPPFLAGS) -o examples$(PATHSEP)$(EXEC)
header:
@echo "Checking Header"
$(CXX) -fsyntax-only -Wcpp include$(PATHSEP)mat.h
$(LIB): header
@echo "Building $(LIB)"
$(CXX) include$(PATHSEP)lib.cpp $(LIBFLAGS) -o include$(PATHSEP)$(LIB)
clean:
@echo "Cleaning"
rm -f include$(PATHSEP)libmat.so examples$(PATHSEP)$(EXEC) $(LIB)
test: clean $(EXEC)
@echo "Running $(EXEC)"
@$(CP) include$(PATHSEP)$(LIB) $(LIB)
LD_LIBRARY_PATH=. examples$(PATHSEP)${EXEC}
debug: clean
@echo "Preparing for debugging"
@echo "Checking Header"
$(CXX) -fsyntax-only -Wcpp include$(PATHSEP)mat.h
@echo "Building $(LIB)"
$(CXX) include$(PATHSEP)lib.cpp $(LIBFLAGS) -g -o include$(PATHSEP)$(LIB)
$(CXX) examples$(PATHSEP)mat.cpp $(CPPFLAGS) -g -o examples$(PATHSEP)$(EXEC)
@echo "Debugging $(EXEC)"
@$(CP) include$(PATHSEP)$(LIB) $(LIB)
LD_LIBRARY_PATH=. gdb examples$(PATHSEP)${EXEC}
@make clean