-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathMakefile.gappkg
97 lines (83 loc) · 3.4 KB
/
Makefile.gappkg
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
########################################################################
#
# The build rules in this file are intended for use by GAP packages that
# want to build a simple GAP kernel extensions. They are based on the
# GAP build system, and require GNU make. To use this in your GAP
# package, `include` this file from your primary Makefile. You must also
# set several variables beforehand:
#
# - GAPPATH must be set to the location of the GAP installation against
# which to build your package.
# - KEXT_NAME should be the name of your kernel extension (without
# file extensions like .so or .dll)
# - KEXT_SOURCES must contain a list of .c or .cc files to be linked
# into your kernel extension
# - optionally, you can set KEXT_CFLAGS, KEXT_CXXFLAGS, KEXT_LDFLAGS
#
# The contents of this file are released into the public domain; hence
# you may edit this file as you wish, bundle and distribute it with your
# package, etc.
#
# If you bundle this file with your package, please try not to edit it,
# so that we can keep it identical across all GAP packages. Instead, if
# you find that you must edit it, please submit your changes back to
# the GAP team, so that a future version of this file can be adjusted
# to cover your usecase without modifications, thus ensuring you can
# always easily update to newer version of it.
#
########################################################################
# read GAP's build settings
include $(GAPPATH)/sysinfo.gap
# hack to support GAP <= 4.9
ifndef GAP_KERNEL_MAJOR_VERSION
KEXT_CFLAGS += -I$(GAP_LIB_DIR)/src
KEXT_CXXFLAGS += -I$(GAP_LIB_DIR)/src
endif
# honor user supplied flags
ALL_CFLAGS := $(KEXT_CFLAGS) $(KEXT_CXXFLAGS) $(CPPFLAGS) $(CFLAGS) $(CXXFLAGS)
ALL_LDFLAGS := $(KEXT_LDFLAGS) $(LDFLAGS)
# various derived settings
KEXT_BINARCHDIR = bin/$(GAParch)
KEXT_SO = $(KEXT_BINARCHDIR)/$(KEXT_NAME).so
# the following settings are provided by sysinfo.gap in GAP >= 4.12;
# for compatibility with older GAP version (at least 4.9, 4.10, 4.11)
# we try to "guess" suitable values here
GAP ?= $(GAPPATH)/gap
GAC ?= $(GAPPATH)/gac
GAP_OBJEXT ?= lo
# default target
all: $(KEXT_SO)
.PHONY: all
########################################################################
# 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_GAC = @echo " GAC $< => $@";>/dev/null # keep the trailing space!
endif
endif
# build rule for compiling and linking all object files together into a kernel extension
$(KEXT_SO): $(KEXT_SOURCES) Makefile
$(QUIET_GAC)$(GAC) -d -p "$(ALL_CFLAGS)" -P "$(ALL_LDFLAGS)" $(KEXT_SOURCES) -o $@
clean:
rm -rf $(KEXT_BINARCHDIR)
distclean:
rm -rf bin Makefile
rm -rf doc/_*.xml
rm -rf doc/*.aux doc/*.bbl doc/*.blg doc/*.brf doc/*.idx doc/*.idx
rm -rf doc/*.ilg doc/*.ind doc/*.log doc/*.out doc/*.pnr doc/*.toc
doc:
$(GAP) --quitonbreak -b -q < makedoc.g
# re-run configure if configure, Makefile.in or GAP itself changed
Makefile: configure Makefile.in $(GAPPATH)/sysinfo.gap
./configure "$(GAPPATH)"
.PHONY: check clean distclean doc
########################################################################
# Makefile debugging trick:
# call print-VARIABLE to see the runtime value of any variable
########################################################################
print-%:
@echo '$*=$($*)'