-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathGNUmakefile.in
177 lines (154 loc) · 6.51 KB
/
GNUmakefile.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
# GNUmakefile.in: Standard-complying wrapper for gprbuild and install.
# Copyright (C) 2024 streaksu
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Nuke built-in rules and variables.
MAKEFLAGS += -rR
.SUFFIXES:
# Macros to make our build system still work from within paths with spaces
# or other special characters.
override SPACE := $(subst ,, )
override MKESCAPE = $(subst $(SPACE),\ ,$(1))
override SHESCAPE = $(subst ','\'',$(1))
# Import some autoconf variables as make variables.
override SRCDIR := @SRCDIR@
override PACKAGE_VERSION := @PACKAGE_VERSION@
override PACKAGE_TARNAME := @PACKAGE_TARNAME@
override OUTPUT := $(PACKAGE_TARNAME)
override DIST_OUTPUT := $(PACKAGE_TARNAME)-$(PACKAGE_VERSION)
# Take care of reproducible dates.
override SOURCE_DATE_EPOCH := @SOURCE_DATE_EPOCH@
export SOURCE_DATE_EPOCH
# Autoconf dir variables.
prefix := @prefix@
datarootdir := @datarootdir@
infodir := @infodir@
# Generator executables.
MKDIR_P := @MKDIR_P@
INSTALL := @INSTALL@
INSTALL_DATA := @INSTALL_DATA@
GREP := @GREP@
SED := @SED@
MAKEINFO := @MAKEINFO@
TEXI2HTML := @TEXI2HTML@
TEXI2DVI := @TEXI2DVI@
GPRBUILD := @GPRBUILD@
GNATPROVE := @GNATPROVE@
OBJDUMP := @OBJDUMP@
STRIP := @STRIP@
# Target information.
GPRBUILD_TARGET := @GPRBUILD_TARGET@
override host_cpu := @host_cpu@
override PLATFORM := @PLATFORM@
# Attempt to get the job count from the make command line.
override PARALLELISM := $(shell ps T | $(SED) -n 's%.*'$$PPID'.*$(MAKE).* \(-j\|--jobs\|--jobs=\) *\([0-9][0-9]*\).*%\2%p')
ifeq ($(PARALLELISM),)
override PARALLELISM := 1
endif
# Get a list of Ada source files to determine when to rebuild.
override RTSFILES := $(shell LC_ALL=C find -L '$(call SHESCAPE,$(SRCDIR))/source/rts' -type f | $(SED) 's| |\\ |g')
override ADAFILES := $(shell LC_ALL=C find -L '$(call SHESCAPE,$(SRCDIR))/source' -type f | $(GREP) -v rts | $(SED) 's| |\\ |g')
###############################################################################
# Rules for generating executables, documentation, and other artifacts.
.PHONY: all
all: $(OUTPUT) info
rtsdir/adalib/libgnat.a: GNUmakefile $(RTSFILES)
rm -rf rtsdir
$(MKDIR_P) rtsdir/adalib
$(MKDIR_P) rtsdir/adainclude
cp '$(call SHESCAPE,$(SRCDIR))'/source/rts/*.adb rtsdir/adainclude/
cp '$(call SHESCAPE,$(SRCDIR))'/source/rts/*.ads rtsdir/adainclude/
cp '$(call SHESCAPE,$(SRCDIR))'/source/rts/$(host_cpu)-$(PLATFORM)/*.ads rtsdir/adainclude/
$(GPRBUILD) -P ./rts.gpr \
--target=$(GPRBUILD_TARGET) --db- --db ./gprconfig \
-j$(PARALLELISM)
$(OUTPUT): GNUmakefile rtsdir/adalib/libgnat.a $(ADAFILES)
$(GPRBUILD) --RTS=./rtsdir \
--target=$(GPRBUILD_TARGET) --db- --db ./gprconfig \
-P ./ironclad.gpr -j$(PARALLELISM)
.PHONY: info
info: ironclad.info
ironclad.info: $(call MKESCAPE,$(SRCDIR))/docs/ironclad.texi GNUmakefile
$(MAKEINFO) '$(call SHESCAPE,$<)' -o $@
.PHONY: html
html: ironclad.html
ironclad.html: $(call MKESCAPE,$(SRCDIR))/docs/ironclad.texi GNUmakefile
$(TEXI2HTML) --set-customization-variable 'HIGHLIGHT_SYNTAX highlight' '$(call SHESCAPE,$<)' -o $@
.PHONY: dvi
dvi: ironclad.dvi
ironclad.dvi: $(call MKESCAPE,$(SRCDIR))/docs/ironclad.texi GNUmakefile
$(TEXI2DVI) '$(call SHESCAPE,$<)' -o $@
###############################################################################
# Rules for checks and formal verification.
.PHONY: check
check: check-rts check-kernel
.PHONY: check-rts
check-rts: rtsdir/adalib/libgnat.a
$(GNATPROVE) -U --level=4 --mode=all --counterexamples=on \
-j$(PARALLELISM) -P ./rts.gpr
.PHONY: check-kernel
check-kernel: rtsdir/adalib/libgnat.a
$(GNATPROVE) -U --level=4 --mode=all --counterexamples=on \
--RTS=./rtsdir -j$(PARALLELISM) -P ./ironclad.gpr
###############################################################################
# Rules for cleaning build and configuration artifacts.
.PHONY: clean
clean:
rm -rf $(OUTPUT) obj gnatprove rtsdir \
ironclad.info ironclad.html ironclad.dvi ironclad.log ironclad.toc \
ironclad.aux
# Remove files generated by configure.
.PHONY: distclean
distclean: clean
rm -rf config.log config.status GNUmakefile ironclad.gpr rts.gpr gprconfig/*.xml
.PHONY: maintainer-clean
maintainer-clean: distclean
cd '$(call SHESCAPE,$(SRCDIR))' && rm -rf configure build-aux *'~' autom4te.cache freestnd-c-hdrs cc-runtime uacpi-repository uacpi
###############################################################################
# Create a release tarball.
.PHONY: dist
dist:
rm -rf "$(DIST_OUTPUT)"
$(MKDIR_P) "$(DIST_OUTPUT)"
cp -rp '$(call SHESCAPE,$(SRCDIR))'/.git "$(DIST_OUTPUT)"/
cd "$(DIST_OUTPUT)" && git checkout .
cd "$(DIST_OUTPUT)" && ./bootstrap
rm -rf "$(DIST_OUTPUT)"/.git
rm -rf "$(DIST_OUTPUT)"/.gitignore
rm -rf "$(DIST_OUTPUT)"/.mailmap
rm -rf "$(DIST_OUTPUT)"/autom4te.cache
rm -rf "$(DIST_OUTPUT)"/cc-runtime/.git
rm -rf "$(DIST_OUTPUT)"/cc-runtime/.gitignore
rm -rf "$(DIST_OUTPUT)"/uacpi-repository
echo "$(PACKAGE_VERSION)" >"$(DIST_OUTPUT)"/version
tar -zcf "$(DIST_OUTPUT)".tar.gz "$(DIST_OUTPUT)"
rm -rf "$(DIST_OUTPUT)"
###############################################################################
# Install artifacts and other files to their final locations.
.PHONY: install
install: all
$(INSTALL) -d '$(call SHESCAPE,$(DESTDIR)$(infodir))'
$(INSTALL) -d '$(call SHESCAPE,$(DESTDIR)$(datarootdir))/$(PACKAGE_TARNAME)'
$(INSTALL_DATA) $(OUTPUT) '$(call SHESCAPE,$(DESTDIR)$(datarootdir))/$(PACKAGE_TARNAME)/'
$(INSTALL_DATA) ironclad.info '$(call SHESCAPE,$(DESTDIR)$(infodir))/'
# Install and strip executables.
.PHONY: install-strip
install-strip: install
$(STRIP) '$(call SHESCAPE,$(DESTDIR)$(datarootdir))/$(PACKAGE_TARNAME)/$(OUTPUT)'
###############################################################################
# Uninstall previously installed files and executables.
.PHONY: uninstall
uninstall:
rm -rf '$(call SHESCAPE,$(DESTDIR)$(datarootdir))/$(PACKAGE_TARNAME)'
rm -f '$(call SHESCAPE,$(DESTDIR)$(infodir))/ironclad.info'