forked from gap-system/gap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.rules
1160 lines (959 loc) · 40.3 KB
/
Makefile.rules
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
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
########################################################################
#
# Makefile rules for GAP, to be included from GNUmakefile.
# Partially based on the git and ScummVM build systems.
#
# This requires GNU make!!! You have been warned.
#
# To learn more about the GAP build system, see README.buildsys.md
#
########################################################################
########################################################################
# Default rule: build gap
########################################################################
all: gap$(EXEEXT) gac
.PHONY: all
libgap: libgap.la
.PHONY: libgap
# Backwards compatibility: add "default" target as alias for "all"
default: all
.PHONY: default
########################################################################
# Source files
#
# We avoid line continuations, instead use repeatedly "SOURCES+=". This
# makes it trivial to comment out lines, or to insert conditionals.
########################################################################
SOURCES =
SOURCES += src/ariths.c
SOURCES += src/blister.c
SOURCES += src/bool.c
SOURCES += src/c_methsel1.c
SOURCES += src/c_oper1.c
SOURCES += src/c_type1.c
SOURCES += src/calls.c
SOURCES += src/code.c
SOURCES += src/compiler.c
SOURCES += src/compstat.c
SOURCES += src/costab.c
SOURCES += src/cyclotom.c
SOURCES += src/debug.c
SOURCES += src/dt.c
SOURCES += src/dteval.c
SOURCES += src/exprs.c
SOURCES += src/ffdata.c
SOURCES += src/finfield.c
SOURCES += src/funcs.c
SOURCES += src/gap.c
SOURCES += gen/gap_version.c # generated source file
SOURCES += src/gapstate.c
SOURCES += src/gvars.c
SOURCES += src/hookintrprtr.c
SOURCES += src/integer.c
SOURCES += src/intfuncs.c
SOURCES += src/intrprtr.c
SOURCES += src/io.c
SOURCES += src/iostream.c
SOURCES += src/listfunc.c
SOURCES += src/listoper.c
SOURCES += src/lists.c
SOURCES += src/macfloat.c
SOURCES += src/modules-builtin.c
SOURCES += src/objccoll.c
SOURCES += src/objcftl.c
SOURCES += src/objects.c
SOURCES += src/objfgelm.c
SOURCES += src/objpcgel.c
SOURCES += src/objscoll.c
SOURCES += src/objset.c
SOURCES += src/opers.c
SOURCES += src/permutat.c
SOURCES += src/plist.c
SOURCES += src/pperm.c
SOURCES += src/precord.c
SOURCES += src/profile.c
SOURCES += src/range.c
SOURCES += src/rational.c
SOURCES += src/read.c
SOURCES += src/records.c
SOURCES += src/saveload.c
SOURCES += src/scanner.c
SOURCES += src/sctable.c
SOURCES += src/set.c
SOURCES += src/stats.c
SOURCES += src/streams.c
SOURCES += src/stringobj.c
SOURCES += src/sysfiles.c
SOURCES += src/system.c
SOURCES += src/tietze.c
SOURCES += src/trans.c
SOURCES += src/vars.c
SOURCES += src/vec8bit.c
SOURCES += src/vecffe.c
SOURCES += src/vecgf2.c
SOURCES += src/vector.c
SOURCES += src/weakptr.c
# TODO: Change the following to check for a new USE_BOEHM flag
ifeq ($(HPCGAP),yes)
SOURCES += src/boehm_gc.c
else
SOURCES += src/gasman.c
endif
ifeq ($(GAPMPI),yes)
SOURCES += src/hpc/gapmpi.c
endif
ifeq ($(HPCGAP),yes)
SOURCES += src/hpc/aobjects.c
SOURCES += src/hpc/misc.c
SOURCES += src/hpc/serialize.c
SOURCES += src/hpc/thread.c
SOURCES += src/hpc/threadapi.c
SOURCES += src/hpc/tls.c
SOURCES += src/hpc/traverse.c
endif
########################################################################
# Preprocessor flags
#
# GAP_CPPFLAGS is for the GAP build system, while GAP_PKG_CPPFLAGS is
# for use by gac, and for package build systems. The latter does not
# contain warning flags, and uses absolute include paths.
########################################################################
GAP_CPPFLAGS =
GAP_PKG_CPPFLAGS =
# First add include paths
# If this is an out-of-tree build, then first add the builddir to the list of
# include directories, so that the correct gen/config.h is picked up (even if
# the user also has an active in-tree build)
ifneq ($(builddir),$(srcdir))
GAP_CPPFLAGS += -I$(builddir)
GAP_PKG_CPPFLAGS += -I$(abs_builddir)
endif
# Finally look into srcdir
GAP_CPPFLAGS += -I$(srcdir)
GAP_PKG_CPPFLAGS += -I$(abs_srcdir)
# Add DEFS (from autoconf, contains -D flags)
GAP_CPPFLAGS += $(DEFS)
GAP_PKG_CPPFLAGS += $(DEFS)
# Add flags for dependencies
GAP_CPPFLAGS += $(GMP_CPPFLAGS)
GAP_CPPFLAGS += $(READLINE_CPPFLAGS)
GAP_CPPFLAGS += $(BOEHM_GC_CPPFLAGS)
GAP_CPPFLAGS += $(LIBATOMIC_OPS_CPPFLAGS)
GAP_PKG_CPPFLAGS += $(GMP_CPPFLAGS)
GAP_PKG_CPPFLAGS += $(READLINE_CPPFLAGS)
GAP_PKG_CPPFLAGS += $(BOEHM_GC_CPPFLAGS)
GAP_PKG_CPPFLAGS += $(LIBATOMIC_OPS_CPPFLAGS)
# Add flags controlling compiler warnings (not for GAP_PKG_CPPFLAGS)
GAP_CPPFLAGS += $(WARNING_CPPFLAGS)
# Finally add user provided flags
GAP_CPPFLAGS += $(CPPFLAGS)
GAP_PKG_CPPFLAGS += $(CPPFLAGS)
########################################################################
# Compiler flags
########################################################################
GAP_CFLAGS = $(ABI_CFLAGS)
ifeq ($(HPCGAP),yes)
GAP_CFLAGS += $(PTHREAD_CFLAGS)
endif
# Finally add user provided CFLAGS
GAP_CFLAGS += $(CFLAGS)
########################################################################
# Linker flags
########################################################################
GAP_LDFLAGS = $(ABI_CFLAGS)
# Add flags for dependencies
GAP_LDFLAGS += $(GMP_LDFLAGS)
GAP_LDFLAGS += $(READLINE_LDFLAGS)
GAP_LDFLAGS += $(BOEHM_GC_LDFLAGS)
GAP_LDFLAGS += $(LIBATOMIC_OPS_LDFLAGS)
ifeq ($(HPCGAP),yes)
GAP_LDFLAGS += $(PTHREAD_CFLAGS) $(PTHREAD_LIBS)
endif
# Finally add user provided flags
GAP_LDFLAGS += $(LDFLAGS)
# libs
GAP_LIBS =
# Add flags for dependencies
GAP_LIBS += $(GMP_LIBS)
GAP_LIBS += $(READLINE_LIBS)
GAP_LIBS += $(BOEHM_GC_LIBS)
GAP_LIBS += $(LIBATOMIC_OPS_LIBS)
# Finally add user provided flags
GAP_LIBS += $(LIBS)
########################################################################
# HPC-GAP: transform code using ward
#
# For HPC-GAP, we must use ward as a preprocessor before invoking the C
# compiler. Moreover, some source files come in two versions: One which is
# located in src/, and another in hpcgap/src/, which is to be used instead
# when building in HPC-GAP mode.
#
# The following build rules achieve this.
########################################################################
ifeq ($(HPCGAP),yes)
# Compute new list of sources from ORIGINAL_SOURCES, by replacing src/ with gen/
ORIGINAL_SOURCES := $(SOURCES)
SOURCES := $(patsubst src/%,gen/%,$(ORIGINAL_SOURCES))
# Determine which sources have a version in "hpcgap/src".
# This uses the fact that "wildcard" only returns paths which refer
# to existing files.
HPCGAP_SOURCES := $(wildcard $(addprefix $(srcdir)/hpcgap/,$(ORIGINAL_SOURCES)))
HPCGAP_SOURCES := $(subst $(srcdir)/hpcgap/src/,,$(HPCGAP_SOURCES))
HPCGAP_SOURCES := $(addprefix gen/,$(HPCGAP_SOURCES))
# static pattern rule for sources with an HPCGAP-version
# (note that ward needs to parse the sources, hence gen/config.h must already be made)
$(HPCGAP_SOURCES): gen/%.c: hpcgap/src/%.c gen/config.h
@$(MKDIR_P) $(@D)/$(DEPDIRNAME)
@echo "$@: $<" > $(DEPFILE)
@echo "$<:" >> $(DEPFILE)
$(QUIET_WARD) CPP="$(CPP)" $(ADDGUARDS2) -cpp $(GAP_CPPFLAGS) -- $< > $@
# static pattern rule for sources without an HPCGAP-version
# (note that ward needs to parse the sources, hence gen/config.h must already be made)
gen/%.c: src/%.c gen/config.h
@$(MKDIR_P) $(@D)/$(DEPDIRNAME)
@echo "$@: $<" > $(DEPFILE)
@echo "$<:" >> $(DEPFILE)
$(QUIET_WARD) CPP="$(CPP)" $(ADDGUARDS2) -cpp $(GAP_CPPFLAGS) -- $< > $@
# Normally, GNU make deletes intermediate build files, such as the gen/*.c
# files generated by ward. We do not want this for various reasons (performance
# being one of them), so we tell GNU make accordingly:
.SECONDARY: $(SOURCES)
endif # end of HPCGAP specific code
# instruct GNU make to delete output files of failed build rules,
# so that if Ward errors out, any incomplete generated files are
# deleted.
.DELETE_ON_ERROR:
########################################################################
# Object files
########################################################################
# OBJS shall contain the names of all object files that constitute GAP.
# So turn all src/*.c and gen/*.c file names in SOURCES into obj/*.lo
OBJS = $(patsubst gen/%.c,obj/%.lo,$(patsubst src/%.c,obj/%.lo,$(SOURCES)))
# ensure config.h is built before the compilers gets invoked
$(OBJS): gen/config.h
########################################################################
# Quiet rules.
#
# Replace regular output with quiet messages, unless V is set,
# e.g. "make V=1"
########################################################################
ifneq ($(findstring $(MAKEFLAGS),s),s)
ifndef V
QUIET_CC = @echo " C $< => $@";
QUIET_LINK = @echo " LINK $@";
QUIET_WARD = @echo " WARD $< => $@";
QUIET_SED = @echo " SED $< => $@";
QUIET_INSTALL = @echo " INSTALL $< => $@";
QUIET = @
LIBTOOL += --silent
endif
endif
########################################################################
# Rules for automatic header dependency tracking.
#
# This is somewhat similar to what automake does, but relies on compiler
# support. The result is much simpler.
#
# So, here is what happens: In each directory containing source files,
# a ".deps" subdirectory is created. We then instruct the compiler via
# some flags to create a ".deps/FOO.d" file when it compiles "FOO.c".
# This file encodes the header dependencies of "FOO.c" in a way that
# make can read (i.e. simply as a bunch of make targets with
# dependencies).
#
# Finally, to let make track the header dependencies, we include the *.d files.
#
# For a more detailed explanation of a very similar scheme, read this:
# http://make.mad-scientist.net/papers/advanced-auto-dependency-generation/
#
########################################################################
# Name of subdirectories in which the generated dependencies are stored.
DEPDIRNAME := .deps
# List of all (potential) dependency directories, derived from OBJS
# and SOURCES (the latter for generated sources, which may also involve
# dependency tracking)
DEPDIRS = $(addsuffix $(DEPDIRNAME),$(sort $(dir $(SOURCES) $(OBJS))))
# Include the dependency tracking files.
-include $(wildcard $(addsuffix /*.d,$(DEPDIRS)))
# Mark *.d files as PHONY. This stops make from trying to
# recreate them (which it can't), and in particular from looking for potential
# source files. This can save quite a bit of disk access time.
.PHONY: $(wildcard $(addsuffix /*.d,$(DEPDIRS)))
DEPFILE = "$(@D)/$(DEPDIRNAME)/$(*F).d"
# The following flags instruct the compiler to enable advanced
# dependency tracking. Supported by GCC 3 and newer; clang; Intel C
# compiler; and more.
#
# TODO: use configure to compute DEPFLAGS, so that we can
# disable it for compilers that don't support it, resp. replace it
# something that works for that compiler
DEPFLAGS = -MQ "$@" -MMD -MP -MF $(DEPFILE)
########################################################################
# Compiler rules
########################################################################
COMPILE=$(LIBTOOL) --mode=compile $(CC)
# Build rule for C source files
# Disabled for HPC-GAP, to ensure we always use the output of ward
# and not the original source files
ifeq ($(HPCGAP),no)
obj/%.lo: src/%.c cnf/GAP-CFLAGS cnf/GAP-CPPFLAGS
@$(MKDIR_P) $(@D)/$(DEPDIRNAME)
$(QUIET_CC)$(COMPILE) $(DEPFLAGS) $(GAP_CFLAGS) $(GAP_CPPFLAGS) -c $< -o $@
endif
# Build rule for generated C source files
obj/%.lo: gen/%.c cnf/GAP-CFLAGS cnf/GAP-CPPFLAGS
@$(MKDIR_P) $(@D)/$(DEPDIRNAME)
$(QUIET_CC)$(COMPILE) $(DEPFLAGS) $(GAP_CFLAGS) $(GAP_CPPFLAGS) -c $< -o $@
########################################################################
# Linker rules for gap executable
########################################################################
LINK=$(LIBTOOL) --mode=link $(CC) -export-dynamic
libgap.la: $(OBJS) cnf/GAP-LDFLAGS cnf/GAP-LIBS cnf/GAP-OBJS
$(QUIET_LINK)$(LINK) -no-undefined -rpath $(libdir) $(GAP_LDFLAGS) $(OBJS) $(GAP_LIBS) -o $@
ifeq ($(SYS_IS_CYGWIN32),yes)
all: bin/gapicon.bmp bin/gapicon.ico bin/instcygwinterminfo.sh bin/cygwin-version.txt
bin/gapicon.bmp: $(srcdir)/cnf/cygwin/gapicon.bmp
cp $< $@
bin/gapicon.ico: $(srcdir)/cnf/cygwin/gapicon.ico
cp $< $@
bin/instcygwinterminfo.sh: $(srcdir)/cnf/cygwin/instcygwinterminfo.sh
cp $< $@
chmod a+x $@
bin/cygwin-version.txt:
uname -a > $@
GAP_CPPFLAGS += "-DCOMPILECYGWINDLL"
# increase stack size, the default is too small (see issue #1522)
GAP_LDFLAGS += -Wl,--stack,16777216
# Special build rules for CYGWIN / Windows: In order to allow kernel
# extensions, we employ a trick: GAP itself is compiled into DLL, in which
# GAP's standard main function is renamed. And gap.exe is a tiny binary which
# loads that DLL and calls the renamed main function.
all: bin/$(GAPARCH)/gap.dll
bin/$(GAPARCH)/gap.dll: symlinks libgap.la
cp .libs/cyggap-0.dll $@ # FIXME: HACK to support kernel extensions
gap$(EXEEXT): libgap.la cnf/GAP-LDFLAGS cnf/GAP-LIBS cnf/GAP-OBJS
$(QUIET_LINK)$(LINK) $(GAP_LDFLAGS) $(srcdir)/src/gapw95.c $(GAP_LIBS) libgap.la -o $@
@( if which peflags > /dev/null ; then peflags --cygwin-heap=2048 gap$(EXEEXT) ; fi )
else
# Linking rule and dependencies for the main gap executable
gap$(EXEEXT): $(OBJS) cnf/GAP-LDFLAGS cnf/GAP-LIBS cnf/GAP-OBJS
$(QUIET_LINK)$(LINK) $(GAP_LDFLAGS) $(OBJS) $(GAP_LIBS) -o $@
endif
########################################################################
# The "docomp" target regenerates the various src/c_*.c files, and
# replaces the old "etc/docomp" script.
########################################################################
ifeq ($(HPCGAP),yes)
DOCOMP_PREFIX = $(abs_srcdir)/hpcgap
else
DOCOMP_PREFIX = $(abs_srcdir)
endif
docomp: #gap$(EXEEXT)
@"$(abs_srcdir)"/cnf/GAP-C-GEN $(abs_srcdir)/lib $(abs_srcdir)/src methsel1 ./gap$(EXEEXT)
@"$(abs_srcdir)"/cnf/GAP-C-GEN $(abs_srcdir)/lib $(DOCOMP_PREFIX)/src oper1 ./gap$(EXEEXT)
@"$(abs_srcdir)"/cnf/GAP-C-GEN $(abs_srcdir)/lib $(DOCOMP_PREFIX)/src type1 ./gap$(EXEEXT)
.PHONY: docomp
########################################################################
# The "ffdata" target regenerates src/ffdata.{c,h} using etc/ffgen.c
########################################################################
ffgen: etc/ffgen.c
$(QUIET_CC)$(CC) -Wall -Wextra $< -o $@
ffdata: ffgen
./ffgen -h > $(abs_srcdir)/src/ffdata.h
./ffgen -c > $(abs_srcdir)/src/ffdata.c
.PHONY: ffdata
########################################################################
# The "tags" target regenerates the tags file using Exuberant Ctags
########################################################################
tags:
cd $(abs_srcdir) && etc/tags.sh --recurse lib hpcgap/lib src
etags:
cd $(abs_srcdir) && etc/tags.sh -e --recurse lib hpcgap/lib src
.PHONY: tags etags
########################################################################
# Rules for 'make clean'
########################################################################
distclean: clean
rm -f config.log config.status libtool stamp-h GNUmakefile configure
rm -f bin/gap.sh sysinfo.gap*
rm -f doc/make_doc
rm -rf gen
rm -rf dev/log
rm -rf coverage
rm -rf tags
rm -rf TAGS
rmdir bin cnf dev doc src 2>/dev/null || : # remove dirs if they are now empty
clean:
rm -rf bin/$(GAPARCH)
rm -rf obj
rm -f gap$(EXEEXT) gac ffgen
rm -f libgap.la
rm -f gen/gap_version.c
rm -f doc/wsp.g
rm -f cnf/GAP-{CFLAGS,CPPFLAGS,LDFLAGS,LIBS,OBJS}
.PHONY: clean distclean
########################################################################
# Rules for 'make install'
########################################################################
LTINSTALL=$(LIBTOOL) --mode=install $(INSTALL)
install: install-libgap install-headers
@echo "Warning, 'make install' has not yet been fully implemented"
$(QUIET_INSTALL)$(INSTALL) -d -m 0755 $(DESTDIR)$(bindir)
$(QUIET_INSTALL)$(INSTALL) gap $(DESTDIR)$(bindir)
$(QUIET_INSTALL)$(INSTALL) gac $(DESTDIR)$(bindir)
install-headers:
$(QUIET_INSTALL)$(INSTALL) -d -m 0755 $(DESTDIR)$(includedir)/gap
$(QUIET_INSTALL)$(INSTALL) -d -m 0755 $(DESTDIR)$(includedir)/gap/hpc
$(QUIET_INSTALL)$(INSTALL) -m 0644 $(srcdir)/src/*.h $(DESTDIR)$(includedir)/gap
$(QUIET_INSTALL)$(INSTALL) -m 0644 $(srcdir)/src/hpc/*.h $(DESTDIR)$(includedir)/gap/hpc
sed -i -E -e 's;#include <src/([^>]+)>;#include "\1";' $(DESTDIR)$(includedir)/gap/*.h
sed -i -E -e 's;#include <src/([^>]+)>;#include "\1";' $(DESTDIR)$(includedir)/gap/hpc/*.h
# TODO: take care of config.h
install-libgap: libgap.la
$(QUIET_INSTALL)$(INSTALL) -d -m 0755 $(DESTDIR)$(libdir)
$(QUIET_INSTALL)$(LTINSTALL) libgap.la $(DESTDIR)$(libdir)
.PHONY: install install-libgap
########################################################################
# Building subprojects
########################################################################
# master target for external dependencies / subprojects
EXTERN_FILES =
#
# GMP
#
ifeq ($(BUILD_GMP),yes)
GMP_BUILDDIR := extern/build/gmp
GMP_PREFIX := extern/install/gmp
# GMP_PREREQ := $(GMP_BUILDDIR)/config.status
GMP_FILES := $(GMP_PREFIX)/lib/libgmp.la
EXTERN_FILES += $(GMP_FILES)
# Note: we pass the ABI flag to gmp, and also --enable-shared ; the latter
# is there for the benefit of cygwin builds, where GMP otherwise defaults
# to building only a static library.
# We touch gmp.info so GMP does not think it is out of date and rebuilds it,
# because that requires makeinfo
gmp: $(GMP_FILES)
$(GMP_FILES):
touch "$(abs_srcdir)/extern/gmp/doc/gmp.info"
MAKE=$(MAKE) $(srcdir)/cnf/build-extern.sh gmp "$(abs_srcdir)/extern/gmp" ABI=$(ABI) --disable-static --enable-shared
.PHONY: gmp
# TODO: add clean, distclean, check targets?
# TODO: pass on cachfile?
# TODO: pass on certain *FLAGS ?
else
gmp:
echo "Using external GMP, nothing to do be done"
endif # BUILD_GMP
#
# libatomic_ops
#
ifeq ($(BUILD_LIBATOMIC_OPS),yes)
LIBATOMIC_OPS_BUILDDIR := extern/build/libatomic_ops
LIBATOMIC_OPS_PREFIX := extern/install/libatomic_ops
#LIBATOMIC_OPS_PREREQ := $(LIBATOMIC_OPS_BUILDDIR)/config.status
LIBATOMIC_OPS_FILES := $(LIBATOMIC_OPS_PREFIX)/lib/libatomic_ops.la
EXTERN_FILES += $(LIBATOMIC_OPS_FILES)
libatomic_ops: $(LIBATOMIC_OPS_FILES)
$(LIBATOMIC_OPS_FILES):
MAKE=$(MAKE) CFLAGS=$(ABI_CFLAGS) LDFLAGS=$(ABI_CFLAGS) \
$(srcdir)/cnf/build-extern.sh libatomic_ops "$(abs_srcdir)/hpcgap/extern/libatomic_ops" --disable-static --enable-shared
# TODO: MAKEFLAGS=-j1
.PHONY: libatomic_ops
endif # BUILD_LIBATOMIC_OPS
#
# Boehm GC
#
ifeq ($(BUILD_BOEHM_GC),yes)
# TODO: ensure Boehm GC is built *after* libatomic_ops, at least if
# we are building or own libatomic_ops.
# Also, ensure that it uses the right version of libatomic_ops,
# by passing --with-libatomic-ops=...
# TODO: also pass
# TODO: refactor code which handles dependencies like GMP, Boehm, libatomic,
# to reduce code duplication.
# TODO: pass on more things to configure, e.g. the build / host system type...
#
BOEHM_GC_BUILDDIR := extern/build/gc
BOEHM_GC_PREFIX := extern/install/gc
#BOEHM_GC_PREREQ := $(BOEHM_GC_BUILDDIR)/config.status
BOEHM_GC_FILES := $(BOEHM_GC_PREFIX)/lib/libgc.la
EXTERN_FILES += $(BOEHM_GC_FILES)
boehm: gc # alias
gc: $(BOEHM_GC_FILES)
$(BOEHM_GC_FILES):
MAKE=$(MAKE) \
CFLAGS=$(ABI_CFLAGS) \
LDFLAGS=$(ABI_CFLAGS) \
ATOMIC_OPS_CFLAGS=$(LIBATOMIC_OPS_CPPFLAGS) \
ATOMIC_OPS_LIBS=$(LIBATOMIC_OPS_LDFLAGS) \
$(srcdir)/cnf/build-extern.sh gc "$(abs_srcdir)/hpcgap/extern/gc" --disable-static --enable-shared
ifeq ($(BUILD_LIBATOMIC_OPS),yes)
$(BOEHM_GC_FILES): $(LIBATOMIC_OPS_FILES)
endif
.PHONY: boehm gc
endif # BUILD_BOEHM_GC
# ensure subprojects are built and "installed" before compiling and linking GAP
gap$(EXEEXT): $(EXTERN_FILES)
$(OBJS): $(EXTERN_FILES)
ifeq ($(HPCGAP),yes)
$(SOURCES): $(EXTERN_FILES)
endif
distclean: distclean-extern
distclean-extern:
rm -rf extern/build
rm -rf extern/install
########################################################################
# Compatibility mode
#
# If enabled, we prepare the environment to look like it did with
# the old build system, thus enabling existing packages with kernel
# extensions to be compiled against this version of GAP/
########################################################################
ifeq ($(COMPAT_MODE),yes)
# regenerate sysinfo.gap if necessary
all: sysinfo.gap
sysinfo.gap: config.status $(srcdir)/Makefile.rules cnf/GAP-CFLAGS cnf/GAP-CPPFLAGS cnf/GAP-LDFLAGS cnf/GAP-LIBS
@rm -f sysinfo.gap # in case this is a symlink created by an older version of the build system
@echo "# This files has been generated by the GAP build system," > $@
@echo "# do not edit manually!" >> $@
@echo "GAParch=$(GAPARCH)" >> $@
@echo "GAP_ABI=$(ABI)" >> $@
@echo "" >> $@
@echo "GAP_BIN_DIR=\"$(abs_builddir)\"" >> $@
@echo "GAP_LIB_DIR=\"$(abs_srcdir)\"" >> $@
@echo "" >> $@
@echo "GAP_CC=\"$(CC)\"" >> $@
@echo "GAP_CFLAGS=\"$(GAP_CFLAGS)\"" >> $@
@echo "GAP_CPPFLAGS=\"$(GAP_PKG_CPPFLAGS)\"" >> $@
@echo "GAP_LDFLAGS=\"$(GAP_LDFLAGS)\"" >> $@
@echo "GAP_LIBS=\"$(GAP_LIBS)\"" >> $@
@echo "" >> $@
@echo "GAP_OBJS=\"$(OBJS)\"" >> $@
# regenerate bin/gap.sh if necessary
all: bin/gap.sh
bin/gap.sh: $(srcdir)/cnf/compat/gap.sh.in config.status
$(SHELL) ./config.status $@
# regenerate symlinks if necessary
all: symlinks
symlinks: FORCE
@$(MKDIR_P) bin/$(GAPARCH)
@if test -L sysinfo.gap ; then rm -f sysinfo.gap && $(MAKE) sysinfo.gap ; fi
@$(srcdir)/cnf/REGEN-SYMLINK sysinfo.gap sysinfo.gap-default$(ABI)
@$(srcdir)/cnf/REGEN-SYMLINK $(abs_srcdir)/src bin/$(GAPARCH)/src
@$(srcdir)/cnf/REGEN-SYMLINK ../../gac bin/$(GAPARCH)/gac
@$(srcdir)/cnf/REGEN-SYMLINK ../../gap bin/$(GAPARCH)/gap
@$(srcdir)/cnf/REGEN-SYMLINK ../../gen/config.h bin/$(GAPARCH)/config.h
.PHONY: symlinks
endif
########################################################################
# Specifying GAP calls to use for the test suite and building manuals
########################################################################
GAPARGS=
TESTGAP = $(abs_builddir)/bin/gap.sh --quitonbreak -b -m 100m -o 1g -q -x 80 -r -A $(GAPARGS)
TESTGAPauto = $(abs_builddir)/bin/gap.sh --quitonbreak -b -m 100m -o 1g -q -x 80 -r $(GAPARGS)
########################################################################
# Documentation rules
########################################################################
# Alias for backwards compatibility
manuals: doc
doc: gap$(EXEEXT) doc/make_doc
doc/make_doc
clean-doc:
rm -f doc/*/chap*.html doc/*/chap*.txt doc/*/*.css doc/*/*.js
rm -f doc/*/chooser.html doc/*/manual*.pdf
rm -f doc/*/*.{aux,bbl,blg,brf,idx,ilg,ind,lab,log,out,pnr,six,tex,toc}
rm -f doc/manualbib.xml.bib
# FIXME: we currently build the manual inside $srcdir; so we don't want "make clean"
# to remove it, as other builds might share the manual.
#clean: clean-doc
# Manual consistency check
check-manuals: all
$(MKDIR_P) dev/log
((cd doc/ref ; \
echo 'Read("testconsistency.g");' | $(TESTGAP) ) \
> `date -u +dev/log/check_manuals_%Y-%m-%d-%H-%M` 2>&1 )
.PHONY: doc clean-doc manuals check-manuals
########################################################################
# Rules for test{install/standard/etc.} targets
########################################################################
# run testinstall.g twice:
# - without packages (except needed to run GAP)
# - with all packages loaded
testinstall: all
$(MKDIR_P) dev/log
( echo 'SetUserPreference("UseColorsInTerminal",false); \
ReadGapRoot( "tst/testinstall.g" );' | $(TESTGAP) | \
tee `date -u +dev/log/testinstall1_%Y-%m-%d-%H-%M` )
( echo 'SetUserPreference("UseColorsInTerminal",false); LoadAllPackages(); \
ReadGapRoot( "tst/testinstall.g" );' | $(TESTGAP) | \
tee `date -u +dev/log/testinstall2_%Y-%m-%d-%H-%M` )
# test manual examples three times:
# - without packages
# - with packages loaded by default
# - with all packages loaded
testmanuals: all
$(MKDIR_P) dev/log
((cd doc/tut ; \
echo 'SetUserPreference("UseColorsInTerminal",false); SetAssertionLevel( 2 ); \
Read("extractexamples.g"); Read("runexamples.g"); ' | $(TESTGAP);\
echo '============================================================';\
cd ../.. ; ff=`ls doc/tut/EXAMPLEDIFFS* 2> /dev/null | wc -l`; \
if [ $$ff != "0" ] ; then cat doc/tut/EXAMPLEDIFFS*; \
else echo "NO DIFFERENCES IN TUTORIAL EXAMPLES (NO PACKAGES)"; fi ; \
echo '============================================================';\
cd doc/ref ; \
echo 'SetUserPreference("UseColorsInTerminal",false); SetAssertionLevel( 2 ); \
Read("extractexamples.g"); Read("runexamples.g"); ' | $(TESTGAP);\
echo '============================================================';\
cd ../.. ; ff=`ls doc/ref/EXAMPLEDIFFS* 2> /dev/null | wc -l`; \
if [ $$ff != "0" ] ; then cat doc/ref/EXAMPLEDIFFS*; \
else echo "NO DIFFERENCES IN REFERENCE MANUAL EXAMPLES (NO PACKAGES)"; fi ) \
> `date -u +dev/log/testmanuals1_%Y-%m-%d-%H-%M` 2>&1 )
( rm -rf doc/tut/EXAMPLEDIFFS*; rm -rf doc/ref/EXAMPLEDIFFS* )
((cd doc/tut ; \
echo 'SetUserPreference("UseColorsInTerminal",false); SetAssertionLevel( 2 ); \
Read("extractexamples.g"); Read("runexamples.g"); ' | $(TESTGAPauto);\
echo '============================================================';\
cd ../.. ; ff=`ls doc/tut/EXAMPLEDIFFS* 2> /dev/null | wc -l`; \
if [ $$ff != "0" ] ; then cat doc/tut/EXAMPLEDIFFS*; \
else echo "NO DIFFERENCES IN TUTORIAL EXAMPLES (DEFAULT PACKAGES)"; fi ; \
echo '============================================================';\
cd doc/ref ; \
echo 'SetUserPreference("UseColorsInTerminal",false); SetAssertionLevel( 2 ); \
Read("extractexamples.g"); Read("runexamples.g"); ' | $(TESTGAPauto);\
echo '============================================================';\
cd ../.. ; ff=`ls doc/ref/EXAMPLEDIFFS* 2> /dev/null | wc -l`; \
if [ $$ff != "0" ] ; then cat doc/ref/EXAMPLEDIFFS*; \
else echo "NO DIFFERENCES IN REFERENCE MANUAL EXAMPLES (DEFAULT PACKAGES)"; fi ) \
> `date -u +dev/log/testmanualsA_%Y-%m-%d-%H-%M` 2>&1 )
( rm -rf doc/tut/EXAMPLEDIFFS*; rm -rf doc/ref/EXAMPLEDIFFS* )
((cd doc/tut ; \
echo 'SetUserPreference("UseColorsInTerminal",false); SetAssertionLevel( 2 ); \
LoadAllPackages() ; \
Read("extractexamples.g"); Read("runexamples.g"); ' | $(TESTGAP);\
echo '============================================================';\
cd ../.. ; ff=`ls doc/tut/EXAMPLEDIFFS* 2> /dev/null | wc -l`; \
if [ $$ff != "0" ] ; then cat doc/tut/EXAMPLEDIFFS*; \
else echo "NO DIFFERENCES IN TUTORIAL EXAMPLES (ALL PACKAGES)"; fi ; \
echo '============================================================';\
cd doc/ref ; \
echo 'SetUserPreference("UseColorsInTerminal",false); SetAssertionLevel( 2 ); \
LoadAllPackages() ; \
Read("extractexamples.g"); Read("runexamples.g"); ' | $(TESTGAP);\
echo '============================================================';\
cd ../.. ; ff=`ls doc/ref/EXAMPLEDIFFS* 2> /dev/null | wc -l`; \
if [ $$ff != "0" ] ; then cat doc/ref/EXAMPLEDIFFS*; \
else echo "NO DIFFERENCES IN REFERENCE MANUAL EXAMPLES (ALL PACKAGES)"; fi ) \
> `date -u +dev/log/testmanuals2_%Y-%m-%d-%H-%M` 2>&1 )
( rm -rf doc/tut/EXAMPLEDIFFS*; rm -rf doc/ref/EXAMPLEDIFFS* )
# check how packages are loaded when loading obsoletes is disabled
# - when all dependencies are loaded
# - when packages are loaded with `OnlyNeeded` option
testobsoletes: all
$(MKDIR_P) dev/log
( echo 'ReadGapRoot( "tst/testutil.g" ); \
SaveWorkspace( "wsp.g" );' | $(TESTGAP) -O )
( echo 'CreatePackageLoadTestsInput( "testobsoletes1.in", \
"dev/log/testobsoletes1", \
"$(TESTGAP) -O -L wsp.g", false, false );'\
| $(TESTGAP) -O -L wsp.g > /dev/null )
( chmod 777 testobsoletes1.in; ./testobsoletes1.in > \
`date -u +dev/log/testobsoletes1_%Y-%m-%d-%H-%M`; rm testobsoletes1.in )
( rm wsp.g )
( echo 'ReadGapRoot( "tst/testutil.g" ); \
SaveWorkspace( "wsp.g" );' | $(TESTGAP) -O )
( echo 'CreatePackageLoadTestsInput( "testobsoletesN1.in", \
"dev/log/testobsoletesN1", \
"$(TESTGAP) -O -L wsp.g", false, true );'\
| $(TESTGAP) -O -L wsp.g > /dev/null )
( chmod 777 testobsoletesN1.in; ./testobsoletesN1.in > \
`date -u +dev/log/testobsoletesN1_%Y-%m-%d-%H-%M`; rm testobsoletesN1.in )
( rm wsp.g )
# For a package with the name given by the PKGNAME variable,
# run its standard tests (i.e. those specified in PackageInfo.g):
# - in GAP started without packages
# - in GAP started with packages loaded by default
# - in GAP started with all packages loaded
testpackage: all
$(MKDIR_P) dev/log
( echo 'SetAssertionLevel( 2 ); ReadGapRoot( "tst/testutil.g" ); \
SaveWorkspace( "wsp.g" );' | $(TESTGAP) )
( echo 'CreatePackageTestsInput( "testpackage.in", \
"dev/log/testpackage1", \
"$(TESTGAP) -L wsp.g", "false", "$(PKGNAME)" );'\
| $(TESTGAP) -L wsp.g > /dev/null )
( chmod 777 testpackage.in; ./testpackage.in; rm testpackage.in )
( rm wsp.g )
( echo 'SetAssertionLevel( 2 ); ReadGapRoot( "tst/testutil.g" ); \
SaveWorkspace( "wsp.g" );' | $(TESTGAPauto) )
( echo 'CreatePackageTestsInput( "testpackage.in", \
"dev/log/testpackageA", \
"$(TESTGAPauto) -L wsp.g", "auto", "$(PKGNAME)" );'\
| $(TESTGAPauto) -L wsp.g > /dev/null )
( chmod 777 testpackage.in; ./testpackage.in; rm testpackage.in )
( rm wsp.g )
( echo 'SetAssertionLevel( 2 ); ReadGapRoot( "tst/testutil.g" ); \
SaveWorkspace( "wsp.g" );' | $(TESTGAP) )
( echo 'CreatePackageTestsInput( "testpackage.in", \
"dev/log/testpackage2", \
"$(TESTGAP) -L wsp.g", "true", "$(PKGNAME)" );'\
| $(TESTGAP) -L wsp.g > /dev/null )
( chmod 777 testpackage.in; ./testpackage.in; rm testpackage.in )
( rm wsp.g )
# For each package that specifies its standard tests in PackageInfo.g, run it
# - in GAP started without packages
# - in GAP started with packages loaded by default
# - in GAP started with all packages loaded
testpackages: all
$(MKDIR_P) dev/log
( echo 'SetAssertionLevel( 2 ); ReadGapRoot( "tst/testutil.g" ); \
SaveWorkspace( "wsp.g" );' | $(TESTGAP) )
( echo 'CreatePackageTestsInput( "testpackages.in", \
"dev/log/testpackages1", \
"$(TESTGAP) -L wsp.g", "false" );'\
| $(TESTGAP) -L wsp.g > /dev/null )
( chmod 777 testpackages.in; ./testpackages.in; rm testpackages.in )
( rm wsp.g )
( echo 'SetAssertionLevel( 2 ); ReadGapRoot( "tst/testutil.g" ); \
SaveWorkspace( "wsp.g" );' | $(TESTGAPauto) )
( echo 'CreatePackageTestsInput( "testpackages.in", \
"dev/log/testpackagesA", \
"$(TESTGAPauto) -L wsp.g", "auto" );'\
| $(TESTGAPauto) -L wsp.g > /dev/null )
( chmod 777 testpackages.in; ./testpackages.in; rm testpackages.in )
( rm wsp.g )
( echo 'SetAssertionLevel( 2 ); ReadGapRoot( "tst/testutil.g" ); \
SaveWorkspace( "wsp.g" );' | $(TESTGAP) )
( echo 'CreatePackageTestsInput( "testpackages.in", \
"dev/log/testpackages2", \
"$(TESTGAP) -L wsp.g", "true" );'\
| $(TESTGAP) -L wsp.g > /dev/null )
( chmod 777 testpackages.in; ./testpackages.in; rm testpackages.in )
( rm wsp.g )
# check how packages are loaded
# - when all dependencies are loaded
# - when packages are loaded with `OnlyNeeded` option
testpackagesload: all
$(MKDIR_P) dev/log
( echo 'ReadGapRoot( "tst/testutil.g" ); \
SaveWorkspace( "wsp.g" );' | $(TESTGAP) )
( echo 'CreatePackageLoadTestsInput( "testpackagesload.in", \
"dev/log/testpackagesload1", \
"$(TESTGAP) -L wsp.g", false, false );'\
| $(TESTGAP) -L wsp.g > /dev/null )
( chmod 777 testpackagesload.in; ./testpackagesload.in > \
`date -u +dev/log/testpackagesload1_%Y-%m-%d-%H-%M`; rm testpackagesload.in )
( rm wsp.g )
( echo 'ReadGapRoot( "tst/testutil.g" ); \
SaveWorkspace( "wsp.g" );' | $(TESTGAP) )
( echo 'CreatePackageLoadTestsInput( "testpackagesload.in", \
"dev/log/testpackagesloadN1", \
"$(TESTGAP) -L wsp.g", false, true );'\
| $(TESTGAP) -L wsp.g > /dev/null )
( chmod 777 testpackagesload.in; ./testpackagesload.in > \
`date -u +dev/log/testpackagesloadN1_%Y-%m-%d-%H-%M`; rm testpackagesload.in )
( rm wsp.g )
( echo 'ReadGapRoot( "tst/testutil.g" ); \
SaveWorkspace( "wsp.g" );' | $(TESTGAPauto) )
( echo 'CreatePackageLoadTestsInput( "testpackagesload.in", \
"testpackagesloadA", \
"$(TESTGAPauto) -L wsp.g", true, false );'\
| $(TESTGAPauto) -L wsp.g > /dev/null )
( chmod 777 testpackagesload.in; ./testpackagesload.in > \
`date -u +dev/log/testpackagesloadA_%Y-%m-%d-%H-%M`; rm testpackagesload.in )
( rm wsp.g )
( echo 'ReadGapRoot( "tst/testutil.g" ); \
SaveWorkspace( "wsp.g" );' | $(TESTGAPauto) )
( echo 'CreatePackageLoadTestsInput( "testpackagesload.in", \
"testpackagesloadNA", \
"$(TESTGAPauto) -L wsp.g", true, true );'\
| $(TESTGAPauto) -L wsp.g > /dev/null )
( chmod 777 testpackagesload.in; ./testpackagesload.in > \
`date -u +dev/log/testpackagesloadNA_%Y-%m-%d-%H-%M`; rm testpackagesload.in )
( rm wsp.g )
# Produce an overview of new variables defined by each package
testpackagesvars: all
$(MKDIR_P) dev/log
( echo 'ReadGapRoot( "tst/testutil.g" ); \
SaveWorkspace( "wsp.g" );' | $(TESTGAP) )
( echo 'CreatePackageVarsTestsInput( "testpackagesvars.in", \
"dev/log/testpackagesvars", \
"$(TESTGAP) -L wsp.g" );'\
| $(TESTGAP) -L wsp.g > /dev/null )
( chmod 777 testpackagesvars.in; ./testpackagesvars.in > \
`date -u +dev/log/testpackagesvars_%Y-%m-%d-%H-%M`; rm testpackagesvars.in )
( rm wsp.g )
# run teststandard.g twice:
# - without packages (except needed to run GAP)
# - with all packages loaded
teststandard: all
$(MKDIR_P) dev/log
( echo 'SetUserPreference("UseColorsInTerminal",false); \
ReadGapRoot( "tst/teststandard.g" );' | $(TESTGAP) | \
tee `date -u +dev/log/teststandard1_%Y-%m-%d-%H-%M` )
( echo 'SetUserPreference("UseColorsInTerminal",false); LoadAllPackages(); \
ReadGapRoot( "tst/teststandard.g" );' | $(TESTGAP) | \
tee `date -u +dev/log/teststandard2_%Y-%m-%d-%H-%M` )
# run testbugfix.g twice:
# - without packages (except needed to run GAP)
# - with all packages loaded
testbugfix: all
$(MKDIR_P) dev/log
( echo 'SetUserPreference("UseColorsInTerminal",false); \
ReadGapRoot( "tst/testbugfix.g" );' | $(TESTGAP) | \
tee `date -u +dev/log/testbugfix1_%Y-%m-%d-%H-%M` )
( echo 'SetUserPreference("UseColorsInTerminal",false); LoadAllPackages(); \
ReadGapRoot( "tst/testbugfix.g" );' | $(TESTGAP) | \
tee `date -u +dev/log/testbugfix2_%Y-%m-%d-%H-%M` )
coverage:
gcov -o . $(SOURCES)
.PHONY: testinstall testmanuals testobsoletes teststandard testbugfix
.PHONY: testpackage testpackages testpackagesload testpackagesvars
.PHONY: coverage
########################################################################
# Bootstrap rules
########################################################################
# change PKG_BRANCH to stable-X.Y in the stable branch
PKG_BRANCH = master
PKG_BOOTSTRAP_URL = https://www.gap-system.org/pub/gap/gap4pkgs/
PKG_MINIMAL = packages-required-$(PKG_BRANCH).tar.gz
PKG_FULL = packages-$(PKG_BRANCH).tar.gz
WGET = wget -N
bootstrap-pkg-minimal:
@if test -e pkg; then \
echo "The pkg directory already exists. Please move or remove it to proceed."; \
else \
$(WGET) $(PKG_BOOTSTRAP_URL)$(PKG_MINIMAL) && \
mkdir pkg && \
cd pkg && \
tar xzf ../$(PKG_MINIMAL) ; \
fi;
bootstrap-pkg-full:
@if test -e pkg; then \