added an interupt handler has SIGINT was being ignored... ?
[physics.git] / src / Makefile
1
2 LIBGL := -lGL -lGLU
3 LIBSDL := `sdl-config --libs`
4 LIBS := ${LIBSDL} ${LIBGL}
5
6 OPTFLAGS := -O2
7 DBGFLAGS := -ggdb
8 PRFFLAGS := ${DBGFLAGS} -pg
9
10 #CXX := g++
11 CXXFLAGS := -Wall -pedantic -ansi ${DBGFLAGS}
12
13 TARGET := ../run_physics
14
15 SRCS := # simply to keep every line below the same
16 SRCS += entityManager.cpp
17 SRCS += entityCreator.cpp
18 SRCS += game.cpp
19 SRCS += main.cpp
20 SRCS += mathw.cpp
21 SRCS += ticks.cpp
22 SRCS += Vector2.cpp
23 SRCS += handleSignal.cpp
24
25 SRCS += Entities/Ball.cpp
26 SRCS += Entities/Entity.cpp
27 SRCS += Entities/Line.cpp
28 SRCS += Entities/Particle.cpp
29 SRCS += Entities/PhysicsEntity.cpp
30 SRCS += Entities/Point.cpp
31 SRCS += Entities/Polygon.cpp
32 SRCS += Entities/WindParticle.cpp
33
34 SRCS += GameStates/CreatingPolygon.cpp
35 SRCS += GameStates/GameState.cpp
36 SRCS += GameStates/Paused.cpp
37 SRCS += GameStates/Running.cpp
38
39 SRCS += input/inputManager.cpp
40
41 SRCS += graphics/graphics.cpp
42
43 OBJS := ${SRCS:.cpp=.o}
44 DEPENDS := ${SRCS:.cpp=.d}
45
46 HRDS := ${SRCS:.cpp=.h}
47 HRDS := ${HRDS:main.h=} # remove main.h
48 HRDS += debug.h
49 HRDS += graphics/colors.h
50
51 TARS := ${SRCS} ${HRDS} Makefile
52
53
54 VERBOSE := 0
55
56 ifeq (${VERBOSE},0)
57     # quiet the echo command
58     Q1 := @
59     # quiet the command that is `replaced' by an echo
60     Q2 := @
61 else
62     # EAT the echo command as if it was not there
63     Q1 := @true # NOTE: the space between @true and the # is VERY important!!
64     # do not quiet the command output
65     Q2 :=
66 endif
67
68 .PHONY: all
69 all: ${TARGET}
70
71 ${TARGET}: ${OBJS}
72         ${Q1}echo "${CXX}: $@"
73         ${Q2}${CXX} ${CXXFLAGS} -o ${TARGET} $^ ${LIBS}
74
75 # rule to make a depend file from a .cpp
76 %.d: %.cpp
77         ${Q1}echo "DEP: $@"
78         ${Q2}${CXX} -M ${CXXFLAGS} $< | sed 's,: , $@: ,' > $@
79
80 # rule to make an object file from a .cpp
81 %.o: %.cpp
82         ${Q1}echo "${CXX}: $@"
83         ${Q2}${CXX} ${CXXFLAGS} -c -o $@ $<
84
85
86 .PHONY: clean
87 clean:
88         ${Q1}echo "CLEAN: OBJS"
89         ${Q2}rm -f ${OBJS}
90         ${Q1}echo "CLEAN: TARGET"
91         ${Q2}rm -f ${TARGET}
92
93 .PHONY: distclean
94 distclean: clean
95         ${Q1}echo "CLEAN: DEPENDS"
96         ${Q2}rm -f ${DEPENDS}
97         ${Q1}echo "CLEAN: tags prof gmon.out"
98         ${Q2}rm -f tags prof gmon.out
99
100 tags: ${SRCS}
101         ctags $^
102
103 tar:
104         ${Q1}echo "tar: physics.tar.bz2"
105         ${Q2}rm -f physics.tar # prevents appending
106         ${Q2}for f in ${TARS}; do\
107                 tar -C ../.. -rf physics.tar "physics/src/$$f"; done
108         ${Q2}bzip2 physics.tar
109
110 git-tar:
111         ${Q1}echo "git-archive: ../physics.tar.bz2"
112         ${Q2}cd ..; git-archive --prefix=physics/ HEAD | bzip2 > physics.tar.bz2
113
114 .PHONY: run
115 run: all
116         ${TARGET}
117
118 .PHONY: val
119 val: all
120         valgrind --leak-check=full ${TARGET}
121
122 .PHONY: prof
123 prof: all
124         ${TARGET}
125         gprof -b ${TARGET} > prof
126         kprof -f prof
127
128 -include ${DEPENDS}