Allow setting type of Real at compilation time
[ipdf/code.git] / src / Makefile
1 #Makefile
2 ARCH := $(shell uname -m)
3 CXX = g++ -std=gnu++0x -Wall -Werror -Wshadow -pedantic -g
4 MAIN = main.o
5 OBJ = log.o real.o document.o view.o screen.o vfpu.o
6 LIB_x86_64 = ../contrib/lib/libSDL2-2.0.so.0 -lGL
7 LIB_i386 = ../contrib/lib32/libSDL2-2.0.so.0 -lGL
8
9 MAINRPATH_x86_64 = -Wl,-rpath,'$$ORIGIN/../contrib/lib'
10 MAINRPATH_i386 = -Wl,-rpath,'$$ORIGIN/../contrib/lib32'
11 TESTRPATH_x86_64 = -Wl,-rpath,'$$ORIGIN/../../contrib/lib'
12 TESTRPATH_i386 = -Wl,-rpath,'$$ORIGIN/../../contrib/lib32'
13 OBJPATHS = $(OBJ:%=../obj/%)
14 DEPS := $(OBJPATHS:%.o=%.d)
15 CFLAGS_x86_64 := -I../contrib/include/SDL2 -I`pwd`
16 CFLAGS_i386 := -I../contrib/include32/SDL2 -I`pwd`
17
18
19 LIB := $(LIB_$(ARCH))
20 MAINRPATH := $(MAINRPATH_$(ARCH))
21 TESTRPATH := $(TESTRPATH_$(ARCH))
22 CFLAGS := $(CFLAGS_$(ARCH))
23
24 DEF = -DREAL=1
25
26 LINKOBJ = $(OBJPATHS)
27
28 RM = rm -f
29 BIN = ../bin/ipdf
30
31
32 all : $(BIN)
33
34 single : DEF = -DREAL=0
35 single : $(BIN)
36
37 double : DEF = -DREAL=1
38 double : $(BIN)
39
40 # The tests will compile with the default REAL definition
41 # To change that you can run as `make DEFS="REAL=X" tests/<target>` where X is your chosen type
42 # But remember to make clean first.
43 tests/% : tests/%.cpp ../obj/tests/%.o $(LINKOBJ)
44         $(CXX) -o [email protected] $(LINKOBJ) ../obj/[email protected] $(LIB) $(TESTRPATH)
45
46 runtests : tests/runtests.sh
47         cd tests; ./runtests.sh
48
49
50 $(BIN) : $(LINKOBJ) ../obj/$(MAIN)
51         @mkdir -p $(dir $@)
52         $(CXX) -o $(BIN) $(LINKOBJ) ../obj/$(MAIN) $(LIB) $(MAINRPATH)
53
54 ../obj/%.o : %.cpp
55         @mkdir -p $(dir $@)
56         $(CXX) $(CFLAGS) $(DEF) -c -MMD -o $@ $<
57
58 -include $(DEPS)
59
60 clean_bin :
61         $(RM) $(BIN)
62
63 clean :
64         $(RM) $(BIN) $(DEPS) $(LINKOBJ) ../obj/$(MAIN)
65         $(RM) tests/*~
66         $(RM) tests/*.test
67         $(RM) tests/*.out
68         $(RM) tests/*.err
69         
70
71 clean_full: clean
72         $(RM) *.*~
73         $(RM) *~
74
75
76
77         

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