| 1 |
#!/usr/bin/make -f |
| 2 |
# Build script for XML/Ada in Debian. |
| 3 |
# Copyright (c) 2003-2009 Ludovic Brenta <[email protected]> |
| 4 |
# Copyright (c) 2013-2023 Nicolas Boulenguez <[email protected]> |
| 5 |
|
| 6 |
# This program is free software; you can redistribute it and/or modify |
| 7 |
# it under the terms of the GNU General Public License as published by |
| 8 |
# the Free Software Foundation; either version 3 of the License, or |
| 9 |
# (at your option) any later version. |
| 10 |
|
| 11 |
# This program is distributed in the hope that it will be useful, but |
| 12 |
# WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 |
# General Public License for more details. |
| 15 |
|
| 16 |
# On Debian systems, the full text of the GPL is in the file |
| 17 |
# /usr/share/common-licenses/GPL-3. |
| 18 |
|
| 19 |
# NOTE: |
| 20 |
# In order to prevent a circular build-dependency, the Debian packages |
| 21 |
# for XML/Ada and GPRBuild bother to build without project support. |
| 22 |
# Please keep the two debian/rules files similar enough to ease |
| 23 |
# backport of good ideas. |
| 24 |
|
| 25 |
###################################################################### |
| 26 |
|
| 27 |
DEB_BUILD_MAINT_OPTIONS := hardening=+all |
| 28 |
DEB_ADAFLAGS_MAINT_APPEND := -gnatwa -Wall -gnatafno -gnatVa |
| 29 |
DEB_LDFLAGS_MAINT_APPEND := \ |
| 30 |
-Wl,--no-undefined \ |
| 31 |
-Wl,--no-copy-dt-needed-entries \ |
| 32 |
-Wl,--no-allow-shlib-undefined |
| 33 |
include /usr/share/dpkg/buildflags.mk |
| 34 |
include /usr/share/dpkg/buildopts.mk |
| 35 |
include $(wildcard /usr/share/ada/packaging.mk) |
| 36 |
# wildcard in case only Build-Depends-Indep are installed. |
| 37 |
|
| 38 |
# Ignore gnat.adc in top directory. |
| 39 |
GNATMAKEFLAGS += -gnatA |
| 40 |
|
| 41 |
###################################################################### |
| 42 |
%: |
| 43 |
dh $@ |
| 44 |
|
| 45 |
# Rewrite upstream configure/make build system. |
| 46 |
.PHONY: $(addprefix override_dh_auto_, \ |
| 47 |
configure build-arch build-indep test install-arch install-indep clean) |
| 48 |
|
| 49 |
# Rewrite upstream targets without gprbuild or gprclean. |
| 50 |
# gnatmake does not support projects anymore, we cannot use xmlada.gpr. |
| 51 |
# The priority is to bootstrap, not a complete dependency graph. |
| 52 |
|
| 53 |
###################################################################### |
| 54 |
# Rewrite unicode/importer/Makefile without network and gprbuild. |
| 55 |
# Generate the unicode-names-*.ads before the override_dh_auto_build |
| 56 |
# phase so that wildcard below sees the generated files. |
| 57 |
override_dh_auto_build-arch:: |
| 58 |
mkdir -p obj unicode/importer/generated |
| 59 |
gnatmake unicode/importer/convert.adb -D obj -o obj/convert \ |
| 60 |
$(GNATMAKEFLAGS) \ |
| 61 |
-cargs $(ADAFLAGS) \ |
| 62 |
-largs $(LDFLAGS) |
| 63 |
cd unicode/importer && ../../obj/convert \ |
| 64 |
/usr/share/unicode/Blocks.txt \ |
| 65 |
/usr/share/unicode/NameAliases.txt \ |
| 66 |
/usr/share/unicode/UnicodeData.txt |
| 67 |
rm -f unicode/unicode-names-*.ads |
| 68 |
mv unicode/importer/generated/unicode-names-*.ads unicode |
| 69 |
|
| 70 |
###################################################################### |
| 71 |
|
| 72 |
# For source directories (-aI) and ALI directories (-aO), blindly list |
| 73 |
# all build dependencies and append each library once it is |
| 74 |
# built. This does not hurt, and covers all direct and indirect |
| 75 |
# dependencies. |
| 76 |
|
| 77 |
# For installed shared libraries (-l) and locally built shared |
| 78 |
# objects), the same strategy works thanks to --as-needed, which is |
| 79 |
# the default since gcc-9, provided a proper ordering. |
| 80 |
|
| 81 |
# Libraries provided by Ada -dev packages in Build-Depends. |
| 82 |
ada_build_deps := |
| 83 |
|
| 84 |
# These list grow each time the template is expanded. |
| 85 |
gnatmakeflags := $(GNATMAKEFLAGS) \ |
| 86 |
$(ada_build_deps:%=-aI/$(DEB_ADA_SOURCE_DIR)/%) \ |
| 87 |
$(ada_build_deps:%=-aO/$(DEB_ADA_LIB_INFO_DIR)/%) |
| 88 |
shared_objects_so_far := $(ada_build_deps:%=-l%) \ |
| 89 |
-lgnarl-$(DEB_GNAT_VERSION) \ |
| 90 |
-lgnat-$(DEB_GNAT_VERSION) |
| 91 |
|
| 92 |
define library_template |
| 93 |
# Parameters: |
| 94 |
# _SRCDIR: directory containing the sources files |
| 95 |
# _SO_VERSION : part of the shared object name |
| 96 |
# _imported_projects: for the generated project. |
| 97 |
|
| 98 |
override_dh_auto_build-arch:: |
| 99 |
|
| 100 |
mkdir -p obj/shared_$1 obj/static_$1 |
| 101 |
|
| 102 |
# Build dynamic library. |
| 103 |
# -fPIC/-shared overrides -fPIE/-pie in ADAFLAGS/LDFLAGS. |
| 104 |
gnatmake -c `grep -L '^separate ' $($1_SRCDIR)/*.ad[bs] | grep -v __` \ |
| 105 |
$(gnatmakeflags) -D obj/shared_$1 -cargs $(ADAFLAGS) -fPIC |
| 106 |
gcc-$(DEB_GNAT_VERSION) -shared \ |
| 107 |
-o obj/lib$1.so.$($1_SO_VERSION) \ |
| 108 |
-Wl,-soname,lib$1.so.$($1_SO_VERSION) \ |
| 109 |
$(LDFLAGS) obj/shared_$1/*.o $(shared_objects_so_far) |
| 110 |
|
| 111 |
# Mark ALI files as read-only. |
| 112 |
chmod 444 obj/shared_$1/*.ali |
| 113 |
|
| 114 |
# Build static library. |
| 115 |
gnatmake -c `grep -L '^separate ' $($1_SRCDIR)/*.ad[bs] | grep -v __` \ |
| 116 |
$(gnatmakeflags) -D obj/static_$1 -cargs $(ADAFLAGS) |
| 117 |
ar rc obj/lib$1.a obj/static_$1/*.o |
| 118 |
ranlib obj/lib$1.a |
| 119 |
|
| 120 |
# Externally built project installed for end users. |
| 121 |
sed ' \ |
| 122 |
/@IMPORTS@/ { \ |
| 123 |
s//$($1_imported_projects:%=with "%.gpr";\n)/; \ |
| 124 |
s/\n /\n/g; }; \ |
| 125 |
s/@library@/$1/; \ |
| 126 |
s|@DEB_LIB_DIR@|$(DEB_LIB_DIR)|; \ |
| 127 |
s|@DEB_ADA_SOURCE_DIR@|$(DEB_ADA_SOURCE_DIR)|; \ |
| 128 |
s|@DEB_ADA_LIB_INFO_DIR@|$(DEB_ADA_LIB_INFO_DIR)|; \ |
| 129 |
' debian/template.gpr > obj/$1.gpr |
| 130 |
|
| 131 |
override_dh_auto_install-arch:: |
| 132 |
install -m644 -Dtdebian/tmp/$(DEB_ADA_SOURCE_DIR)/$1 $($1_SRCDIR)/*.ad[bs] |
| 133 |
install -m444 -Dtdebian/tmp/$(DEB_ADA_LIB_INFO_DIR)/$1 obj/shared_$1/*.ali |
| 134 |
install -m644 -Dtdebian/tmp/$(DEB_GNAT_PROJECT_DIR) obj/$1.gpr |
| 135 |
install -m644 -Dtdebian/tmp/$(DEB_LIB_DIR) \ |
| 136 |
obj/lib$1.so.$($1_SO_VERSION) obj/lib$1.a |
| 137 |
ln -fs lib$1.so.$($1_SO_VERSION) debian/tmp/$(DEB_LIB_DIR)/lib$1.so |
| 138 |
|
| 139 |
gnatmakeflags += -aI$($1_SRCDIR) -aOobj/shared_$1 |
| 140 |
shared_objects_so_far := obj/lib$1.so.$($1_SO_VERSION) \ |
| 141 |
$(shared_objects_so_far) |
| 142 |
endef |
| 143 |
|
| 144 |
xmlada_unicode_SRCDIR := unicode |
| 145 |
$(eval $(call library_template,xmlada_unicode)) |
| 146 |
|
| 147 |
xmlada_input_SRCDIR := input_sources |
| 148 |
xmlada_input_imported_projects := xmlada_unicode |
| 149 |
$(eval $(call library_template,xmlada_input)) |
| 150 |
|
| 151 |
xmlada_sax_SRCDIR := sax |
| 152 |
xmlada_sax_imported_projects := xmlada_input xmlada_unicode |
| 153 |
$(eval $(call library_template,xmlada_sax)) |
| 154 |
|
| 155 |
xmlada_dom_SRCDIR := dom |
| 156 |
xmlada_dom_imported_projects := xmlada_sax xmlada_unicode |
| 157 |
$(eval $(call library_template,xmlada_dom)) |
| 158 |
|
| 159 |
xmlada_schema_SRCDIR := schema |
| 160 |
xmlada_schema_imported_projects := xmlada_dom xmlada_sax xmlada_unicode |
| 161 |
$(eval $(call library_template,xmlada_schema)) |
| 162 |
|
| 163 |
###################################################################### |
| 164 |
override_dh_auto_build-indep: |
| 165 |
ifeq (,$(filter nodoc,$(DEB_BUILD_OPTIONS))) |
| 166 |
$(MAKE) -Cdocs html latexpdf text \ |
| 167 |
$(DEB_BUILD_OPTION_PARALLEL:%=SPHINXOPTS=-j%) |
| 168 |
endif |
| 169 |
|
| 170 |
# Compatibility project, importing all XMLAda libraries. |
| 171 |
execute_after_dh_install-arch: |
| 172 |
dh_install --package=libxmlada-schema-dev \ |
| 173 |
distrib/xmlada.gpr \ |
| 174 |
$(DEB_GNAT_PROJECT_DIR) |