-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
119 lines (93 loc) · 2.93 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#---------------------------------------------------------------------
# Detect system type using uname command.
#
# On Linux, uname -s returns 'Linux'
# On Linux 64, uname -m additionally returns x86_64
# On Mac OS X, uname -s returns 'Darwin'
#
# See discussion at http://osdir.com/ml/gnu.make.bugs/2002-09/msg00003.html
# Conclusion: instead of using OSTYPE (env var defined in bash), manually
# set OSTYPE := $(shell uname -msr)
# In order to avoid confusion, I'm going to just use OSNAME := $(shell uname -s).
#---------------------------------------------------------------------
OSNAME := $(shell uname -s)
MACHINE := $(shell uname -m)
ifeq ($(OSNAME),Linux)
ifeq ($(MACHINE),x86_64)
PLATFORM := LINUX64
else
PLATFORM := LINUX
endif
else
ifeq ($(OSNAME),Darwin)
PLATFORM := MAC_OS_X
else
PLATFORM := OTHER
endif
endif
#---------------------------------------------------------------------
# Choose a compiler & its options
#---------------------------------------------------------------------
g++ = g++
CXX = g++
ifeq ($(CXX),icpc)
# If the compiler is ICPC, use some extra flags
OPTS = -pipe -O3 -MMD -ip -vec-report0 -diag-disable cpu-dispatch
else
OPTS = -pipe -O3 -MMD
endif
ifeq ($(PLATFORM),MAC_OS_X)
OPTS += -DMACOS
endif
ifneq ($(ENABLE_LOGGING),0)
OPTS += -DENABLE_LOGGING=1
endif
#-------------------------------------------------------------------
# Base parameters for INCLUDE and LIB.
#
# The next sections after this one add items to INCLUDE and LIB using
# the += operator.
#-------------------------------------------------------------------
INCLUDE = -I.
LIB = $(LIBS)
#--------------------------------------------------------------------
# Add Xlib and OpenGL
#--------------------------------------------------------------------
ifneq ($(GL_ON),0)
OPTS += -DGL_ON=1
ifeq ($(PLATFORM),MAC_OS_X)
GL_LIB = -framework OpenGL -framework GLUT -framework Foundation
LIB += $(GL_LIB)
else
GL_LIB = -lglut -lGL -lGLU
LIB += -L./lib $(GL_LIB)
INCLUDE += -I/usr/include
endif
endif
#--------------------------------------------------------------------
DIRS= . mathtool GL modelgraph
SRCS=$(wildcard $(addsuffix /*.cpp,$(DIRS)))
OBJS=${SRCS:.cpp=.o}
#--------------------------------------------------------------------
# Set CFLAGS
#--------------------------------------------------------------------
INCLUDE += $(addprefix -I,$(DIRS))
CFLAGS = $(OPTS) $(INCLUDE)
CXXFLAGS = $(CFLAGS)
all: objview
#--------------------------------------------------------------------
objview: $(OBJS)
${CXX} ${CXXFLAGS} -o $@ $(OBJS) $(LIB)
clean:
rm -f *.o $(OBJS) Dependencies objview
#--------------------------------------------------------------------
# Build Rules
#--------------------------------------------------------------------
.SUFFIXES: .cpp
.cpp.o:
${CXX} ${CXXFLAGS} -c $< -o $@
cat $*.d >> Dependencies
-rm -f $*.d
Dependencies:
touch Dependencies
-include Dependencies