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
|
#!/usr/bin/make -f
# Build script for XML/Ada in Debian.
# Copyright (c) 2003-2009 Ludovic Brenta <lbrenta@debian.org>
# Copyright (c) 2013-2023 Nicolas Boulenguez <nicolas@debian.org>
# 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.
# On Debian systems, the full text of the GPL is in the file
# /usr/share/common-licenses/GPL-3.
# NOTE:
# In order to prevent a circular build-dependency, the Debian packages
# for XML/Ada and GPRBuild bother to build without project support.
# Please keep the two debian/rules files similar enough to ease
# backport of good ideas.
######################################################################
DEB_BUILD_MAINT_OPTIONS := hardening=+all
DEB_ADAFLAGS_MAINT_APPEND := -gnatwa -Wall -gnatafno -gnatVa
DEB_LDFLAGS_MAINT_APPEND := \
-Wl,--no-undefined \
-Wl,--no-copy-dt-needed-entries \
-Wl,--no-allow-shlib-undefined
include /usr/share/dpkg/buildflags.mk
include /usr/share/dpkg/buildopts.mk
include $(wildcard /usr/share/ada/packaging.mk)
# wildcard in case only Build-Depends-Indep are installed.
# Ignore gnat.adc in top directory.
GNATMAKEFLAGS += -gnatA
######################################################################
%:
dh $@
# Rewrite upstream configure/make build system.
.PHONY: $(addprefix override_dh_auto_, \
configure build-arch build-indep test install-arch install-indep clean)
# Rewrite upstream targets without gprbuild or gprclean.
# gnatmake does not support projects anymore, we cannot use xmlada.gpr.
# The priority is to bootstrap, not a complete dependency graph.
######################################################################
# Rewrite unicode/importer/Makefile without network and gprbuild.
# Generate the unicode-names-*.ads before the override_dh_auto_build
# phase so that wildcard below sees the generated files.
override_dh_auto_build-arch::
mkdir -p obj unicode/importer/generated
gnatmake unicode/importer/convert.adb -D obj -o obj/convert \
$(GNATMAKEFLAGS) \
-cargs $(ADAFLAGS) \
-largs $(LDFLAGS)
cd unicode/importer && ../../obj/convert \
/usr/share/unicode/Blocks.txt \
/usr/share/unicode/NameAliases.txt \
/usr/share/unicode/UnicodeData.txt
rm -f unicode/unicode-names-*.ads
mv unicode/importer/generated/unicode-names-*.ads unicode
######################################################################
# For source directories (-aI) and ALI directories (-aO), blindly list
# all build dependencies and append each library once it is
# built. This does not hurt, and covers all direct and indirect
# dependencies.
# For installed shared libraries (-l) and locally built shared
# objects), the same strategy works thanks to --as-needed, which is
# the default since gcc-9, provided a proper ordering.
# Libraries provided by Ada -dev packages in Build-Depends.
ada_build_deps :=
# These list grow each time the template is expanded.
gnatmakeflags := $(GNATMAKEFLAGS) \
$(ada_build_deps:%=-aI/$(DEB_ADA_SOURCE_DIR)/%) \
$(ada_build_deps:%=-aO/$(DEB_ADA_LIB_INFO_DIR)/%)
shared_objects_so_far := $(ada_build_deps:%=-l%) \
-lgnarl-$(DEB_GNAT_VERSION) \
-lgnat-$(DEB_GNAT_VERSION)
define library_template
# Parameters:
# _SRCDIR: directory containing the sources files
# _SO_VERSION : part of the shared object name
# _imported_projects: for the generated project.
override_dh_auto_build-arch::
mkdir -p obj/shared_$1 obj/static_$1
# Build dynamic library.
# -fPIC/-shared overrides -fPIE/-pie in ADAFLAGS/LDFLAGS.
gnatmake -c `grep -L '^separate ' $($1_SRCDIR)/*.ad[bs] | grep -v __` \
$(gnatmakeflags) -D obj/shared_$1 -cargs $(ADAFLAGS) -fPIC
gcc-$(DEB_GNAT_VERSION) -shared \
-o obj/lib$1.so.$($1_SO_VERSION) \
-Wl,-soname,lib$1.so.$($1_SO_VERSION) \
$(LDFLAGS) obj/shared_$1/*.o $(shared_objects_so_far)
# Mark ALI files as read-only.
chmod 444 obj/shared_$1/*.ali
# Build static library.
gnatmake -c `grep -L '^separate ' $($1_SRCDIR)/*.ad[bs] | grep -v __` \
$(gnatmakeflags) -D obj/static_$1 -cargs $(ADAFLAGS)
ar rc obj/lib$1.a obj/static_$1/*.o
ranlib obj/lib$1.a
# Externally built project installed for end users.
sed ' \
/@IMPORTS@/ { \
s//$($1_imported_projects:%=with "%.gpr";\n)/; \
s/\n /\n/g; }; \
s/@library@/$1/; \
s|@DEB_LIB_DIR@|$(DEB_LIB_DIR)|; \
s|@DEB_ADA_SOURCE_DIR@|$(DEB_ADA_SOURCE_DIR)|; \
s|@DEB_ADA_LIB_INFO_DIR@|$(DEB_ADA_LIB_INFO_DIR)|; \
' debian/template.gpr > obj/$1.gpr
override_dh_auto_install-arch::
install -m644 -Dtdebian/tmp/$(DEB_ADA_SOURCE_DIR)/$1 $($1_SRCDIR)/*.ad[bs]
install -m444 -Dtdebian/tmp/$(DEB_ADA_LIB_INFO_DIR)/$1 obj/shared_$1/*.ali
install -m644 -Dtdebian/tmp/$(DEB_GNAT_PROJECT_DIR) obj/$1.gpr
install -m644 -Dtdebian/tmp/$(DEB_LIB_DIR) \
obj/lib$1.so.$($1_SO_VERSION) obj/lib$1.a
ln -fs lib$1.so.$($1_SO_VERSION) debian/tmp/$(DEB_LIB_DIR)/lib$1.so
gnatmakeflags += -aI$($1_SRCDIR) -aOobj/shared_$1
shared_objects_so_far := obj/lib$1.so.$($1_SO_VERSION) \
$(shared_objects_so_far)
endef
xmlada_unicode_SRCDIR := unicode
$(eval $(call library_template,xmlada_unicode))
xmlada_input_SRCDIR := input_sources
xmlada_input_imported_projects := xmlada_unicode
$(eval $(call library_template,xmlada_input))
xmlada_sax_SRCDIR := sax
xmlada_sax_imported_projects := xmlada_input xmlada_unicode
$(eval $(call library_template,xmlada_sax))
xmlada_dom_SRCDIR := dom
xmlada_dom_imported_projects := xmlada_sax xmlada_unicode
$(eval $(call library_template,xmlada_dom))
xmlada_schema_SRCDIR := schema
xmlada_schema_imported_projects := xmlada_dom xmlada_sax xmlada_unicode
$(eval $(call library_template,xmlada_schema))
######################################################################
override_dh_auto_build-indep:
ifeq (,$(filter nodoc,$(DEB_BUILD_OPTIONS)))
$(MAKE) -Cdocs html latexpdf text \
$(DEB_BUILD_OPTION_PARALLEL:%=SPHINXOPTS=-j%)
endif
# Compatibility project, importing all XMLAda libraries.
execute_after_dh_install-arch:
dh_install --package=libxmlada-schema-dev \
distrib/xmlada.gpr \
$(DEB_GNAT_PROJECT_DIR)
|