-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile.in
801 lines (688 loc) · 31.4 KB
/
Makefile.in
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
#
# Copyright (C) 2023 Albin Ahlbäck
#
# This file is part of FLINT.
#
# FLINT is free software: you can redistribute it and/or modify it under
# the terms of the GNU Lesser General Public License (LGPL) as published
# by the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version. See <http://www.gnu.org/licenses/>.
#
FLINT_DIR:=.
SRC_DIR:=src
BUILD_DIR:=build
ABS_FLINT_DIR:='$(patsubst %/,%, $(dir $(abspath $(lastword $(MAKEFILE_LIST)))))'
ABS_SRC_DIR:=$(ABS_FLINT_DIR)/$(SRC_DIR)
ABS_BUILD_DIR:=$(ABS_FLINT_DIR)/$(SRC_DIR)
FLINT_MAJOR:=@FLINT_MAJOR@
FLINT_MINOR:=@FLINT_MINOR@
FLINT_PATCH:=@FLINT_PATCH@
FLINT_MAJOR_SO:=@FLINT_MAJOR_SO@
FLINT_MINOR_SO:=@FLINT_MINOR_SO@
FLINT_PATCH_SO:=@FLINT_PATCH_SO@
FLINT_LIB:=@FLINT_LIB@
FLINT_LIB_MAJOR:=@FLINT_LIB_MAJOR@
FLINT_LIB_FULL:=@FLINT_LIB_FULL@
FLINT_IMPLIB:=@FLINT_IMPLIB@
FLINT_LIB_STATIC:=@FLINT_LIB_STATIC@
FLINT_DLLLIB:=@FLINT_DLLLIB@
FLINT_DYLIB:=@FLINT_DYLIB@
FLINT_SOLIB:=@FLINT_SOLIB@
prefix:=@prefix@
exec_prefix:=@exec_prefix@
INCLUDEDIR:=$(DESTDIR)@includedir@
LIBDIR:=$(DESTDIR)@libdir@
BINDIR:=$(DESTDIR)@bindir@
PKGCONFIGDIR:=$(LIBDIR)/pkgconfig
HOST_OS:=@host_os@
EXEEXT:=@EXEEXT@
AR:=@AR@
CC:=@CC@
CXX:=@CC@
DLLTOOL:=@DLLTOOL@
LD:=@LD@
LDCONFIG:=@LDCONFIG@
LN_S:=@LN_S@
MKDIR_P:=@MKDIR_P@
STRIP:=@STRIP@
RM_F:=rm -f
RM_RF:=rm -rf
CP:=cp
CP_A:=cp -a
STATIC:=@STATIC@
SHARED:=@SHARED@
COVERAGE:=@COVERAGE@
WANT_NTL:=@WANT_NTL@
WANT_DEPS:=@WANT_DEPS@
WANT_CXX:=@WANT_CXX@
GMP_LIB_PATH:=@GMP_LIB_PATH@
MPFR_LIB_PATH:=@MPFR_LIB_PATH@
BLAS_LIB_PATH:=@BLAS_LIB_PATH@
GC_LIB_PATH:=@GC_LIB_PATH@
NTL_LIB_PATH:=@NTL_LIB_PATH@
CFLAGS:=@CFLAGS@
TESTCFLAGS:=@TESTCFLAGS@
CPPFLAGS:=@CPPFLAGS@
CPPFLAGS2:=-L$(FLINT_DIR) $(CPPFLAGS)
LIB_CPPFLAGS:=@LIB_CPPFLAGS@
CXXFLAGS:=@CXXFLAGS@
LIBS:=@LIBS@
LIBS2:=$(LIBS) -lflint
PIC_FLAG:=@PIC_FLAG@
LDFLAGS:=@LDFLAGS@
EXTRA_SHARED_FLAGS:=@EXTRA_SHARED_FLAGS@ $(foreach path, $(GMP_LIB_PATH) $(MPFR_LIB_PATH) $(BLAS_LIB_PATH) $(GC_LIB_PATH) $(NTL_LIB_PATH), @WL@-rpath,$(path))
EXE_LDFLAGS:=$(LDFLAGS) $(foreach path, $(ABS_FLINT_DIR) $(GMP_LIB_PATH) $(MPFR_LIB_PATH) $(BLAS_LIB_PATH) $(GC_LIB_PATH) $(NTL_LIB_PATH), @WL@-rpath,$(path))
################################################################################
################################################################################
# files and directories
################################################################################
################################################################################
################################################################################
# configuration files
################################################################################
CFG_FILES := \
$(FLINT_DIR)/config.log $(SRC_DIR)/flint-config.h \
$(SRC_DIR)/fft_tuning.h $(FLINT_DIR)/flint.pc \
$(FLINT_DIR)/Makefile $(SRC_DIR)/fmpz/fmpz.c
################################################################################
# directories
################################################################################
HEADLESS_DIRS := generic_files
HEADER_DIRS := \
thread_pool thread_support \
\
ulong_extras \
long_extras \
perm \
double_extras d_vec d_mat \
mpn_extras \
mpf_vec mpf_mat \
mpfr_vec mpfr_mat \
nmod nmod_vec nmod_mat nmod_poly \
fmpz fmpz_vec fmpz_mat fmpz_poly \
fmpz_mod fmpz_mod_vec fmpz_mod_mat fmpz_mod_poly \
fmpq fmpq_vec fmpq_mat fmpq_poly \
\
fq fq_vec fq_mat fq_poly \
fq_nmod fq_nmod_vec fq_nmod_mat fq_nmod_poly \
fq_zech fq_zech_mat fq_zech_poly \
fq_default fq_default_mat fq_default_poly \
fq_embed \
fq_nmod_embed \
fq_zech_embed \
padic padic_mat padic_poly \
qadic \
\
nmod_poly_factor fmpz_factor \
fmpz_poly_factor fmpz_mod_poly_factor \
fq_poly_factor fq_nmod_poly_factor \
fq_zech_poly_factor fq_default_poly_factor \
\
nmod_poly_mat fmpz_poly_mat \
\
mpoly nmod_mpoly fmpz_mpoly fmpz_mod_mpoly \
fmpq_mpoly fq_nmod_mpoly fq_zech_mpoly \
\
nmod_mpoly_factor fmpz_mpoly_factor \
fmpz_mod_mpoly_factor fmpq_mpoly_factor \
fq_nmod_mpoly_factor fq_zech_mpoly_factor \
\
fft @FFT_SMALL@ fmpz_poly_q fmpz_lll \
n_poly arith qsieve aprcl \
\
nf nf_elem qfb \
\
double_interval dlog \
fmpz_extras fmpzi \
bool_mat partitions \
mag \
arf acf arb acb \
arb_mat arb_poly arb_calc arb_hypgeom \
acb_mat acb_poly acb_calc acb_hypgeom \
arb_fmpz_poly arb_fpwrap \
acb_dft acb_elliptic acb_modular acb_dirichlet \
dirichlet bernoulli hypgeom \
\
gr gr_generic gr_vec gr_mat \
gr_poly gr_mpoly gr_special \
\
calcium \
fmpz_mpoly_q \
fexpr fexpr_builtin \
qqbar \
ca ca_ext ca_field ca_vec \
ca_poly ca_mat
DIRS := $(HEADLESS_DIRS) $(HEADER_DIRS)
TEMPLATE_DIRS := \
fq_vec_templates fq_mat_templates \
fq_poly_templates fq_poly_factor_templates \
fq_embed_templates fq_templates
BUILD_DIRS := \
$(BUILD_DIR) \
$(patsubst %, $(BUILD_DIR)/%, $(DIRS)) \
$(patsubst %, $(BUILD_DIR)/%/profile, $(DIRS)) \
$(patsubst %, $(BUILD_DIR)/%/test, $(DIRS)) \
$(patsubst %, $(BUILD_DIR)/%/tune, $(DIRS)) \
$(BUILD_DIR)/examples $(BUILD_DIR)/profile \
$(BUILD_DIR)/test $(BUILD_DIR)/tune
ifneq ($(WANT_NTL), 0)
BUILD_DIRS += \
$(BUILD_DIR)/interfaces $(BUILD_DIR)/interfaces/test
endif
ifneq ($(COVERAGE), 0)
BUILD_DIRS += \
$(BUILD_DIR)/coverage
endif
INSTALL_DIRS := \
$(LIBDIR) $(INCLUDEDIR)/flint \
$(PKGCONFIGDIR)
ifneq ($(WANT_CXX),0)
INSTALL_DIRS += $(INCLUDEDIR)/flint/flintxx
endif
ifneq ($(FLINT_DLLLIB),0)
INSTALL_DIRS += $(BINDIR)
endif
################################################################################
# headers
################################################################################
SINGLE_HEADERS := \
flint.h longlong.h exception.h gmpcompat.h \
hashmap.h profiler.h templates.h flint-config.h \
fft_tuning.h \
crt_helpers.h machine_vectors.h \
\
fq_zech_vec.h \
\
limb_types.h mpoly_types.h \
fmpz_types.h fmpq_types.h \
nmod_types.h fmpz_mod_types.h \
fq_types.h fq_nmod_types.h \
fq_zech_types.h \
arf_types.h acf_types.h \
arb_types.h acb_types.h
ifneq ($(WANT_NTL), 0)
SINGLE_HEADERS += NTL-interface.h
endif
HEADERS := $(patsubst %,$(SRC_DIR)/%, \
$(patsubst %,%,$(SINGLE_HEADERS)) \
$(patsubst %,%.h,$(HEADER_DIRS)) \
$(patsubst %,%.h,$(TEMPLATE_DIRS)) \
)
################################################################################
# sources
################################################################################
define xxx_SOURCES
$(1)_SOURCES := $(wildcard $(SRC_DIR)/$(1)/*.c)
endef
$(foreach dir, $(DIRS), $(eval $(call xxx_SOURCES,$(dir))))
SOURCES := $(foreach dir,$(DIRS),$($(dir)_SOURCES))
# NOTE: We do not add CPP files to C files in SOURCES in order to not screw up
# the `patsubst' in the object files.
ifneq ($(WANT_NTL), 0)
interfaces_SOURCES := $(SRC_DIR)/interfaces/NTL-interface.cpp
endif
define xxx_PROF_SOURCES
$(1)_PROF_SOURCES := $(wildcard $(SRC_DIR)/$(1)/profile/*.c)
endef
_PROF_SOURCES := $(wildcard $(SRC_DIR)/profile/*.c)
$(foreach dir, $(DIRS), $(eval $(call xxx_PROF_SOURCES,$(dir))))
PROF_SOURCES := $(foreach dir,$(DIRS),$($(dir)_PROF_SOURCES)) $(_PROF_SOURCES)
# FIXME: De-hardcode fq_zech_vec from this.
fq_zech_vec_TEST_SOURCES := $(wildcard $(SRC_DIR)/fq_zech_vec/test/*.c)
define xxx_TEST_SOURCES
$(1)_TEST_SOURCES := $(wildcard $(SRC_DIR)/$(1)/test/*.c)
endef
_TEST_SOURCES := $(wildcard $(SRC_DIR)/test/*.c)
$(foreach dir, $(DIRS), $(eval $(call xxx_TEST_SOURCES,$(dir))))
TEST_SOURCES := $(foreach dir,$(DIRS),$($(dir)_TEST_SOURCES)) $(_TEST_SOURCES) $(fq_zech_vec_TEST_SOURCES)
ifneq ($(WANT_NTL), 0)
interfaces_TEST_SOURCES := $(SRC_DIR)/interfaces/test/t-NTL-interface.cpp
endif
define xxx_TUNE_SOURCES
$(1)_TUNE_SOURCES := $(wildcard $(SRC_DIR)/$(1)/tune/*.c)
endef
_TUNE_SOURCES := $(wildcard $(SRC_DIR)/tune/*.c)
$(foreach dir, $(DIRS), $(eval $(call xxx_TUNE_SOURCES,$(dir))))
TUNE_SOURCES := $(foreach dir,$(DIRS),$($(dir)_TUNE_SOURCES)) $(_TUNE_SOURCES)
EXMP_SOURCES := $(wildcard $(FLINT_DIR)/examples/*.c)
################################################################################
# objects
################################################################################
ifneq ($(STATIC), 0)
define xxx_OBJS
$(1)_OBJS := $(patsubst $(SRC_DIR)/%.c,$(BUILD_DIR)/%.o,$($(1)_SOURCES))
endef
$(foreach dir, $(DIRS), $(eval $(call xxx_OBJS,$(dir))))
OBJS := $(foreach dir, $(DIRS), $($(dir)_OBJS))
ifneq ($(WANT_NTL), 0)
OBJS += $(BUILD_DIR)/interfaces/NTL-interface.o
endif
endif
################################################################################
# library objects
################################################################################
ifneq ($(SHARED), 0)
define xxx_LOBJS
$(1)_LOBJS := $(patsubst $(SRC_DIR)/%.c,$(BUILD_DIR)/%.lo,$($(1)_SOURCES))
endef
$(foreach dir, $(DIRS), $(eval $(call xxx_LOBJS,$(dir))))
LOBJS := $(foreach dir, $(DIRS), $($(dir)_LOBJS))
ifneq ($(WANT_NTL), 0)
LOBJS += $(BUILD_DIR)/interfaces/NTL-interface.lo
endif
endif
################################################################################
# executables
################################################################################
define xxx_PROFS
$(1)_PROFS := $(patsubst $(SRC_DIR)/%.c,$(BUILD_DIR)/%$(EXEEXT),$($(1)_PROF_SOURCES))
endef
_PROFS := $(patsubst $(SRC_DIR)/%.c,$(BUILD_DIR)/%$(EXEEXT),$(_PROF_SOURCES))
$(foreach dir, $(DIRS), $(eval $(call xxx_PROFS,$(dir))))
PROFS := $(foreach dir,$(DIRS),$($(dir)_PROFS)) $(_PROFS)
define xxx_TESTS
$(1)_TESTS := $(patsubst $(SRC_DIR)/%.c,$(BUILD_DIR)/%$(EXEEXT),$($(1)_TEST_SOURCES))
endef
_TESTS := $(patsubst $(SRC_DIR)/%.c,$(BUILD_DIR)/%$(EXEEXT),$(_TEST_SOURCES))
ifneq ($(WANT_NTL), 0)
interfaces_TESTS := $(BUILD_DIR)/interfaces/test/t-NTL-interface$(EXEEXT)
endif
$(foreach dir, $(DIRS), $(eval $(call xxx_TESTS,$(dir))))
TESTS := $(foreach dir,$(DIRS),$($(dir)_TESTS)) $(_TESTS) $(interfaces_TESTS)
define xxx_TUNES
$(1)_TUNES := $(patsubst $(SRC_DIR)/%.c,$(BUILD_DIR)/%$(EXEEXT),$($(1)_TUNE_SOURCES))
endef
_TUNES := $(patsubst $(SRC_DIR)/%.c,$(BUILD_DIR)/%$(EXEEXT),$(_TUNE_SOURCES))
$(foreach dir, $(DIRS), $(eval $(call xxx_TUNES,$(dir))))
TUNES := $(foreach dir,$(DIRS),$($(dir)_TUNES)) $(_TUNES)
EXMPS := $(patsubst $(FLINT_DIR)/%.c,$(BUILD_DIR)/%$(EXEEXT),$(EXMP_SOURCES))
################################################################################
################################################################################
# recipes
################################################################################
################################################################################
################################################################################
# main recipe
################################################################################
all: library
################################################################################
# library
################################################################################
ifneq ($(SHARED), 0)
library: shared
endif
ifneq ($(STATIC), 0)
library: static
endif
ifneq ($(SHARED), 0)
shared: $(FLINT_DIR)/$(FLINT_LIB_FULL)
# The following is to avoid reaching the maximum length of command line
# arguments, mainly present on MinGW.
define xxx_merged_lobj_rule
$(BUILD_DIR)/$(1)_merged.lo: $($(1)_LOBJS) | $(BUILD_DIR)
@$(LD) -r $($(1)_LOBJS) -o $(BUILD_DIR)/$(1)_merged.lo
endef
$(foreach dir, $(DIRS), $(eval $(call xxx_merged_lobj_rule,$(dir))))
MERGED_LOBJS:=$(foreach dir, $(DIRS),$(BUILD_DIR)/$(dir)_merged.lo)
$(FLINT_DIR)/$(FLINT_LIB_FULL): $(MERGED_LOBJS)
$(CC) $(CFLAGS) -shared $(EXTRA_SHARED_FLAGS) $(MERGED_LOBJS) -o $(FLINT_LIB_FULL) $(LDFLAGS) $(LIBS)
ifneq ($(FLINT_SOLIB), 0)
$(LDCONFIG) -n .
endif
$(RM_F) $(FLINT_LIB)
$(RM_F) $(FLINT_LIB_MAJOR)
$(LN_S) $(FLINT_LIB_FULL) $(FLINT_LIB)
$(LN_S) $(FLINT_LIB_FULL) $(FLINT_LIB_MAJOR)
endif
ifneq ($(STATIC), 0)
static: $(FLINT_DIR)/$(FLINT_LIB_STATIC)
# The following is to avoid reaching the maximum length of command line
# arguments, mainly present on MinGW.
define xxx_merged_obj_rule
$(BUILD_DIR)/$(1)_merged.o: $($(1)_OBJS) | $(BUILD_DIR)
@$(LD) -r $($(1)_OBJS) -o $(BUILD_DIR)/$(1)_merged.o
endef
$(foreach dir, $(DIRS), $(eval $(call xxx_merged_obj_rule,$(dir))))
MERGED_OBJS:=$(foreach dir, $(DIRS),$(BUILD_DIR)/$(dir)_merged.o)
$(FLINT_DIR)/$(FLINT_LIB_STATIC): $(MERGED_OBJS)
$(AR) rcs $(FLINT_DIR)/$(FLINT_LIB_STATIC) $(MERGED_OBJS)
endif
################################################################################
# directories
################################################################################
$(BUILD_DIRS) $(INSTALL_DIRS):
$(MKDIR_P) $@
################################################################################
# inclusions
################################################################################
ifneq ($(WANT_DEPS), 0)
ifeq ($(words $(MAKECMDGOALS)), 0)
-include $(BUILD_DIR)/*/*.o.d
-include $(BUILD_DIR)/*/*.lo.d
else ifeq ($(words $(MAKECMDGOALS)), 1)
ifeq ($(MAKECMDGOALS), clean)
# Include nothing
else ifeq ($(MAKECMDGOALS), dist)
# Include nothing
else ifeq ($(MAKECMDGOALS), distclean)
# Include nothing
else ifeq ($(MAKECMDGOALS), uninstall)
# Include nothing
else ifeq ($(findstring print-,$(MAKECMDGOALS)), print-)
# Include nothing
else ifeq ($(MAKECMDGOALS), static)
-include $(BUILD_DIR)/*/*.o.d
else ifeq ($(MAKECMDGOALS), shared)
-include $(BUILD_DIR)/*/*.lo.d
else ifeq ($(MAKECMDGOALS), library)
-include $(BUILD_DIR)/*/*.o.d
-include $(BUILD_DIR)/*/*.lo.d
else ifeq ($(MAKECMDGOALS), install)
-include $(BUILD_DIR)/*/*.o.d
-include $(BUILD_DIR)/*/*.lo.d
else ifeq ($(MAKECMDGOALS), examples)
-include $(BUILD_DIR)/*/*.o.d
-include $(BUILD_DIR)/*/*.lo.d
-include $(BUILD_DIR)/examples/*.d
else ifeq ($(MAKECMDGOALS), profile)
ifdef MOD
$(warning Dependency tracking only set to cover the profile executables of $(MOD).)
-include $(foreach dir, $(MOD), $(BUILD_DIR)/$(dir)/profile/*.d)
else
-include $(BUILD_DIR)/*/*.o.d
-include $(BUILD_DIR)/*/*.lo.d
-include $(BUILD_DIR)/profile/*.d
-include $(BUILD_DIR)/*/profile/*.d
endif
else ifeq ($(MAKECMDGOALS), tests)
-include $(BUILD_DIR)/*/*.o.d
-include $(BUILD_DIR)/*/*.lo.d
-include $(BUILD_DIR)/test/*.d
-include $(BUILD_DIR)/*/test/*.d
else ifeq ($(MAKECMDGOALS), check)
ifdef MOD
$(warning Dependency tracking only set to cover the test executables of $(MOD).)
-include $(foreach dir, $(MOD), $(BUILD_DIR)/$(dir)/test/*.d)
else
-include $(BUILD_DIR)/*/*.o.d
-include $(BUILD_DIR)/*/*.lo.d
-include $(BUILD_DIR)/test/*.d
-include $(BUILD_DIR)/*/test/*.d
endif
else ifeq ($(MAKECMDGOALS), tune)
-include $(BUILD_DIR)/*/*.o.d
-include $(BUILD_DIR)/*/*.lo.d
-include $(BUILD_DIR)/tune/*.d
-include $(BUILD_DIR)/*/tune/*.d
else ifeq ($(MAKECMDGOALS), valgrind)
ifdef MOD
$(warning Dependency tracking only set to cover the test executables of $(MOD).)
-include $(foreach dir, $(MOD), $(BUILD_DIR)/$(dir)/test/*.d)
else
-include $(BUILD_DIR)/*/*.o.d
-include $(BUILD_DIR)/*/*.lo.d
-include $(BUILD_DIR)/test/*.d
-include $(BUILD_DIR)/*/test/*.d
endif
else
# Cannot recognize the command, so we simply include everything
-include $(BUILD_DIR)/*/*.o.d
-include $(BUILD_DIR)/*/*.lo.d
-include $(BUILD_DIR)/test/*.d
-include $(BUILD_DIR)/*/test/*.d
-include $(BUILD_DIR)/profile/*.d
-include $(BUILD_DIR)/*/profile/*.d
-include $(BUILD_DIR)/examples/*.d
endif
else
# Multiple goals. Not currently implemented, so simply include everything.
-include $(BUILD_DIR)/*/*.o.d
-include $(BUILD_DIR)/*/*.lo.d
-include $(BUILD_DIR)/test/*.d
-include $(BUILD_DIR)/*/test/*.d
-include $(BUILD_DIR)/profile/*.d
-include $(BUILD_DIR)/*/profile/*.d
-include $(BUILD_DIR)/examples/*.d
endif
endif
################################################################################
# objects
################################################################################
ifneq ($(STATIC), 0)
define xxx_OBJS_rule
$(BUILD_DIR)/$(1)/%.o: $(SRC_DIR)/$(1)/%.c | $(BUILD_DIR)/$(1)
@echo " CC $$(@:$(BUILD_DIR)/%=%)"
@$(CC) $(CFLAGS) $(CPPFLAGS) $(LIB_CPPFLAGS) -c $$< -o $$@ -MMD -MF $$(@:%=%.d)
endef
$(foreach dir, $(DIRS), $(eval $(call xxx_OBJS_rule,$(dir))))
ifneq ($(WANT_NTL), 0)
$(BUILD_DIR)/interfaces/NTL-interface.o: $(SRC_DIR)/interfaces/test/t-NTL-interface.cpp | $(BUILD_DIR)/interfaces
@echo " CXX $(@:$(BUILD_DIR)/%=%)"
@$(CXX) $(CXXFLAGS) $(CPPFLAGS) $(LIB_CPPFLAGS) -c $< -o $@ -MMD -MF $(@:%=%.d)
endif
endif
################################################################################
# library objects
################################################################################
ifneq ($(SHARED), 0)
define xxx_LOBJS_rule
$(BUILD_DIR)/$(1)/%.lo: $(SRC_DIR)/$(1)/%.c | $(BUILD_DIR)/$(1)
@echo " CC $$(@:$(BUILD_DIR)/%=%)"
@$(CC) $(PIC_FLAG) $(CFLAGS) $(CPPFLAGS) $(LIB_CPPFLAGS) -c $$< -o $$@ -MMD -MF $$(@:%=%.d)
endef
$(foreach dir, $(DIRS), $(eval $(call xxx_LOBJS_rule,$(dir))))
ifneq ($(WANT_NTL), 0)
$(BUILD_DIR)/interfaces/NTL-interface.lo: $(SRC_DIR)/interfaces/test/t-NTL-interface.cpp | $(BUILD_DIR)/interfaces
@echo " CXX $(@:$(BUILD_DIR)/%=%)"
@$(CXX) $(PIC_FLAG) $(CXXFLAGS) $(CPPFLAGS) $(LIB_CPPFLAGS) -c $< -o $@ -MMD -MF $(@:%=.d)
endif
endif
################################################################################
# executables
################################################################################
ifeq ($(SHARED), 0)
$(BUILD_DIR)/profile/%$(EXEEXT): $(SRC_DIR)/profile/%.c $(FLINT_DIR)/$(FLINT_LIB_STATIC) | $(BUILD_DIR)/profile
@echo " CC $(@:$(BUILD_DIR)/%=%)"
@$(CC) $(TESTCFLAGS) $(CPPFLAGS2) $< -o $@ $(EXE_LDFLAGS) $(LIBS2) -MMD -MF $(@:%=%.d)
else
$(BUILD_DIR)/profile/%$(EXEEXT): $(SRC_DIR)/profile/%.c | $(FLINT_DIR)/$(FLINT_LIB_FULL) $(BUILD_DIR)/profile
@echo " CC $(@:$(BUILD_DIR)/%=%)"
@$(CC) $(TESTCFLAGS) $(CPPFLAGS2) $< -o $@ $(EXE_LDFLAGS) $(LIBS2) -MMD -MF $(@:%=%.d)
endif
ifeq ($(SHARED), 0)
define xxx_PROFS_rule
$(BUILD_DIR)/$(1)/profile/%$(EXEEXT): $(SRC_DIR)/$(1)/profile/%.c $(FLINT_DIR)/$(FLINT_LIB_STATIC) | $(BUILD_DIR)/$(1)/profile
@echo " CC $$(@:$(BUILD_DIR)/%=%)"
@$(CC) $(TESTCFLAGS) $(CPPFLAGS2) $$< -o $$@ $(EXE_LDFLAGS) $(LIBS2) -MMD -MF $$(@:%=%.d)
endef
else
define xxx_PROFS_rule
$(BUILD_DIR)/$(1)/profile/%$(EXEEXT): $(SRC_DIR)/$(1)/profile/%.c | $(FLINT_DIR)/$(FLINT_LIB_FULL) $(BUILD_DIR)/$(1)/profile
@echo " CC $$(@:$(BUILD_DIR)/%=%)"
@$(CC) $(TESTCFLAGS) $(CPPFLAGS2) $$< -o $$@ $(EXE_LDFLAGS) $(LIBS2) -MMD -MF $$(@:%=%.d)
endef
endif
$(foreach dir, $(DIRS), $(eval $(call xxx_PROFS_rule,$(dir))))
ifeq ($(SHARED), 0)
$(BUILD_DIR)/test/%$(EXEEXT): $(SRC_DIR)/test/%.c $(FLINT_DIR)/$(FLINT_LIB_STATIC) | $(BUILD_DIR)/test
@echo " CC $(@:$(BUILD_DIR)/%=%)"
@$(CC) $(TESTCFLAGS) $(CPPFLAGS2) $< -o $@ $(EXE_LDFLAGS) $(LIBS2) -MMD -MF $(@:%=%.d)
else
$(BUILD_DIR)/test/%$(EXEEXT): $(SRC_DIR)/test/%.c | $(FLINT_DIR)/$(FLINT_LIB_FULL) $(BUILD_DIR)/test
@echo " CC $(@:$(BUILD_DIR)/%=%)"
@$(CC) $(TESTCFLAGS) $(CPPFLAGS2) $< -o $@ $(EXE_LDFLAGS) $(LIBS2) -MMD -MF $(@:%=%.d)
endif
ifeq ($(SHARED), 0)
define xxx_TESTS_rule
$(BUILD_DIR)/$(1)/test/%$(EXEEXT): $(SRC_DIR)/$(1)/test/%.c $(FLINT_DIR)/libflint.a | $(BUILD_DIR)/$(1)/test
@echo " CC $$(@:$(BUILD_DIR)/%=%)"
@$(CC) $(TESTCFLAGS) $(CPPFLAGS2) $$< -o $$@ $(EXE_LDFLAGS) $(LIBS2) -MMD -MF $$(@:%=%.d)
endef
else
define xxx_TESTS_rule
$(BUILD_DIR)/$(1)/test/%$(EXEEXT): $(SRC_DIR)/$(1)/test/%.c | $(FLINT_DIR)/$(FLINT_LIB_FULL) $(BUILD_DIR)/$(1)/test
@echo " CC $$(@:$(BUILD_DIR)/%=%)"
@$(CC) $(TESTCFLAGS) $(CPPFLAGS2) $$< -o $$@ $(EXE_LDFLAGS) $(LIBS2) -MMD -MF $$(@:%=%.d)
endef
endif
$(foreach dir, $(DIRS), $(eval $(call xxx_TESTS_rule,$(dir))))
ifneq ($(WANT_NTL), 0)
ifeq ($(SHARED), 0)
$(BUILD_DIR)/interfaces/test/t-NTL-interface$(EXEEXT): $(SRC_DIR)/interfaces/test/t-NTL-interface.cpp $(FLINT_DIR)/$(FLINT_LIB_STATIC) | $(BUILD_DIR)/interfaces/test
@echo " CXX $(@:$(BUILD_DIR)/%=%)"
@$(CXX) $(CXXFLAGS) $(CPPFLAGS2) $< -o $@ $(EXE_LDFLAGS) $(LIBS2) -MMD -MF $(@:%=%.d)
else
$(BUILD_DIR)/interfaces/test/t-NTL-interface$(EXEEXT): $(SRC_DIR)/interfaces/test/t-NTL-interface.cpp | $(FLINT_DIR)/$(FLINT_LIB_FULL) $(BUILD_DIR)/interfaces/test
@echo " CXX $(@:$(BUILD_DIR)/%=%)"
@$(CXX) $(CXXFLAGS) $(CPPFLAGS2) $< -o $@ $(EXE_LDFLAGS) $(LIBS2) -MMD -MF $(@:%=%.d)
endif
endif
ifeq ($(SHARED), 0)
$(BUILD_DIR)/tune/%$(EXEEXT): $(SRC_DIR)/tune/%.c $(FLINT_DIR)/$(FLINT_LIB_STATIC) | $(BUILD_DIR)/tune
@echo " CC $(@:$(BUILD_DIR)/%=%)"
@$(CC) $(TESTCFLAGS) $(CPPFLAGS2) $< -o $@ $(EXE_LDFLAGS) $(LIBS2) -MMD -MF $(@:%=%.d)
else
$(BUILD_DIR)/tune/%$(EXEEXT): $(SRC_DIR)/tune/%.c | $(FLINT_DIR)/$(FLINT_LIB_FULL) $(BUILD_DIR)/tune
@echo " CC $(@:$(BUILD_DIR)/%=%)"
@$(CC) $(TESTCFLAGS) $(CPPFLAGS2) $< -o $@ $(EXE_LDFLAGS) $(LIBS2) -MMD -MF $(@:%=%.d)
endif
ifeq ($(SHARED), 0)
define xxx_TUNES_rule
$(BUILD_DIR)/$(1)/tune/%$(EXEEXT): $(SRC_DIR)/$(1)/tune/%.c $(FLINT_DIR)/$(FLINT_LIB_STATIC) | $(BUILD_DIR)/$(1)/tune
@echo " CC $$(@:$(BUILD_DIR)/%=%)"
@$(CC) $(TESTCFLAGS) $(CPPFLAGS2) $$< -o $$@ $(EXE_LDFLAGS) $(LIBS2) -MMD -MF $$(@:%=%.d)
endef
else
define xxx_TUNES_rule
$(BUILD_DIR)/$(1)/tune/%$(EXEEXT): $(SRC_DIR)/$(1)/tune/%.c | $(FLINT_DIR)/$(FLINT_LIB_FULL) $(BUILD_DIR)/$(1)/tune
@echo " CC $$(@:$(BUILD_DIR)/%=%)"
@$(CC) $(TESTCFLAGS) $(CPPFLAGS2) $$< -o $$@ $(EXE_LDFLAGS) $(LIBS2) -MMD -MF $$(@:%=%.d)
endef
endif
$(foreach dir, $(DIRS), $(eval $(call xxx_TUNES_rule,$(dir))))
ifeq ($(SHARED), 0)
$(BUILD_DIR)/examples/%$(EXEEXT): $(FLINT_DIR)/examples/%.c $(FLINT_DIR)/$(FLINT_LIB_STATIC) | $(BUILD_DIR)/examples
@echo " CC $(@:$(BUILD_DIR)/%=%)"
@$(CC) $(TESTCFLAGS) $(CPPFLAGS2) $< -o $@ $(EXE_LDFLAGS) $(LIBS2) -MMD -MF $(@:%=%.d)
else
$(BUILD_DIR)/examples/%$(EXEEXT): $(FLINT_DIR)/examples/%.c | $(FLINT_DIR)/$(FLINT_LIB_FULL) $(BUILD_DIR)/examples
@echo " CC $(@:$(BUILD_DIR)/%=%)"
@$(CC) $(TESTCFLAGS) $(CPPFLAGS2) $< -o $@ $(EXE_LDFLAGS) $(LIBS2) -MMD -MF $(@:%=%.d)
endif
################################################################################
# examples
################################################################################
examples: library $(EXMPS)
################################################################################
# profiling
################################################################################
ifdef MOD
profile: library $(foreach dir, $(MOD), $($(dir)_PROFS))
else
profile: library $(PROFS)
endif
################################################################################
# tests
################################################################################
tests: library $(TESTS)
# NOTE: File has to be located in another directory in order for this to work.
%_TEST_RUN: %
@$<
ifdef PYTHON
check: library
PYTHONPATH=$(FLINT_DIR) python3 $(SRC_DIR)/python/flint_ctypes.py
else ifdef MOD
check: library $(patsubst %,%_TEST_RUN,$(foreach dir, $(MOD), $($(dir)_TESTS)))
else
check: library $(TESTS:%=%_TEST_RUN)
endif
################################################################################
# tuning
################################################################################
tune: library $(TUNES)
################################################################################
# valgrind
################################################################################
%_VALGRIND_RUN: %
valgrind --track-origins=yes --leak-check=full --show-reachable=yes --log-file="$*.valgrind" $<
ifdef MOD
valgrind: library $(patsubst %,%_VALGRIND_RUN,$(foreach dir, $(MOD), $($(dir)_TESTS)))
else
valgrind: library $(TESTS:%=%_VALGRIND_RUN)
endif
################################################################################
# coverage
################################################################################
ifneq ($(COVERAGE), 0)
coverage: | $(BUILD_DIR)/coverage
lcov --capture --exclude "*test/t-*.c" --exclude "/usr/*" --directory $(BUILD_DIR) --output-file $(BUILD_DIR)/coverage/coverage.info
genhtml $(BUILD_DIR)/coverage/coverage.info --output-directory $(BUILD_DIR)/coverage
endif
################################################################################
# clean
################################################################################
clean:
$(RM_F) $(FLINT_DIR)/$(FLINT_LIB)
$(RM_F) $(FLINT_DIR)/$(FLINT_LIB_MAJOR)
$(RM_F) $(FLINT_DIR)/$(FLINT_LIB_FULL)
ifneq ($(FLINT_DLLLIB), 0)
$(RM_F) $(FLINT_DIR)/$(FLINT_IMPLIB)
endif
$(RM_F) $(FLINT_DIR)/$(FLINT_LIB_STATIC)
$(RM_RF) $(BUILD_DIR)
distclean: clean
$(RM_F) $(CFG_FILES)
################################################################################
# install and uninstall
################################################################################
install: library | $(INSTALL_DIRS)
$(CP) flint.pc $(PKGCONFIGDIR)/flint.pc
ifneq ($(SHARED), 0)
ifneq ($(FLINT_DLLLIB),0)
$(CP_A) $(FLINT_DIR)/$(FLINT_LIB) $(BINDIR)
$(CP_A) $(FLINT_DIR)/$(FLINT_LIB_MAJOR) $(BINDIR)
$(CP_A) $(FLINT_DIR)/$(FLINT_LIB_FULL) $(BINDIR)
$(CP) $(FLINT_DIR)/$(FLINT_IMPLIB) $(LIBDIR)
else
$(CP_A) $(FLINT_DIR)/$(FLINT_LIB) $(LIBDIR)
$(CP_A) $(FLINT_DIR)/$(FLINT_LIB_MAJOR) $(LIBDIR)
$(CP_A) $(FLINT_DIR)/$(FLINT_LIB_FULL) $(LIBDIR)
endif
ifneq ($(FLINT_DYLIB),0)
install_name_tool -id $(LIBDIR)/$(FLINT_LIB_FULL) $(LIBDIR)/$(FLINT_LIB)
endif
endif
ifneq ($(STATIC), 0)
$(CP) $(FLINT_DIR)/$(FLINT_LIB_STATIC) $(LIBDIR)
endif
$(CP) $(HEADERS) $(INCLUDEDIR)/flint
ifneq ($(WANT_CXX), 0)
$(CP) $(SRC_DIR)/flintxx/*.h $(INCLUDEDIR)/flint/flintxx
$(CP) $(SRC_DIR)/flintxx_public/*xx.h $(INCLUDEDIR)/flint
endif
uninstall:
$(RM_F) $(PKGCONFIGDIR)/flint.pc
ifneq ($(FLINT_DLLLIB),0)
$(RM_F) $(BINDIR)/$(FLINT_LIB)
$(RM_F) $(BINDIR)/$(FLINT_LIB_MAJOR)
$(RM_F) $(BINDIR)/$(FLINT_LIB_FULL)
$(RM_F) $(LIBDIR)/$(FLINT_IMPLIB)
else
$(RM_F) $(LIBDIR)/$(FLINT_LIB)
$(RM_F) $(LIBDIR)/$(FLINT_LIB_MAJOR)
$(RM_F) $(LIBDIR)/$(FLINT_LIB_FULL)
endif
$(RM_F) $(LIBDIR)/$(FLINT_LIB_STATIC)
$(RM_RF) $(INCLUDEDIR)/flint
################################################################################
# maintainer stuff
################################################################################
dist:
git archive --format tar --prefix flint-$(FLINT_MAJOR).$(FLINT_MINOR).$(FLINT_PATCH)/ origin/flint-$(FLINT_MAJOR).$(FLINT_MINOR) > ../flint-$(FLINT_MAJOR).$(FLINT_MINOR).$(FLINT_PATCH).tar; gzip ../flint-$(FLINT_MAJOR).$(FLINT_MINOR).$(FLINT_PATCH).tar
git archive --format zip --prefix flint-$(FLINT_MAJOR).$(FLINT_MINOR).$(FLINT_PATCH)/ origin/flint-$(FLINT_MAJOR).$(FLINT_MINOR) > ../flint-$(FLINT_MAJOR).$(FLINT_MINOR).$(FLINT_PATCH).zip
################################################################################
# debugging
################################################################################
print-%:
@echo "$*=$($*)"
.PHONY: all library shared static examples profile tests check tune valgrind clean distclean install uninstall dist %_TEST_RUN %_VALGRIND_RUN print-% coverage