File: rules

package info (click to toggle)
asis 2015-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 13,640 kB
  • sloc: ada: 140,372; makefile: 260; sh: 50; xml: 48; csh: 10
file content (112 lines) | stat: -rwxr-xr-x 4,499 bytes parent folder | download
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
#! /usr/bin/make -rf
# Debian build script for asis
# Copyright (c) 2003-2014 Ludovic Brenta <lbrenta@debian.org>
# Copyright (c) 2013-2016 Nicolas Boulenguez <nicolas@debian.org>

# This build script is free software; you can redistribute it and/or
# modify it under terms of the GNU General Public License as published
# by the Free Software Foundation; either version 3, or (at your
# option) any later version. This build script 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
# distributed with this build script; see file
# /usr/share/common-licenses/GPL. If not, see <http://www.gnu.org/licenses/>.

DEB_BUILD_MAINT_OPTIONS=hardening=+all,-pie
# PIE should only affect the tools.
include /usr/share/dpkg/default.mk
include /usr/share/ada/debian_packaging*.mk

DEB_DATE := $(shell dpkg-parsechangelog -S date)

ADAFLAGS += -gnatfno -gnatwa -gnatVa

soversion := $(shell sed -n -e "s/^Package: libasis\([[:digit:]]\+\)$$/\1/p" debian/control)
ifndef soversion
  $(warning Could not guess soversion from debian/control)
endif

BUILDER_OPTIONS := $(subst -j,-XPROCESSORS=,$(BUILDER_OPTIONS))

######################################################################
POLICY_TARGETS := binary binary-arch binary-indep build build-arch \
  build-indep clean
.PHONY: $(POLICY_TARGETS)
$(POLICY_TARGETS):
	dh $@ --with ada-library

# Ignore upstream Makefile/configure.
.PHONY: $(addprefix override_dh_auto_,configure build-arch build-indep test install clean)

######################################################################
# Build dynamic and static versions of the library.
# Import the dynamic version of the library and build each tool.
ALL_TOOLS := \
  asistant gnat2xml gnatcheck gnatelim gnatmetric gnatpp gnatstub gnattest
# Only this selection will be built and installed.
# gnat2xml, gnatmetric and gnatppp miss asis_ul-driver.ads.
# gnattest misses gnattest-aggregator.ads
TOOLS := asistant gnatcheck gnatelim gnatstub

override_dh_auto_build-arch: build-asis-dynamic \
                             build-asis-static \
                             $(addprefix build-,$(TOOLS))

.PHONY: build-asis-dynamic build-asis-static
build-asis-dynamic build-asis-static: build-asis-%: | lib-% obj-%
	gprbuild -XLIBRARY_KIND=$* asis.gpr $(BUILDER_OPTIONS) \
	  $(foreach v,ADAFLAGS LDFLAGS soversion,"-X$(v)=$($(v))")
lib-dynamic lib-static obj-dynamic obj-static:
	mkdir $@
override_dh_auto_clean::
	rm -fr lib-dynamic lib-static obj-dynamic obj-static

BUILD_TOOLS := $(addprefix build-,$(ALL_TOOLS))
.PHONY: $(BUILD_TOOLS)
$(BUILD_TOOLS): ADAFLAGS += -fPIE
$(BUILD_TOOLS): LDFLAGS += -fPIE
$(BUILD_TOOLS): build-%: build-asis-dynamic
	gprbuild -XLIBRARY_KIND=dynamic tools/$*/$*.gpr $(EXECUTABLE) $(BUILDER_OPTIONS) \
	  $(foreach v,ADAFLAGS LDFLAGS soversion,"-X$(v)=$($(v))")
override_dh_auto_clean::
	rm -f $(foreach tool,$(ALL_TOOLS),$(addprefix tools/$(tool)/, \
	  *.ali *.o $(tool) auto.cgpr $(tool)-driver.bexch b__$(tool)-driver.ad[bs]))
	rm -f tools/tool_utils/*.ali tools/tool_utils/*.o

# Ensure deterministic timestamps in ALI files even for patched sources.
TOUCHED_TOO_MUCH := \
 asis/a4g-a_opt.ads \
 asis/a4g-gnat_int.adb \
 asis/a4g-ee_cache.adb \
 asis/a4g-contt.adb \
 asis/a4g-mapping.adb
build-asis-dynamic: deterministic-timestamps-in-ali-files-stamp
deterministic-timestamps-in-ali-files-stamp:
	touch --date='$(DEB_DATE)' $(TOUCHED_TOO_MUCH)
	touch $@

# For now, restrict gnat2xml.gpr to one executable. See asis-doc.TODO.
build-gnat2xml: EXECUTABLE := gnat2xml-driver.adb
# gnat2xml has its own object directory.
build-gnat2xml: | tools/gnat2xml/obj
tools/gnat2xml/obj:
	mkdir -p $@
override_dh_auto_clean::
	rm -fr tools/gnat2xml/obj

# Restrict gnatcheck to one executable. -docgen seems unusable in this
# archive, it relies on a texinfo source per rule.
build-gnatcheck: EXECUTABLE := gnatcheck-driver.adb

######################################################################
.PHONY: override_dh_install
override_dh_install:
	dh_install --package=asis-programs $(foreach t,$(TOOLS),tools/$(t)/$(t)) usr/bin
	dh_install --remaining-packages

.PHONY: override_dh_installman
override_dh_installman:
	dh_installman --package=asis-programs $(foreach t,$(TOOLS),debian/man/$(t).1)
	dh_installman --remaining-packages