From owner-freebsd-ports@freebsd.org Mon Jul 6 10:28:00 2015 Return-Path: Delivered-To: freebsd-ports@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C8B48993AE3 for ; Mon, 6 Jul 2015 10:28:00 +0000 (UTC) (envelope-from tijl@freebsd.org) Received: from mailman.ysv.freebsd.org (mailman.ysv.freebsd.org [IPv6:2001:1900:2254:206a::50:5]) by mx1.freebsd.org (Postfix) with ESMTP id AD60218FF for ; Mon, 6 Jul 2015 10:28:00 +0000 (UTC) (envelope-from tijl@freebsd.org) Received: by mailman.ysv.freebsd.org (Postfix) id AC188993AE2; Mon, 6 Jul 2015 10:28:00 +0000 (UTC) Delivered-To: ports@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 91D2D993AE1 for ; Mon, 6 Jul 2015 10:28:00 +0000 (UTC) (envelope-from tijl@freebsd.org) Received: from mailrelay109.isp.belgacom.be (mailrelay109.isp.belgacom.be [195.238.20.136]) by mx1.freebsd.org (Postfix) with ESMTP id F0F3418FE for ; Mon, 6 Jul 2015 10:27:59 +0000 (UTC) (envelope-from tijl@freebsd.org) X-Belgacom-Dynamic: yes X-Cloudmark-SP-Filtered: true X-Cloudmark-SP-Result: v=1.1 cv=Cjxj77ls1R2S+e9aJ2LrqpY3XlZy0HpxyZbjmPPvmIM= c=1 sm=2 a=mR_foD2xAAAA:8 a=6I5d2MoRAAAA:8 a=NEAV23lmAAAA:8 a=mDV3o1hIAAAA:8 a=9qXmDRkNAAAA:8 a=LQxB-7eNEWSo_ez0gNgA:9 a=CjuIK1q_8ugA:10 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2CfBABTV5pV/++YsFtcgxJUYL1VCYFwhXUCgSs5FAEBAQEBAQGBCoQkAQEEOhwjEAsOCgklDyoeBhOIMgEIyBMBAQEBAQEBAwEBAQEBARyLS4JrghsHhCsFlBWEYocFgX+WWCaDfTwxAQEBgkgBAQE Received: from 239.152-176-91.adsl-dyn.isp.belgacom.be (HELO kalimero.tijl.coosemans.org) ([91.176.152.239]) by relay.skynet.be with ESMTP; 06 Jul 2015 12:26:48 +0200 Received: from kalimero.tijl.coosemans.org (kalimero.tijl.coosemans.org [127.0.0.1]) by kalimero.tijl.coosemans.org (8.14.9/8.14.9) with ESMTP id t66AQl36002057; Mon, 6 Jul 2015 12:26:47 +0200 (CEST) (envelope-from tijl@FreeBSD.org) Date: Mon, 6 Jul 2015 12:26:47 +0200 From: Tijl Coosemans To: Marcin Cieslak Cc: ports@FreeBSD.org Subject: Re: Proper way to get base with autoconf? Message-ID: <20150706122647.64b520e2@kalimero.tijl.coosemans.org> In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-BeenThere: freebsd-ports@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Porting software to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 06 Jul 2015 10:28:00 -0000 On Sun, 5 Jul 2015 21:11:55 +0000 Marcin Cieslak wrote: > [X-posted, replies set to ports@FreeBSD.org] > > Hello, > > I have managed to upstream few things needed > to make mono work on FreeBSD without local patches. > > Now I am stuck with the iconv detection code. > > Mono (or it's dumbled-down glib called eglib) need > libiconv for two things - charset conversion: > > > https://github.com/mono/mono/blob/master/eglib/src/giconv.c > > and getting default charset information > > https://github.com/mono/mono/blob/master/eglib/src/gunicode.c#L223 > > The latter can be solved by using "nl_langinfo (CODESET);" > and avoiding the need to link libcharset.so > > > Mono uses "standard" iconv.m4 autoconf test, version 11 > https://github.com/mono/mono/blob/master/eglib/m4/iconv.m4 > > which is developed in the gettext and gnulib (The GNU portability > library): > > http://git.savannah.gnu.org/cgit/gnulib.git/log/m4/iconv.m4 > > http://git.savannah.gnu.org/cgit/gettext.git/log/gettext-runtime/m4/iconv.m4 > > Whenever -I/usr/local/include is added to CPPFLAGS for > some reason (some other library, or jest using /usr/local as > default prefix) the configure script fails to use base header > and libc support and needs using GNU iconv as a dependency; > because this simple test fails: > > > configure:13910: checking for iconv > configure:13934: cc -o conftest -g -O2 -g -D_GNU_SOURCE -I/usr/local/include conftest.c >&5 > /tmp/conftest-ee6d62.o: In function `main': > /home/saper/sw/mono/eglib/conftest.c:42: undefined reference to `libiconv_open' > /home/saper/sw/mono/eglib/conftest.c:43: undefined reference to `libiconv' > /home/saper/sw/mono/eglib/conftest.c:44: undefined reference to `libiconv_close' > cc: error: linker command failed with exit code 1 (use -v to see invocation) > configure:13934: $? = 1 > configure: failed program was: > | /* confdefs.h */ > | #define PACKAGE_NAME "eglib" > | #define PACKAGE_TARNAME "eglib" > | #define PACKAGE_VERSION "0.3" > | #define PACKAGE_STRING "eglib 0.3" > | #define PACKAGE_BUGREPORT "http://bugzilla.xamarin.com/enter_bug.cgi?classification=Mono" > > --snip-- > > | /* end confdefs.h. */ > | > | #include > | #include > | > | int > | main () > | { > | iconv_t cd = iconv_open("",""); > | iconv(cd,NULL,NULL,NULL,NULL); > | iconv_close(cd); > | ; > | return 0; > | } > configure:13958: cc -o conftest -g -O2 -g -D_GNU_SOURCE -I/usr/local/include conftest.c /usr/local/lib/libiconv.so -Wl,-rpath -Wl,/usr/local/lib >&5 > configure:13958: $? = 0 > configure:13968: result: yes > > The test fails because /usr/local/include/iconv.h > redefines iconv_open (and friends) to libiconv_open > > Any ideas how to fix/improve the iconv.m4 detection code > - to use the FreeBSD's base and not require a library? This works as intended and behaves exactly the same as on Linux. When you don't have libiconv installed, base iconv is used. When you have libiconv installed, libiconv is used. When you have libiconv installed, but don't want to use it you can add -DLIBICONV_PLUG to CPPFLAGS. It's up to the user to choose one of these and not something that you as a developer need to worry about. So no changes to mono or iconv.m4 are needed. When creating a port that uses iconv you just add USES=iconv to the port Makefile and it should do the right thing.