forked from gap-system/gap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.rules
1323 lines (1098 loc) · 46.2 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 libgap.la
.PHONY: all
# 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/bags.c
SOURCES += src/blister.c
SOURCES += src/bool.c
ifeq ($(HPCGAP),yes)
SOURCES += src/hpc/c_oper1.c
SOURCES += src/hpc/c_type1.c
else
SOURCES += src/c_oper1.c
SOURCES += src/c_type1.c
endif
SOURCES += src/calls.c
SOURCES += src/code.c
SOURCES += src/collectors.cc
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/error.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/gvars.c
SOURCES += src/hookintrprtr.c
SOURCES += src/info.c
SOURCES += src/integer.c
SOURCES += src/intfuncs.c
SOURCES += src/intrprtr.c
SOURCES += src/io.c
SOURCES += src/iostream.c
ifeq ($(HPCGAP),no) # we don't support a kernel API in HPC-GAP atm
SOURCES += src/libgap-api.c
endif
SOURCES += src/listfunc.c
SOURCES += src/listoper.c
SOURCES += src/lists.c
SOURCES += src/macfloat.c
SOURCES += src/modules.c
SOURCES += src/modules_builtin.c
SOURCES += src/objcftl.c
SOURCES += src/objects.c
SOURCES += src/objfgelm.cc
SOURCES += src/objpcgel.cc
SOURCES += src/objset.c
SOURCES += src/opers.c
SOURCES += src/permutat.cc
SOURCES += src/plist.c
SOURCES += src/pperm.cc
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/syntaxtree.c
SOURCES += src/sysfiles.c
SOURCES += src/sysmem.c
SOURCES += src/system.c
SOURCES += src/tietze.c
SOURCES += src/trans.cc
SOURCES += src/vars.c
SOURCES += src/vec8bit.c
SOURCES += src/vecffe.c
SOURCES += src/vecgf2.c
SOURCES += src/vector.c
SOURCES += src/weakptr.c
SOURCES += $(GC_SOURCES)
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/region.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
# The "gen" directory contains generated files and thus is placed into
# the build directory.
GAP_CPPFLAGS += -I$(builddir)/gen
GAP_PKG_CPPFLAGS += -I$(abs_builddir)/gen
# The other source files are relative to the srcdir
GAP_CPPFLAGS += -I$(srcdir)/src
GAP_PKG_CPPFLAGS += -I$(abs_srcdir)/src
# For backwards compatibility with certain packages and their kernel
# extensions, also add the root of the srcdir to the package CPPFLAGS
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 += $(ZLIB_CPPFLAGS)
GAP_CPPFLAGS += $(READLINE_CPPFLAGS)
GAP_CPPFLAGS += $(JULIA_CPPFLAGS)
GAP_CPPFLAGS += $(BOEHM_GC_CPPFLAGS)
GAP_CPPFLAGS += $(LIBATOMIC_OPS_CPPFLAGS)
GAP_PKG_CPPFLAGS += $(GMP_CPPFLAGS)
GAP_PKG_CPPFLAGS += $(ZLIB_CPPFLAGS)
GAP_PKG_CPPFLAGS += $(READLINE_CPPFLAGS)
GAP_PKG_CPPFLAGS += $(JULIA_CPPFLAGS)
GAP_PKG_CPPFLAGS += $(BOEHM_GC_CPPFLAGS)
GAP_PKG_CPPFLAGS += $(LIBATOMIC_OPS_CPPFLAGS)
# Finally add user provided flags
GAP_CPPFLAGS += $(CPPFLAGS)
GAP_PKG_CPPFLAGS += $(CPPFLAGS)
########################################################################
# C compiler flags
########################################################################
GAP_CFLAGS = $(ABI_CFLAGS)
ifeq ($(HPCGAP),yes)
GAP_CFLAGS += $(PTHREAD_CFLAGS)
endif
# Finally add user provided CFLAGS
GAP_CFLAGS += $(CFLAGS)
########################################################################
# C++ compiler flags
########################################################################
GAP_CXXFLAGS = $(ABI_CFLAGS)
ifeq ($(HPCGAP),yes)
GAP_CXXFLAGS += $(PTHREAD_CFLAGS)
endif
# Finally add user provided CXXFLAGS
GAP_CXXFLAGS += $(CXXFLAGS)
########################################################################
# Linker flags
########################################################################
GAP_LDFLAGS = $(ABI_CFLAGS)
# Add flags for dependencies
GAP_LDFLAGS += $(GMP_LDFLAGS)
GAP_LDFLAGS += $(ZLIB_LDFLAGS)
GAP_LDFLAGS += $(READLINE_LDFLAGS)
GAP_LDFLAGS += $(JULIA_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 += $(ZLIB_LIBS)
GAP_LIBS += $(READLINE_LIBS)
GAP_LIBS += $(JULIA_LIBS)
GAP_LIBS += $(BOEHM_GC_LIBS)
GAP_LIBS += $(LIBATOMIC_OPS_LIBS)
# Finally add user provided flags
GAP_LIBS += $(LIBS)
########################################################################
# Object files
########################################################################
# OBJS shall contain the names of all object files that constitute GAP.
# So turn all FOO/*.c and FOO/*.cc file names in SOURCES into obj/FOO/*.lo
OBJS = $(patsubst %.cc,obj/%.lo,$(patsubst %.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_CXX = @echo " CXX $< => $@";
QUIET_LINK = @echo " LINK $@";
QUIET_SED = @echo " SED $< => $@";
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:
# https://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
########################################################################
# HACK: when we rename a file foobar.c to foobar.cc (i.e., only the extension
# is changed from C to C++), then this can cause problems in the .d file, as
# they contain rules which depend on the source file, and that is now gone.
# As a result, one may get errors like this:
#
# make: *** No rule to make target 'src/objpcgel.c', needed by 'obj/src/objpcgel.lo'. Stop.
#
# To avoid this, we simply add an empty rule `foobar.c:` resp. `foobar.cc:`
# to the end of the .d files, via this line in the build rules:
# @echo "$<:" >> $(DEPFILE)
#
# Extra hack: Since old versions of the build system don't have this,
# switching from a build with such an old version to one with a new version
# (e.g. during a `git bisect`) still runs into the above error. To work
# around that, we add a few explicit rules down below, for files that were
# changed from .c to .cc
$(srcdir)/src/objfgelm.c:
$(srcdir)/src/objpcgel.c:
$(srcdir)/src/permutat.c:
$(srcdir)/src/pperm.c:
$(srcdir)/src/trans.c:
# Build rule for C++ source files
obj/%.lo: %.cc cnf/GAP-CXXFLAGS cnf/GAP-CPPFLAGS libtool
@$(MKDIR_P) $(@D)/$(DEPDIRNAME)
$(QUIET_CXX)$(LIBTOOL) --mode=compile --tag CXX $(CXX) $(DEPFLAGS) $(GAP_CXXFLAGS) $(WARN_CXXFLAGS) $(GAP_CPPFLAGS) -c $< -o $@
@echo "$<:" >> $(DEPFILE)
# Build rule for C source files
obj/%.lo: %.c cnf/GAP-CFLAGS cnf/GAP-CPPFLAGS libtool
@$(MKDIR_P) $(@D)/$(DEPDIRNAME)
$(QUIET_CC)$(LIBTOOL) --mode=compile --tag CC $(CC) $(DEPFLAGS) $(GAP_CFLAGS) $(WARN_CFLAGS) $(GAP_CPPFLAGS) -c $< -o $@
@echo "$<:" >> $(DEPFILE)
########################################################################
# 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
# Allow multiple definitions so we can declare a function multiple times with 'extern inline'
GAP_LDFLAGS += -Wl,--allow-multiple-definition
# 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)/src/hpc
else
DOCOMP_PREFIX = $(abs_srcdir)/src
endif
docomp: #gap$(EXEEXT)
@"$(abs_srcdir)"/cnf/GAP-C-GEN $(abs_srcdir)/lib $(DOCOMP_PREFIX) oper1 ./gap$(EXEEXT)
@"$(abs_srcdir)"/cnf/GAP-C-GEN $(abs_srcdir)/lib $(DOCOMP_PREFIX) 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 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,CXXFLAGS,LDFLAGS,LIBS,OBJS}
.PHONY: clean distclean
########################################################################
# Rules for 'make install'
########################################################################
LTINSTALL=$(LIBTOOL) --mode=install $(INSTALL)
install:
@echo "Error, 'make install' has not yet been implemented"
exit 1
install-bin:
@echo "Warning, 'make install-bin' is incomplete"
$(INSTALL) -d -m 0755 $(DESTDIR)$(bindir)
$(INSTALL) -m 0755 gap $(DESTDIR)$(bindir)/gap.real
echo "!/bin/sh\nexec \"$(bindir)/gap.real\" -l \"$(datarootdir)/gap\" \"$@\"" > gap-wrapper.sh
$(INSTALL) -m 0755 gap-wrapper.sh $(DESTDIR)$(bindir)/gap
# TODO: make gac installable; this requires adjusting path in it, and
# installing the libtool script generated by configure somewhere; and then
# putting that path to it into gac)
#$(INSTALL) gac $(DESTDIR)$(bindir)
install-gaproot:
@echo "Warning, 'make install-gaproot' is incomplete"
$(INSTALL) -d -m 0755 $(DESTDIR)$(datarootdir)/gap
# TODO: update paths and FLAGS in sysinfo.gap
$(INSTALL) -m 0644 $(srcdir)/sysinfo.gap $(DESTDIR)$(datarootdir)/gap
# the following lines should not use `cp -r`, which is not quite portable,
# and which also may not deal with file permissions correctly
cp -r $(srcdir)/doc $(DESTDIR)$(datarootdir)/gap/ # FIXME: don't use `cp -r`
cp -r $(srcdir)/grp $(DESTDIR)$(datarootdir)/gap/ # FIXME: don't use `cp -r`
cp -r $(srcdir)/lib $(DESTDIR)$(datarootdir)/gap/ # FIXME: don't use `cp -r`
cp -r $(srcdir)/tst $(DESTDIR)$(datarootdir)/gap/ # FIXME: don't use `cp -r`
# TODO: what about CITATION, CONTRIBUTING.md, COPYRIGHT, INSTALL.md,
# LICENSE, README* ? Copy them also here? Or into some other path?
# TODO: also copy bin/BuildPackage.sh, as it is very useful?
install-pkg:
@echo "Warning, 'make install-pkg' is incomplete"
# TODO: should we try to compiled packages? perhaps better not, leave it
# to the packagers, as they also need to consider build dependencies ?! If
# we do try it, then we may need to deal with adjusting paths and so on...
# we can't really install packages by any other means that copying their
# whole directory... One strategy to overcome this: in the future, we
# demand that packages which must be built using `make` also support
# `make install prefix=DIR DESTDIR=dir`
# and/or allow packages to have a `Install(prefix, destdir)` field in
# their `PackageInfo.g` which contains a function that takes care of
# installation (e.g. by running `make install`, or by any other means).
# This could also be used by the PackageManager package (or perhaps we
# should just use PackageManager ourselves, and/or recommend it to
# packagers).
install-headers:
@echo "Warning, 'make install-headers' is incomplete"
$(INSTALL) -d -m 0755 $(DESTDIR)$(includedir)/gap
$(INSTALL) -m 0644 $(srcdir)/src/*.h $(DESTDIR)$(includedir)/gap
# TODO: run the following only if HPC-GAP is enabled?
$(INSTALL) -d -m 0755 $(DESTDIR)$(includedir)/gap/hpc
$(INSTALL) -m 0644 $(srcdir)/src/hpc/*.h $(DESTDIR)$(includedir)/gap/hpc
# TODO: take care of config.h, this is difficult
install-libgap: libgap.la
@echo "Warning, 'make install-libgap' is incomplete"
$(INSTALL) -d -m 0755 $(DESTDIR)$(libdir)
$(LTINSTALL) libgap.la $(DESTDIR)$(libdir)
.PHONY: install install-bin install-gaproot install-headers 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
#
# ZLIB
#
ifeq ($(BUILD_ZLIB),yes)
ZLIB_BUILDDIR := extern/build/zlib
ZLIB_PREFIX := extern/install/zlib
# ZLIB_PREREQ := $(ZLIB_BUILDDIR)/config.status
ZLIB_FILES := $(ZLIB_PREFIX)/include/zlib.h
EXTERN_FILES += $(ZLIB_FILES)
zlib: $(ZLIB_FILES)
ifeq ($(SYS_IS_CYGWIN32),yes)
$(ZLIB_FILES):
MAKE=$(MAKE) CFLAGS="$(CFLAGS) $(ABI_CFLAGS)" $(srcdir)/cnf/build-cygwin-zlib.sh
else
$(ZLIB_FILES):
MAKE=$(MAKE) CFLAGS="$(CFLAGS) $(ABI_CFLAGS)" $(srcdir)/cnf/build-extern.sh zlib "$(abs_srcdir)/extern/zlib"
endif # SYS_IS_CYGWIN32
.PHONY: zlib
# TODO: add clean, distclean, check targets?
# TODO: pass on cachfile?
# TODO: pass on certain *FLAGS ?
else
zlib:
echo "Using external zlib, nothing to do be done"
endif # BUILD_ZLIB
#
# 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 --enable-large-config
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
# regenerate sysinfo.gap if necessary
all: sysinfo.gap
sysinfo.gap: config.status $(srcdir)/Makefile.rules cnf/GAP-CFLAGS cnf/GAP-CPPFLAGS cnf/GAP-CXXFLAGS 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 "GAP_HPCGAP=$(HPCGAP)" >> $@
@echo "" >> $@
@echo "GAP_KERNEL_MAJOR_VERSION=$(GAP_KERNEL_MAJOR_VERSION)" >> $@
@echo "GAP_KERNEL_MINOR_VERSION=$(GAP_KERNEL_MINOR_VERSION)" >> $@
@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_CXXFLAGS=\"$(GAP_CXXFLAGS)\"" >> $@
@echo "GAP_CPPFLAGS=\"$(GAP_PKG_CPPFLAGS)\"" >> $@
@echo "GAP_LDFLAGS=\"$(GAP_LDFLAGS)\"" >> $@
@echo "GAP_LIBS=\"$(GAP_LIBS)\"" >> $@
@echo "" >> $@
@echo "GAP_OBJS=\"$(OBJS)\"" >> $@
@echo "" >> $@
@echo "JULIA=\"$(JULIA)\"" >> $@
@echo "JULIA_CPPFLAGS=\"$(JULIA_CPPFLAGS)\"" >> $@
@echo "JULIA_LDFLAGS=\"$(JULIA_LDFLAGS)\"" >> $@
@echo "JULIA_LIBS=\"$(JULIA_LIBS)\"" >> $@
########################################################################
# 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 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
html: gap$(EXEEXT) doc/make_doc
doc/make_doc nopdf
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) | \
tee `date -u +../../dev/log/check_manuals_%Y-%m-%d-%H-%M` )
.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); \
SetUserPreference("ReproducibleBehaviour", true); \
ReadGapRoot( "tst/testinstall.g" );' | $(TESTGAP) | \
tee `date -u +dev/log/testinstall1_%Y-%m-%d-%H-%M` )
( echo 'SetUserPreference("UseColorsInTerminal",false); LoadAllPackages(); \
SetUserPreference("ReproducibleBehaviour", true); \
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 ); \
SetUserPreference("ReproducibleBehaviour", true); \
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 ); \
SetUserPreference("ReproducibleBehaviour", true); \
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 ); \
SetUserPreference("ReproducibleBehaviour", true); \
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 ); \
SetUserPreference("ReproducibleBehaviour", true); \
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() ; \
SetUserPreference("ReproducibleBehaviour", true); \
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() ; \
SetUserPreference("ReproducibleBehaviour", true); \
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 )