* [gentoo-dev] How to set CXX compiler?
@ 2020-07-03 22:35 Xianwen Chen (陈贤文)
2020-07-03 22:46 ` Michael Orlitzky
2020-07-03 22:47 ` James Le Cuirot
0 siblings, 2 replies; 6+ messages in thread
From: Xianwen Chen (陈贤文) @ 2020-07-03 22:35 UTC (permalink / raw
To: Gentoo Dev
[-- Attachment #1: Type: text/plain, Size: 743 bytes --]
Dear all,
I got a newbie question.
I need to patch a Makefile, for a package I am working on my own layman
repo. The package is sci-geosciences/sosicon. It converts spatial data
that is in sosi format, which is the national standard format in Norway,
to a shape file or to PostGIS.
In the Makefile, it is written that
cc = g++
I would like to use sed to patch it so that it ebuild knows which g++ to
use. For example, depending on whether ccache is set, ebuild shall know
whether to use ccache.
I tried to replace g++ with ${CXX}$. I also tried to replace g++ with
$(tc-getCXX). Neither was working. I have also tried a number of other
potential solutions that I thought might work.
Any hint, please?
Yours sincerely,
Xianwen
[-- Attachment #2: Type: text/html, Size: 984 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [gentoo-dev] How to set CXX compiler?
2020-07-03 22:35 [gentoo-dev] How to set CXX compiler? Xianwen Chen (陈贤文)
@ 2020-07-03 22:46 ` Michael Orlitzky
2020-07-03 22:47 ` James Le Cuirot
1 sibling, 0 replies; 6+ messages in thread
From: Michael Orlitzky @ 2020-07-03 22:46 UTC (permalink / raw
To: gentoo-dev
On 2020-07-03 18:35, Xianwen Chen (陈贤文) wrote:
>
> In the Makefile, it is written that
>
> cc = g++
>
> I would like to use sed to patch it so that it ebuild knows which g++ to
> use. For example, depending on whether ccache is set, ebuild shall know
> whether to use ccache.
First, you should suggest to upstream that they don't force a particular
compiler in their Makefile. One uncontroversial way to do this is by
setting the default only if the user does not already have one set, with
the "?=" assignment operator:
cc ?= g++
Then, you should suggest that they change the name of that variable to
the relatively-standard "CXX" that is used for the C++ compiler:
CXX ?= g++
Finally, in your ebuild, you should run
emake CXX=$(tc-getCXX) ...
to override the default CXX in the Makefile. Even if upstream doesn't
respond right away, you can patch the Makefile with these suggestions in
Gentoo and send them the patch.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [gentoo-dev] How to set CXX compiler?
2020-07-03 22:35 [gentoo-dev] How to set CXX compiler? Xianwen Chen (陈贤文)
2020-07-03 22:46 ` Michael Orlitzky
@ 2020-07-03 22:47 ` James Le Cuirot
2020-07-06 7:48 ` Xianwen Chen (陈贤文)
1 sibling, 1 reply; 6+ messages in thread
From: James Le Cuirot @ 2020-07-03 22:47 UTC (permalink / raw
To: gentoo-dev
[-- Attachment #1: Type: text/plain, Size: 524 bytes --]
On Fri, 03 Jul 2020 22:35:30 +0000
Xianwen Chen (陈贤文) <x@chen.ac> wrote:
> In the Makefile, it is written that
>
> cc = g++
>
> I would like to use sed to patch it so that it ebuild knows which g++ to
> use. For example, depending on whether ccache is set, ebuild shall know
> whether to use ccache.
Rather than patch it, start the build with:
emake cc="$(tc-getCXX)"
You'll probably need to do more to respect CXXFLAGS and such though.
--
James Le Cuirot (chewi)
Gentoo Linux Developer
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [gentoo-dev] How to set CXX compiler?
2020-07-03 22:47 ` James Le Cuirot
@ 2020-07-06 7:48 ` Xianwen Chen (陈贤文)
2020-07-06 8:52 ` [gentoo-dev] " Nikos Chantziaras
0 siblings, 1 reply; 6+ messages in thread
From: Xianwen Chen (陈贤文) @ 2020-07-06 7:48 UTC (permalink / raw
To: gentoo-dev
[-- Attachment #1: Type: text/plain, Size: 3646 bytes --]
Thank you, Michael and James.
Yes, I plan to submit a nice patch to the Makefile to upstream.
However, I think something is not right on my computer.
I have earlier tried to specify
emake CC="$(tc-getCXX)" prefix="${EPREFIX}/usr" DESTDIR="${D}"
Somehow, emerge does not know what $(tc-getCXX) is.
###############################################################
>>> Emerging (1 of 1) sci-geosciences/sosicon-2020.06.04::an-overlay
* 655c75a4de75dbd4998ced6473aea255fed2492c.zip BLAKE2B SHA512 size ;-)
... [ ok ]
>>> Unpacking source...
>>> Unpacking 655c75a4de75dbd4998ced6473aea255fed2492c.zip to /var/tmp/portage/sci-geosciences/sosicon-2020.06.04/work
>>> Source unpacked in /var/tmp/portage/sci-geosciences/sosicon-2020.06.04/work
>>> Preparing source in /var/tmp/portage/sci-geosciences/sosicon-2020.06.04/work/sosicon-655c75a4de75dbd4998ced6473aea255fed2492c/src ...
>>> Source prepared.
>>> Configuring source in /var/tmp/portage/sci-geosciences/sosicon-2020.06.04/work/sosicon-655c75a4de75dbd4998ced6473aea255fed2492c/src ...
>>> Source configured.
>>> Compiling source in /var/tmp/portage/sci-geosciences/sosicon-2020.06.04/work/sosicon-655c75a4de75dbd4998ced6473aea255fed2492c/src ...
/var/tmp/portage/sci-geosciences/sosicon-2020.06.04/temp/environment:
line 454: tc-getCXX: command not found
make -j1 CC= prefix=/usr
DESTDIR=/var/tmp/portage/sci-geosciences/sosicon-2020.06.04/image
** Pre build steps...
ragel/bin/linux64/ragel -C -L -o parser_ragel.cpp ragel/parser.rl
ragel/bin/linux64/ragel -C -L -o sosi_north_east_ragel.cpp
ragel/sosi_north_east.rl
ragel/bin/linux64/ragel -C -L -o sosi_north_east_height_ragel.cpp
ragel/sosi_north_east_height.rl
ragel/bin/linux64/ragel -C -L -o sosi_origo_ne_ragel.cpp
ragel/sosi_origo_ne.rl
ragel/bin/linux64/ragel -C -L -o sosi_ref_ragel.cpp ragel/sosi_ref.rl
** Compiling...
o ../bin/cmd/linux64/sosicon main.cpp command_line.cpp factory.cpp
logger.cpp utils.cpp byte_order.cpp sosi/sosi_ref_list.cpp
sosi_ref_ragel.cpp sosi/sosi_element.cpp sosi/sosi_element_search.cpp
sosi/sosi_north_east.cpp sosi_north_east_ragel.cpp
sosi_north_east_height_ragel.cpp sosi/sosi_origo_ne.cpp
sosi_origo_ne_ragel.cpp sosi/sosi_charset_singleton.cpp
sosi/sosi_unit.cpp sosi/sosi_translation_table.cpp shape/shapefile.cpp
converter_sosi2shp.cpp converter_sosi2xml.cpp converter_sosi2tsv.cpp
converter_sosi2psql.cpp converter_sosi2mysql.cpp converter_sosi_stat.cpp
coordinate_collection.cpp parser.cpp parser_ragel.cpp -march=nocona -O2
-pipe;
/bin/sh: o: command not found
###############################################################
Below is the content of the ebuild:
###############################################################
# Copyright 1999-2020 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=7
RESTRICT="splitdebug"
sosicon_git_commit="655c75a4de75dbd4998ced6473aea255fed2492c"
DESCRIPTION="Converts a sosi file to a shapefile or to PostGIS"
HOMEPAGE="https://github.com/espena/sosicon/"
SRC_URI="
https://github.com/espena/sosicon/archive/${sosicon_git_commit}.zip
"
SLOT="0/3.0"
LICENSE="GPL-3"
KEYWORDS="amd64 x86"
S="${WORKDIR}/sosicon-${sosicon_git_commit}/src"
src_prepare(){
default
mv makefile Makefile
sed -i "s|INSTALL_PATH ?= /usr/local|INSTALL_PATH = ${D}|g" Makefile ||
die
sed -i "s|COMPILER_OPTS =|COMPILER_OPTS = ${CXXFLAGS}|g" Makefile || die
}
src_compile() {
emake CC="$(tc-getCXX)" prefix="${EPREFIX}/usr" DESTDIR="${D}"
}
src_install() {
mkdir ${D}/bin
emake install prefix="${EPREFIX}/usr" DESTDIR="${D}"
}
###############################################################
Xianwen
[-- Attachment #2: Type: text/html, Size: 4258 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* [gentoo-dev] Re: How to set CXX compiler?
2020-07-06 7:48 ` Xianwen Chen (陈贤文)
@ 2020-07-06 8:52 ` Nikos Chantziaras
2020-07-07 12:33 ` Xianwen Chen (陈贤文)
0 siblings, 1 reply; 6+ messages in thread
From: Nikos Chantziaras @ 2020-07-06 8:52 UTC (permalink / raw
To: gentoo-dev
On 06/07/2020 10:48, Xianwen Chen (陈贤文) wrote:
> Thank you, Michael and James.
>
> Yes, I plan to submit a nice patch to the Makefile to upstream.
>
> However, I think something is not right on my computer.
>
> I have earlier tried to specify
>
> emake CC="$(tc-getCXX)" prefix="${EPREFIX}/usr" DESTDIR="${D}"
>
>
> Somehow, emerge does not know what $(tc-getCXX) is.
> [...]
>
> Below is the content of the ebuild:
>
> ###############################################################
>
> # Copyright 1999-2020 Gentoo Authors
> # Distributed under the terms of the GNU General Public License v2
>
> EAPI=7
>
> RESTRICT="splitdebug"
>
> sosicon_git_commit="655c75a4de75dbd4998ced6473aea255fed2492c"
> [...]
The ebuild is missing an "inherit" line below the "EAPI" one that
specifies "toolchain-funcs" (which is the eclass that provides the
"tc-*" functions. Try
EAPI=7
inherit toolchain-funcs
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [gentoo-dev] Re: How to set CXX compiler?
2020-07-06 8:52 ` [gentoo-dev] " Nikos Chantziaras
@ 2020-07-07 12:33 ` Xianwen Chen (陈贤文)
0 siblings, 0 replies; 6+ messages in thread
From: Xianwen Chen (陈贤文) @ 2020-07-07 12:33 UTC (permalink / raw
To: gentoo-dev
[-- Attachment #1: Type: text/plain, Size: 251 bytes --]
> The ebuild is missing an "inherit" line below the "EAPI" one that specifies "toolchain-funcs" (which is the eclass that provides the "tc-*" functions. Try
>
> EAPI=7
> inherit toolchain-funcs
Fantastic! Thank you very much! This fixed the problem!
[-- Attachment #2: Type: text/html, Size: 982 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2020-07-07 12:32 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-07-03 22:35 [gentoo-dev] How to set CXX compiler? Xianwen Chen (陈贤文)
2020-07-03 22:46 ` Michael Orlitzky
2020-07-03 22:47 ` James Le Cuirot
2020-07-06 7:48 ` Xianwen Chen (陈贤文)
2020-07-06 8:52 ` [gentoo-dev] " Nikos Chantziaras
2020-07-07 12:33 ` Xianwen Chen (陈贤文)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox