chiark / gitweb /
build more stuff
[moebius2.git] / Makefile
1
2
3 ALLDIMS=33 64 125 246 487 968
4 TARGETS= primer lumpy.cfm sgtatham.cfm ring.cfm \
5         minimise-33 minimise-64 minimise-125 minimise-246 \
6         $(addprefix interpolate-, $(ALLDIMS)) \
7         $(addprefix view-, $(ALLDIMS)) \
8         $(addprefix output-, $(ALLDIMS))
9 SGTATHAM=sgtatham
10
11 CWARNS= -Wall -Wwrite-strings -Wpointer-arith -Werror -Wshadow
12 CXXWARNS= $(CWARNS) -Wno-shadow -Wno-error
13
14 OPTIMISE=       -O3
15 CFLAGS_UNIPROC= -MMD $(OPTIMISE) -g $(CWARNS) $(DIMCFLAGS)
16 CXXFLAGS=       -MMD $(OPTIMISE) -g $(CXXWARNS)
17 CFLAGS=         $(CFLAGS_UNIPROC) $(NPROCCFLAGS)
18
19 LIBGSL= -lgsl -lgslcblas
20
21 o= >$@.new && mv -f $@.new $@
22
23 all:            $(TARGETS)
24
25 compute:        all
26                 $(MAKE) best-33.CFM
27                 $(MAKE) best-64.CFM
28 #               $(MAKE) best-968.CFM
29
30 minimise:       energy.o graph.o common.o mgraph.o minimise.o half.o
31                 $(CXX) $(CXXFLAGS) -o $@ $^ $(LIBGSL)
32
33 primer:         primer.o common.o
34                 $(CC) $(CFLAGS) -o $@ $^ $(LIBGSL)
35
36 nprocessors:    nprocessors.o common.o
37                 $(CC) $(CFLAGS_UNIPROC) -o $@ $^ $(LIBGSL)
38
39 common.o nprocessors.o: %.o: %.c
40                 $(CC) -c $(CPPFLAGS) $(CFLAGS_UNIPROC) $< -o $@
41
42 .nprocessors.make: ./nprocessors
43         set -e; n=`./nprocessors`; \
44         echo "NPROCCFLAGS := -DNPROCESSORS=$$n" $o
45
46 include .nprocessors.make
47
48
49 prime.data:     primer
50                 ./$^ $o
51
52 sgtatham.cfm:   sgtatham-regenerator prime.data $(SGTATHAM)/z.typescript
53                 ./$^ -T -o$@
54
55 lumpy.cfm: oldmoebius-converter prime.data ../moebius/ins-new ../moebius/a.out
56                 ./$^ -o$@
57
58 ring.cfm: oldmoebius-converter prime.data /dev/null ../moebius/a.out
59                 ./$^ -o$@
60
61 best-33.CFM:
62                 ./minimise-33 sgtatham.cfm -iwip-33.cfm -o$@
63
64 start-64.cfm:   best-33.CFM
65                 ./interpolate-64 -a4 $< -o$@
66
67 best-64.CFM:
68                 ./minimise-64 start-64.cfm -iwip-64.CFM -o$@
69
70 define interpolate_aa
71 best-$1.cfm:    interpolate-$1 $2
72                 ./$$< -aa $2 -o$$@
73 endef
74
75 $(eval $(call interpolate_aa,968, best-487.cfm))
76 $(eval $(call interpolate_aa,487, best-246.cfm))
77 $(eval $(call interpolate_aa,246, best-125.cfm))
78 $(eval $(call interpolate_aa,125, best-64.CFM))
79
80 view-%:         view+%.o mgraph+%.o common.o
81                 $(CC) $(CFLAGS) -o $@ $^ $(LIBGSL) -L/usr/X11R6/lib -lX11
82
83 output-%:       output+%.o mgraph+%.o common.o
84                 $(CC) $(CFLAGS) -o $@ $^ $(LIBGSL) -L/usr/X11R6/lib -lX11
85
86 interpolate-%:  interpolate+%.o mgraph+%.o common.o
87                 $(CC) $(CFLAGS) -o $@ $^ $(LIBGSL)
88
89 minimise-%:     energy+%.o graph+%.o mgraph+%.o minimise+%.o \
90                         half+%.o parallel.o common.o
91                 $(CXX) $(CXXFLAGS) -o $@ $^ $(LIBGSL) -lpthread
92
93 # this ridiculous repetition is due to make being too lame
94
95 view+%.o: view.c
96                 $(CC) -c $(CPPFLAGS) $(CFLAGS) -DDEFSZ=$* $< -o $@
97
98 output+%.o: output.c
99                 $(CC) -c $(CPPFLAGS) $(CFLAGS) -DDEFSZ=$* $< -o $@
100
101 mgraph+%.o: mgraph.c
102                 $(CC) -c $(CPPFLAGS) $(CFLAGS) -DDEFSZ=$* $< -o $@
103
104 minimise+%.o: minimise.c
105                 $(CC) -c $(CPPFLAGS) $(CFLAGS) -DDEFSZ=$* $< -o $@
106
107 graph+%.o: graph.c
108                 $(CC) -c $(CPPFLAGS) $(CFLAGS) -DDEFSZ=$* $< -o $@
109
110 energy+%.o: energy.c
111                 $(CC) -c $(CPPFLAGS) $(CFLAGS) -DDEFSZ=$* $< -o $@
112
113 half+%.o: half.c
114                 $(CC) -c $(CPPFLAGS) $(CFLAGS) -DDEFSZ=$* $< -o $@
115
116 interpolate+%.o: interpolate.c
117                 $(CC) -c $(CPPFLAGS) $(CFLAGS) -DDEFSZ=$* $< -o $@
118
119 .PRECIOUS: view+%.o output+%.o mgraph+%.o interpolate+%.o
120
121 clean:
122                 rm -f prime.data $(TARGETS)
123                 rm -f *.o *.new *.tmp *.rej *.orig core vgcore.* *~
124                 rm -f *.d .alternately_*
125
126 realclean:      clean
127                 rm -f *.cfm *.CFM
128
129 %.d:
130
131 -include *.d