About to break everything with a merge
[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 -lmpfr
20 LIB_i386 = ../contrib/lib32/libSDL2-2.0.so.0 -lGL -lgmp -lmpfr
21 LIB_i686 = $(LIB_i386)
22 LIB_win32 = -mwindows -lmingw32 -L../contrib/win32/lib/ -lSDL2main -lSDL2 -lgmp -static-libgcc -lopengl32 -static-libstdc++ -lmpfr
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 TRANSFORMATIONS=direct
52 MPFR_PRECISION=23
53 PATHREAL=0
54 DEF = -DREALTYPE=$(REALTYPE)
55
56
57
58 ## Only link with things we care about
59
60 ifeq ($(QUADTREE),enabled)
61         OBJ := $(OBJ) quadtree.o
62 else
63         DEF := $(DEF) -DQUADTREE_DISABLED
64 endif
65
66 ifeq ($(CONTROLPANEL),enabled)
67         LIB := $(LIB) $(QT_LIB)
68         DEF := $(DEF) $(QT_DEF)
69         CFLAGS := $(CFLAGS) $(QT_INCLUDE)
70         OBJ := $(OBJ) moc_controlpanel.o controlpanel.o
71 else
72         DEF := $(DEF) -DCONTROLPANEL_DISABLED
73 endif
74
75 ifeq ($REALTYPE),3)
76         OBJ := $(OBJ) vfpu.o
77 endif
78
79 ifeq ($(REALTYPE),5)
80         OBJ := $(OBJ) add_digits_asm.o sub_digits_asm.o mul_digits_asm.o div_digits_asm.o arbint.o
81         LIB := $(LIB) -lgmp
82 endif
83
84 ifeq ($(REALTYPE),6)
85         LIB := $(LIB) -lgmp -lmpfr
86         DEF := $(DEF) -DMPFR_PRECISION=$(MPFR_PRECISION)
87 endif
88
89 ifeq ($(TRANSFORMATIONS),cumulative)
90         DEF := $(DEF) -DTRANSFORM_OBJECTS_NOT_VIEW
91 endif
92
93 ifeq ($(TRANSFORMATIONS),path)
94         DEF := $(DEF) -DTRANSFORM_OBJECTS_NOT_VIEW -DTRANSFORM_BEZIERS_TO_PATH -DPATHREAL=$(PATHREAL)
95         ifeq ($(PATHREAL), mpfr)
96                 LIB:= $(LIB) -lmpfr
97         endif
98 endif
99
100 ifeq ($(REALTYPE),7)
101         LIB := $(LIB) -L../contrib/iRRAM/lib -liRRAM -lgmp -lmpfr
102         CFLAGS :=  $(CFLAGS) -I../contrib/iRRAM/include
103 endif
104
105 ifeq ($(REALTYPE),8)
106         OBJ := $(OBJ) 
107 endif 
108
109 ifeq ($(REALTYPE),9)
110         LIB := $(LIB) -lgmp
111 endif
112
113 LINKOBJ = $(OBJPATHS)
114
115
116 all : REALTYPE = 1
117 all : $(BIN)
118
119 single : REALTYPE = 0
120 single : $(BIN)
121
122 double : REALTYPE = 1
123 double : $(BIN)
124
125
126
127 CFLAGS := $(CFLAGS) $(QT_DEF)
128
129 demo : $(BIN) ../tools/stream_plot.py
130         mkdir -p ../data/
131         $(RM) ../data/performance.dat
132         ./ipdf | tee ../data/performance.dat | ../tools/stream_plot.py 2>/dev/null
133
134 movie : $(BIN) ../tools/stream_plot.py
135         mkdir -p ../data/
136         $(RM) ../data/performance.dat
137         $(RM) ../data/movie.ogv
138         ./ipdf | tee ../data/performance.dat | ../tools/stream_plot.py 2>/dev/null & recordmydesktop --fps 10 --on-the-fly-encoding -o ../data/movie.ogv
139
140 # The tests will compile with the default REALTYPE definition
141 # To change that you can run as `make DEFS="REALTYPE=X" tests/<target>` where X is your chosen type
142 # But remember to make clean first.
143 tests/% : tests/%.cpp ../obj/tests/%.o $(LINKOBJ)
144         $(CXX) $(CFLAGS) -o $@ $(LINKOBJ) ../obj/$@.o $(LIB) $(TESTRPATH)
145
146 -include $(DEPS)
147
148 runtests : tests/runtests.sh
149         cd tests; ./runtests.sh
150
151
152 $(BIN) : $(LINKOBJ) ../obj/$(MAIN)
153         echo $(LINKOBJ)
154         @mkdir -p $(dir $@)
155         $(CXX) $(CFLAGS) -o $(BIN) $(LINKOBJ) ../obj/$(MAIN) $(LIB) $(MAINRPATH)
156
157 -include $(DEPS)
158
159 moc_controlpanel.cpp : controlpanel.cpp controlpanel.h
160         moc-qt4 $(DEF) controlpanel.h -o moc_controlpanel.cpp
161
162 ../obj/%.o : %.cpp main.h
163         @mkdir -p $(dir $@)
164         $(CXX) $(CFLAGS) $(DEF) -c -MMD -o $@ $<
165
166 ../obj/%_asm.o : %_asm.S main.h
167         @mkdir -p $(dir $@)
168         $(CXX) -c -o $@ $<
169
170 -include $(DEPS)
171
172 clean_bin :
173         $(RM) $(BIN)
174
175 clean :
176         $(RM) $(BIN) $(DEPS) $(LINKOBJ) ../obj/$(MAIN) ../obj/quadtree.?
177         $(RM) tests/*~
178         $(RM) tests/*.test
179         $(RM) tests/*.out
180         $(RM) tests/*.err
181
182 clean_full: clean
183         $(RM) *.*~
184         $(RM) *~
185
186
187
188         

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