b7489c8d58a2d986cc3669e61e2022f7e45db417
[ipdf/code.git] / src / Makefile
1 #Makefile
2 ARCH := $(shell uname -m)
3 # TODO: stb_truetype doesn't compile with some of these warnings.
4
5 # This seemed like a good idea 2 hours ago ok...
6 ifeq ($(ARCH), win32)
7         CXX = i686-w64-mingw32-g++ -std=c++11 -g -Wall -Werror -Wshadow -pedantic
8 else
9         CXX = g++ -std=c++11 -g -Wall -Werror -Wshadow -pedantic -rdynamic
10 endif
11
12 MAIN = main.o
13 OBJ = log.o real.o bezier.o objectrenderer.o view.o screen.o graphicsbuffer.o framebuffer.o shaderprogram.o stb_truetype.o gl_core44.o  path.o document.o debugscript.o paranoidnumber.o
14
15 QT_INCLUDE := -I/usr/share/qt4/mkspecs/linux-g++-64 -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -Itests -I.
16 QT_DEF := -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB
17 QT_LIB :=  -L/usr/lib/x86_64-linux-gnu -lQtGui -lQtCore -lpthread 
18
19 LIB_x86_64 = ../contrib/lib/libSDL2-2.0.so.0 -lGL -lgmp
20 LIB_i386 = ../contrib/lib32/libSDL2-2.0.so.0 -lGL -lgmp
21 LIB_i686 = $(LIB_i386)
22 LIB_win32 = -mwindows -lmingw32 -L../contrib/win32/lib/ -lSDL2main -lSDL2 -lgmp -static-libgcc -lopengl32 -static-libstdc++
23
24 MAINRPATH_x86_64 = -Wl,-rpath,'$$ORIGIN/../contrib/lib'
25 MAINRPATH_i386 = -Wl,-rpath,'$$ORIGIN/../contrib/lib32'
26 MAINRPATH_i686 = $(MAINRPATH_i386)
27 MAINRPATH_win32 = -Wl,-rpath,'$$ORIGIN/../contrib/win32/lib'
28 TESTRPATH_x86_64 = -Wl,-rpath,'$$ORIGIN/../../contrib/lib'
29 TESTRPATH_i386 = -Wl,-rpath,'$$ORIGIN/../../contrib/lib32'
30 TESTRPATH_i686 = $(TESTRPATH_i386)
31 TESTRPATH_win32 = -Wl,-rpath,'$$ORIGIN/../../contrib/win32/lib'
32 OBJPATHS = $(OBJ:%=../obj/%)
33 DEPS := $(OBJPATHS:%.o=%.d)
34 CFLAGS_x86_64 := -I../contrib/include/SDL2 -I`pwd`
35 CFLAGS_i386 := -I../contrib/include32/SDL2 -I`pwd`
36 CFLAGS_i686 := $(CFLAGS_i386)
37 CFLAGS_win32 := -I../contrib/win32/include/SDL2 -I`pwd` -I../contrib/win32/include
38
39
40 LIB := $(LIB_$(ARCH))
41 MAINRPATH := $(MAINRPATH_$(ARCH))
42 TESTRPATH := $(TESTRPATH_$(ARCH))
43
44 CFLAGS := $(CFLAGS_$(ARCH))
45
46 RM = rm -f
47 BIN = ../bin/ipdf
48 REALTYPE=1
49 CONTROLPANEL=enabled
50 QUADTREE=disabled
51 DEF = -DREALTYPE=$(REALTYPE)
52
53
54
55 ## Only link with things we care about
56
57 ifeq ($(QUADTREE),enabled)
58         OBJ := $(OBJ) quadtree.o
59 else
60         DEF := $(DEF) -DQUADTREE_DISABLED
61 endif
62
63 ifeq ($(CONTROLPANEL),enabled)
64         LIB := $(LIB) $(QT_LIB)
65         DEF := $(DEF) $(QT_DEF)
66         CFLAGS := $(CFLAGS) $(QT_INCLUDE)
67         OBJ := $(OBJ) moc_controlpanel.o controlpanel.o
68 else
69         DEF := $(DEF) -DCONTROLPANEL_DISABLED
70 endif
71
72 ifeq ($REALTYPE),3)
73         OBJ := $(OBJ) vfpu.o
74 endif
75
76 ifeq ($(REALTYPE),5)
77         OBJ := $(OBJ) add_digits_asm.o sub_digits_asm.o mul_digits_asm.o div_digits_asm.o arbint.o
78         LIB := $(LIB) -lgmp
79 endif
80
81 ifeq ($(REALTYPE),6)
82         LIB := $(LIB) -lgmp -lmpfr
83 endif
84
85 ifeq ($(REALTYPE),7)
86         LIB := $(LIB) -L../contrib/iRRAM/lib -liRRAM -lgmp -lmpfr
87         CFLAGS :=  $(CFLAGS) -I../contrib/iRRAM/include
88 endif
89
90 ifeq ($(REALTYPE),8)
91         OBJ := $(OBJ) 
92 endif 
93
94 ifeq ($(REALTYPE),9)
95         LIB := $(LIB) -lgmp
96 endif
97
98 LINKOBJ = $(OBJPATHS)
99
100
101 all : REALTYPE = 1
102 all : $(BIN)
103
104 single : REALTYPE = 0
105 single : $(BIN)
106
107 double : REALTYPE = 1
108 double : $(BIN)
109
110
111
112 CFLAGS := $(CFLAGS) $(QT_DEF)
113
114 demo : $(BIN) ../tools/stream_plot.py
115         mkdir -p ../data/
116         $(RM) ../data/performance.dat
117         ./ipdf | tee ../data/performance.dat | ../tools/stream_plot.py 2>/dev/null
118
119 movie : $(BIN) ../tools/stream_plot.py
120         mkdir -p ../data/
121         $(RM) ../data/performance.dat
122         $(RM) ../data/movie.ogv
123         ./ipdf | tee ../data/performance.dat | ../tools/stream_plot.py 2>/dev/null & recordmydesktop --fps 10 --on-the-fly-encoding -o ../data/movie.ogv
124
125 # The tests will compile with the default REALTYPE definition
126 # To change that you can run as `make DEFS="REALTYPE=X" tests/<target>` where X is your chosen type
127 # But remember to make clean first.
128 tests/% : tests/%.cpp ../obj/tests/%.o $(LINKOBJ)
129         $(CXX) $(CFLAGS) -o $@ $(LINKOBJ) ../obj/$@.o $(LIB) $(TESTRPATH)
130
131 -include $(DEPS)
132
133 runtests : tests/runtests.sh
134         cd tests; ./runtests.sh
135
136
137 $(BIN) : $(LINKOBJ) ../obj/$(MAIN)
138         echo $(LINKOBJ)
139         @mkdir -p $(dir $@)
140         $(CXX) $(CFLAGS) -o $(BIN) $(LINKOBJ) ../obj/$(MAIN) $(LIB) $(MAINRPATH)
141
142 -include $(DEPS)
143
144 moc_controlpanel.cpp : controlpanel.cpp controlpanel.h
145         moc-qt4 $(DEF) controlpanel.h -o moc_controlpanel.cpp
146
147 ../obj/%.o : %.cpp main.h
148         @mkdir -p $(dir $@)
149         $(CXX) $(CFLAGS) $(DEF) -c -MMD -o $@ $<
150
151 ../obj/%_asm.o : %_asm.S main.h
152         @mkdir -p $(dir $@)
153         $(CXX) -c -o $@ $<
154
155 -include $(DEPS)
156
157 clean_bin :
158         $(RM) $(BIN)
159
160 clean :
161         $(RM) $(BIN) $(DEPS) $(LINKOBJ) ../obj/$(MAIN) ../obj/quadtree.?
162         $(RM) tests/*~
163         $(RM) tests/*.test
164         $(RM) tests/*.out
165         $(RM) tests/*.err
166
167 clean_full: clean
168         $(RM) *.*~
169         $(RM) *~
170
171
172
173         

UCC git Repository :: git.ucc.asn.au