summaryrefslogtreecommitdiff
blob: f4355a9b7ee9dffe8cdbf08ff20fc8a4a493cc5f (plain)
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
# Copyright 1999-2008 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/dev-ada/asis-gcc/asis-gcc-3.4.6.ebuild,v 1.9 2008/02/10 21:12:55 maekke Exp $

inherit eutils flag-o-matic gnatbuild

DESCRIPTION="The Ada Semantic Interface Specification (tools tied to compiler). GnuAda version"
HOMEPAGE="http://gnuada.sourceforge.net/"
LICENSE="GMGPL"

KEYWORDS="~amd64 x86"

Gnat_Name="gnat-gcc"
My_PN="asis"
My_PV="3.4.4"

SRC_URI="mirror://gentoo/${My_PN}-${My_PV}.tar.bz2"

IUSE="doc"
RDEPEND="=dev-lang/gnat-gcc-${PV}*"
DEPEND="${RDEPEND}
	doc? ( virtual/tetex
	app-text/texi2html
	app-text/ghostscript-gpl )"

S="${WORKDIR}/${My_PN}-${My_PV}"

# Execstack is not nearly as dangerous in Ada as in C and would require a lot of
# work to work around. See bug #141315.
QA_EXECSTACK="usr/$(get_libdir)/gnat-gcc/*/${SLOT}/adalib/libasis-${SLOT}.so
	usr/$(get_libdir)/gnat-gcc/*/${SLOT}/adalib/libasis.a
	usr/*/gnat-gcc-bin/${SLOT}/*"

# it may be even better to force plain -O2 -pipe -ftracer here
replace-flags -O3 -O2

# we need to adjust some vars defined in gnatbuild.eclass so that they use
# gnat-gcc instead of asis
My_LIBPATH=${LIBPATH/${PN}/${Gnat_Name}}
My_BINPATH=${BINPATH/${PN}/${Gnat_Name}}
My_DATAPATH=${DATAPATH/${PN}/${Gnat_Name}}

pkg_setup() {
	currGnat=$(eselect --no-color gnat show | grep "gnat-" | awk '{ print $1 }')
	if [[ "${currGnat}" != "${CTARGET}-${Gnat_Name}-${SLOT}" ]]; then
		echo
		eerror "The active gnat profile does not correspond to the selected"
		eerror "version of asis!  Please install the appropriate gnat (if you"
		eerror "did not so yet) and run:"
		eerror "eselect gnat set ${CTARGET}-${Gnat_Name}-${SLOT}"
		eerror "env-update && source /etc/profile"
		eerror "and then emerge =dev-ada/asis-${PV} again.."
		echo
		die
	fi
	if [[ -e ${My_LIBPATH}/adalib/libasis.a ]] ; then
		echo
		ewarn "gnatmake of gnat-gcc unfortunately has problems forcind the build"
		ewarn "if the package is already installed."
		eerror "Please unmerge asis-gcc first and then resume the merge:"
		eerror "emerge --unmerge asis-gcc && emerge asis-gcc"
		echo
		die
	fi
}

src_unpack() {
	unpack ${A}
}

src_compile() {
	# Build the shared library first, we need -fPIC here
	gnatmake -Pasis  -cargs ${CFLAGS} || die "building libasis.a failed"
	gnatmake -Pasis_dyn -f -cargs ${CFLAGS} || die "building libasis.so failed"

	# build tools
	# we need version.o generated for all the tools
	gcc -c -o obj/version.o gnat/version.c
	for fn in asistant gnatelim gnatstub ; do
		pushd tools/${fn}
			gnatmake -o ${fn} ${fn}-driver.adb -I../../asis/ -I../../gnat/ \
				-L../../lib -cargs ${CFLAGS} -largs -lasis ../../obj/version.o \
				|| die "building ${fn} failed"
		popd
	done

	pushd tools/adabrowse
		gcc -c util-nl.c
		gnatmake -I../../asis -I../../gnat adabrowse -L../../lib -cargs	${CFLAGS} \
			-largs -lasis ../../obj/version.o || die
	popd
	pushd tools/semtools
		gnatmake -I../../asis -I../../gnat adadep -L../../lib \
			-cargs ${CFLAGS} -largs -lasis ../../obj/version.o || die
		gnatmake -I../../asis -I../../gnat adasubst -L../../lib \
			-cargs ${CFLAGS} -largs -lasis ../../obj/version.o || die
	popd

	# common stuff is just docs in this case
	if use doc; then
		pushd documentation
		make all || die "Failed while compiling documentation"
		for fn in *.ps; do ps2pdf ${fn}; done
		popd
	fi
}

src_install () {
	# install the lib
	dodir ${My_LIBPATH}/adalib
	chmod 0755 lib_dyn/libasis.so
	cp lib_dyn/libasis.so "${D}${My_LIBPATH}"/adalib/libasis-${SLOT}.so
	insinto ${My_LIBPATH}/adalib
	doins obj/*.ali
	doins lib/libasis.a
	# make appropriate symlinks
	pushd "${D}${My_LIBPATH}"/adalib
	ln -s libasis-${SLOT}.so libasis.so
	popd
	# sources
	insinto ${My_LIBPATH}/adainclude
	doins gnat/*.ad[sb]
	doins asis/*.ad[sb]
	# two files are already part of gnat, removing to avoid collision
	rm "${D}${My_LIBPATH}"/adainclude/g-string.ad?

	# tools
	mkdir -p "${D}${My_BINPATH}"
	for fn in tools/{adabrowse,asistant,gnatelim,gnatstub}; do
		cp ${fn}/${fn:6} "${D}${My_BINPATH}"
	done
	cp tools/semtools/ada{dep,subst} "${D}${My_BINPATH}"

	if use doc; then
		# docs and examples
		dodoc documentation/*.{txt,ps}
		dohtml documentation/*.html
		insinto /usr/share/doc/${PF}
		doins -r documentation/*.pdf
		# info's should go into gnat-gpl dirs
		insinto ${My_DATAPATH}/info/
		doins documentation/*.info
	fi

	insinto /usr/share/doc/${PF}
	doins -r examples/ tutorial/ templates/
}

pkg_postinst() {
	echo
	elog "The ASIS is installed for the active gnat compiler at gnat's	location."
	elog "No further configuration is necessary. Enjoy."
	echo
}