• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1
2# ==============================================================================
3#                          Unix Makefile for libmpdec
4# ==============================================================================
5
6ENABLE_STATIC = @ENABLE_STATIC@
7ENABLE_SHARED = @ENABLE_SHARED@
8ENABLE_MINGW = @ENABLE_MINGW@
9
10FPIC = @FPIC@
11LIBSTATIC = @LIBSTATIC@
12LIBNAME = @LIBNAME@
13LIBSONAME = @LIBSONAME@
14LIBSHARED = @LIBSHARED@
15LIBIMPORT = @LIBIMPORT@
16LIBSHARED_USE_AR = @LIBSHARED_USE_AR@
17LINK_STATIC = @LINK_STATIC@
18LINK_DYNAMIC = @LINK_DYNAMIC@
19
20EXPORTSYMS = @EXPORTSYMS@
21OBJECT_SUFFIX = @OBJECT_SUFFIX@
22COPY = @cp -f $1 $2
23
24CC = @CC@
25LD = @LD@
26AR = @AR@
27RANLIB = @RANLIB@
28MPD_PGEN = @MPD_PGEN@
29MPD_PUSE = @MPD_PUSE@
30MPD_PREC = @MPD_PREC@
31
32# gcc produces a random false positive warning for LTO bytecode in libmpdec.a
33# (see: bench target).  Users of libmpdec.a should not get spurious warnings.
34FILTER_FOR_STATIC = @FILTER_FOR_STATIC@
35
36CONFIGURE_LIBMPDEC_CFLAGS = @CONFIGURE_LIBMPDEC_CFLAGS@
37MPD_CFLAGS_COMMON = $(strip $(filter-out $(CFLAGS),$(CONFIGURE_LIBMPDEC_CFLAGS)) $(CFLAGS))
38MPD_CFLAGS_SHARED = $(strip $(filter-out $(FPIC),$(MPD_CFLAGS_COMMON)) $(FPIC))
39MPD_CFLAGS = $(strip $(filter-out $(FILTER_FOR_STATIC),$(MPD_CFLAGS_COMMON)))
40
41CONFIGURE_CFLAGS = @CONFIGURE_CFLAGS@
42MPD_BIN_CFLAGS_SHARED = $(strip $(filter-out $(CFLAGS),$(CONFIGURE_CFLAGS)) $(CFLAGS))
43MPD_BIN_CFLAGS = $(strip $(filter-out $(FILTER_FOR_STATIC),$(MPD_BIN_CFLAGS_SHARED)))
44
45CONFIGURE_LDFLAGS = @CONFIGURE_LDFLAGS@
46MPD_LDFLAGS = $(strip $(filter-out $(LDFLAGS),$(CONFIGURE_LDFLAGS)) $(LDFLAGS))
47
48LINK_LIBSTATIC = $(strip $(LINK_STATIC) $(LIBSTATIC) $(LINK_DYNAMIC))
49
50ifeq ($(MAKECMDGOALS), profile_gen)
51  MPD_CFLAGS_COMMON += $(MPD_PGEN)
52  MPD_BIN_CFLAGS_SHARED += $(MPD_PGEN)
53  MPD_LDFLAGS += $(MPD_PGEN)
54endif
55ifeq ($(MAKECMDGOALS), profile_use)
56  MPD_CFLAGS_COMMON += $(MPD_PUSE)
57  MPD_BIN_CFLAGS_SHARED += $(MPD_PUSE)
58  MPD_LDFLAGS += $(MPD_PUSE)
59endif
60
61MPD_TARGETS =
62ifeq ($(ENABLE_STATIC), yes)
63    MPD_TARGETS += $(LIBSTATIC)
64endif
65ifeq ($(ENABLE_SHARED), yes)
66    MPD_TARGETS += $(LIBSHARED)
67endif
68
69
70default: $(MPD_TARGETS)
71
72
73OBJS := basearith.o context.o constants.o convolute.o crt.o mpdecimal.o \
74        mpsignal.o difradix2.o fnt.o fourstep.o io.o mpalloc.o numbertheory.o \
75        sixstep.o transpose.o
76
77SHARED_OBJS := .objs/basearith.o .objs/context.o .objs/constants.o \
78               .objs/convolute.o .objs/crt.o .objs/mpdecimal.o .objs/mpsignal.o \
79               .objs/difradix2.o .objs/fnt.o .objs/fourstep.o .objs/io.o \
80               .objs/mpalloc.o .objs/numbertheory.o .objs/sixstep.o \
81               .objs/transpose.o
82
83
84ifeq ($(LIBSHARED_USE_AR), yes)
85AR_STATIC_OBJS := $(OBJS:.o=$(OBJECT_SUFFIX))
86AR_SHARED_OBJS := $(LIBSHARED:.o=$(OBJECT_SUFFIX))
87%$(OBJECT_SUFFIX): %.o
88	$(call COPY,$<,$@)
89
90$(LIBSHARED): Makefile $(SHARED_OBJS)
91	cp .objs/$(EXPORTSYMS) .objs/symbols.exp
92	$(LD) $(MPD_LDFLAGS) -o $(LIBSHARED) $(SHARED_OBJS) -lm
93
94$(LIBSTATIC): Makefile $(AR_STATIC_OBJS) $(AR_SHARED_OBJS)
95	$(AR) rc $(LIBSTATIC) $(AR_SHARED_OBJS) $(AR_STATIC_OBJS)
96	$(RANLIB) $(LIBSTATIC)
97else
98$(LIBSTATIC): Makefile $(OBJS)
99	$(AR) rc $(LIBSTATIC) $(OBJS)
100	$(RANLIB) $(LIBSTATIC)
101
102$(LIBSHARED): Makefile $(SHARED_OBJS)
103	$(LD) $(MPD_LDFLAGS) -o $(LIBSHARED) $(SHARED_OBJS) -lm
104ifeq ($(ENABLE_MINGW), no)
105	ln -sf $(LIBSHARED) $(LIBNAME)
106	ln -sf $(LIBSHARED) $(LIBSONAME)
107endif
108endif
109
110
111basearith.o:\
112Makefile basearith.c mpdecimal.h basearith.h typearith.h constants.h
113	$(CC) $(MPD_CFLAGS) -c basearith.c
114
115.objs/basearith.o:\
116Makefile basearith.c mpdecimal.h basearith.h typearith.h constants.h
117	$(CC) $(MPD_CFLAGS_SHARED) -c basearith.c -o .objs/basearith.o
118
119constants.o:\
120Makefile constants.c mpdecimal.h basearith.h typearith.h constants.h
121	$(CC) $(MPD_CFLAGS) -c constants.c
122
123.objs/constants.o:\
124Makefile constants.c mpdecimal.h basearith.h typearith.h constants.h
125	$(CC) $(MPD_CFLAGS_SHARED) -c constants.c -o .objs/constants.o
126
127context.o:\
128Makefile context.c mpdecimal.h
129	$(CC) $(MPD_CFLAGS) -c context.c
130
131.objs/context.o:\
132Makefile context.c mpdecimal.h
133	$(CC) $(MPD_CFLAGS_SHARED) -c context.c -o .objs/context.o
134
135convolute.o:\
136Makefile convolute.c mpdecimal.h bits.h constants.h convolute.h fnt.h \
137fourstep.h numbertheory.h sixstep.h umodarith.h typearith.h
138	$(CC) $(MPD_CFLAGS) -c convolute.c
139
140.objs/convolute.o:\
141Makefile convolute.c mpdecimal.h bits.h constants.h convolute.h fnt.h \
142fourstep.h numbertheory.h sixstep.h umodarith.h typearith.h
143	$(CC) $(MPD_CFLAGS_SHARED) -c convolute.c -o .objs/convolute.o
144
145crt.o:\
146Makefile crt.c mpdecimal.h constants.h crt.h numbertheory.h umodarith.h \
147typearith.h
148	$(CC) $(MPD_CFLAGS) -c crt.c
149
150.objs/crt.o:\
151Makefile crt.c mpdecimal.h constants.h crt.h numbertheory.h umodarith.h \
152typearith.h
153	$(CC) $(MPD_CFLAGS_SHARED) -c crt.c -o .objs/crt.o
154
155difradix2.o:\
156Makefile difradix2.c mpdecimal.h bits.h constants.h difradix2.h \
157numbertheory.h umodarith.h typearith.h
158	$(CC) $(MPD_CFLAGS) -c difradix2.c
159
160.objs/difradix2.o:\
161Makefile difradix2.c mpdecimal.h bits.h constants.h difradix2.h \
162numbertheory.h umodarith.h typearith.h
163	$(CC) $(MPD_CFLAGS_SHARED) -c difradix2.c -o .objs/difradix2.o
164
165fnt.o:\
166Makefile fnt.c mpdecimal.h bits.h difradix2.h numbertheory.h constants.h \
167fnt.h
168	$(CC) $(MPD_CFLAGS) -c fnt.c
169
170.objs/fnt.o:\
171Makefile fnt.c mpdecimal.h bits.h difradix2.h numbertheory.h constants.h \
172fnt.h
173	$(CC) $(MPD_CFLAGS_SHARED) -c fnt.c -o .objs/fnt.o
174
175fourstep.o:\
176Makefile fourstep.c mpdecimal.h constants.h fourstep.h numbertheory.h \
177sixstep.h umodarith.h typearith.h
178	$(CC) $(MPD_CFLAGS) -c fourstep.c
179
180.objs/fourstep.o:\
181Makefile fourstep.c mpdecimal.h constants.h fourstep.h numbertheory.h \
182sixstep.h umodarith.h typearith.h
183	$(CC) $(MPD_CFLAGS_SHARED) -c fourstep.c -o .objs/fourstep.o
184
185io.o:\
186Makefile io.c mpdecimal.h typearith.h io.h
187	$(CC) $(MPD_CFLAGS) -c io.c
188
189.objs/io.o:\
190Makefile io.c mpdecimal.h typearith.h io.h
191	$(CC) $(MPD_CFLAGS_SHARED) -c io.c -o .objs/io.o
192
193mpalloc.o:\
194Makefile mpalloc.c mpdecimal.h mpalloc.h typearith.h
195	$(CC) $(MPD_CFLAGS) -c mpalloc.c
196
197.objs/mpalloc.o:\
198Makefile mpalloc.c mpdecimal.h mpalloc.h typearith.h
199	$(CC) $(MPD_CFLAGS_SHARED) -c mpalloc.c -o .objs/mpalloc.o
200
201mpdecimal.o:\
202Makefile mpdecimal.c mpdecimal.h basearith.h typearith.h bits.h \
203constants.h convolute.h crt.h mpalloc.h
204	$(CC) $(MPD_CFLAGS) -c mpdecimal.c
205
206.objs/mpdecimal.o:\
207Makefile mpdecimal.c mpdecimal.h basearith.h typearith.h bits.h \
208constants.h convolute.h crt.h mpalloc.h
209	$(CC) $(MPD_CFLAGS_SHARED) -c mpdecimal.c -o .objs/mpdecimal.o
210
211mpsignal.o:\
212Makefile mpsignal.c mpdecimal.h
213	$(CC) $(MPD_CFLAGS) -c mpsignal.c
214
215.objs/mpsignal.o:\
216Makefile mpsignal.c mpdecimal.h
217	$(CC) $(MPD_CFLAGS_SHARED) -c mpsignal.c -o .objs/mpsignal.o
218
219numbertheory.o:\
220Makefile numbertheory.c mpdecimal.h bits.h numbertheory.h \
221constants.h umodarith.h typearith.h
222	$(CC) $(MPD_CFLAGS) -c numbertheory.c
223
224.objs/numbertheory.o:\
225Makefile numbertheory.c mpdecimal.h bits.h numbertheory.h \
226constants.h umodarith.h typearith.h
227	$(CC) $(MPD_CFLAGS_SHARED) -c numbertheory.c -o .objs/numbertheory.o
228
229sixstep.o:\
230Makefile sixstep.c mpdecimal.h bits.h constants.h difradix2.h \
231numbertheory.h sixstep.h transpose.h umodarith.h typearith.h
232	$(CC) $(MPD_CFLAGS) -c sixstep.c
233
234.objs/sixstep.o:\
235Makefile sixstep.c mpdecimal.h bits.h constants.h difradix2.h \
236numbertheory.h sixstep.h transpose.h umodarith.h typearith.h
237	$(CC) $(MPD_CFLAGS_SHARED) -c sixstep.c -o .objs/sixstep.o
238
239transpose.o:\
240Makefile transpose.c mpdecimal.h bits.h constants.h transpose.h \
241typearith.h
242	$(CC) $(MPD_CFLAGS) -c transpose.c
243
244.objs/transpose.o:\
245Makefile transpose.c mpdecimal.h bits.h constants.h transpose.h \
246typearith.h
247	$(CC) $(MPD_CFLAGS_SHARED) -c transpose.c -o .objs/transpose.o
248
249
250bench: bench.c mpdecimal.h $(LIBSTATIC)
251	$(CC) $(MPD_BIN_CFLAGS) -o bench bench.c $(LINK_LIBSTATIC) -lm
252
253bench_full: bench_full.c mpdecimal.h $(LIBSTATIC)
254	$(CC) $(MPD_BIN_CFLAGS) -o bench_full bench_full.c $(LINK_LIBSTATIC) -lm
255
256bench_shared: bench.c mpdecimal.h $(LIBSHARED)
257	$(CC) -L. $(MPD_BIN_CFLAGS_SHARED) -o bench_shared bench.c -lmpdec -lm
258
259bench_full_shared: bench_full.c mpdecimal.h $(LIBSHARED)
260	$(CC) -L. $(MPD_BIN_CFLAGS_SHARED) -o bench_full_shared bench_full.c -lmpdec -lm
261
262
263pow: Makefile examples/pow.c $(LIBSTATIC)
264	$(CC) -I. $(MPD_BIN_CFLAGS) -o pow examples/pow.c $(LINK_LIBSTATIC) -lm
265
266sqrt: Makefile examples/sqrt.c $(LIBSTATIC)
267	$(CC) -I. $(MPD_BIN_CFLAGS) -o sqrt examples/sqrt.c $(LINK_LIBSTATIC) -lm
268
269examples: pow sqrt
270
271
272GEN_TARGETS =
273ifeq ($(ENABLE_STATIC), yes)
274GEN_TARGETS += bench_full
275endif
276ifeq ($(ENABLE_SHARED), yes)
277GEN_TARGETS += bench_shared
278endif
279
280profile_gen: $(GEN_TARGETS)
281	./.profile/train.sh $(MPD_PREC)
282
283profile_clean:
284	rm -f *.o *.so *.gch
285	rm -f bench bench_shared bench_full bench_full_shared pow sqrt
286	rm -f $(LIBSTATIC) $(LIBNAME) $(LIBSONAME) $(LIBSHARED) $(LIBIMPORT)
287	cd .objs && rm -f *.o *.so *.gch symbols.exp
288
289profile_use: default
290
291profile:
292	$(MAKE) clean
293	$(MAKE) profile_gen
294	$(MAKE) profile_clean
295	$(MAKE) profile_use
296
297
298check: default
299	cd ../tests && $(MAKE) && ./runshort.sh
300
301check_local: default
302	cd ../tests && $(MAKE) && ./runshort.sh --local
303
304check_alloc: default
305	cd ../tests && $(MAKE) && ./runshort_alloc.sh
306
307
308clean:
309	rm -f *.o *.so *.gch *.gcda *.gcno *.gcov *.dyn *.dpi *.lock
310	rm -f bench bench_shared bench_full bench_full_shared pow sqrt
311	rm -f $(LIBSTATIC) $(LIBNAME) $(LIBSONAME) $(LIBSHARED) $(LIBIMPORT)
312	cd .objs && rm -f *.o *.so *.gch *.gcda *.gcno *.gcov *.dyn *.dpi *.lock symbols.exp
313
314distclean: clean
315	rm -f config.h config.log config.status Makefile mpdecimal.h .pc/libmpdec.pc
316