From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Pierre Lindenbaum Newsgroups: gmane.lisp.guile.user Subject: how to write a 'configure.ac' for an* optional* support of libguile. Date: Fri, 15 Dec 2017 09:40:37 +0100 Organization: INSERM Message-ID: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1513327178 25937 195.159.176.226 (15 Dec 2017 08:39:38 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 15 Dec 2017 08:39:38 +0000 (UTC) User-Agent: Mozilla/5.0 (X11; Linux i686; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 To: guile-user@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Fri Dec 15 09:39:32 2017 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ePlWm-0006O2-08 for guile-user@m.gmane.org; Fri, 15 Dec 2017 09:39:32 +0100 Original-Received: from localhost ([::1]:45108 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePlWs-0002IG-Uh for guile-user@m.gmane.org; Fri, 15 Dec 2017 03:39:38 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:44462) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePlWU-0002Hx-O9 for guile-user@gnu.org; Fri, 15 Dec 2017 03:39:15 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ePlWR-0007Vn-Iy for guile-user@gnu.org; Fri, 15 Dec 2017 03:39:14 -0500 Original-Received: from smtp2.univ-nantes.fr ([193.52.82.19]:38584 helo=smtp-prv.univ-nantes.fr) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ePlWR-0007Pp-3n for guile-user@gnu.org; Fri, 15 Dec 2017 03:39:11 -0500 Original-Received: from localhost (localhost [127.0.0.1]) by smtp-prv.univ-nantes.fr (Postfix) with ESMTP id D88C4ACF68F for ; Fri, 15 Dec 2017 09:39:04 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=univ-nantes.fr; s=mail; t=1513327144; bh=HJVEmCbhR1/OL+0M4imuuQBM9v1f0Z6zrSK7/ECuudg=; h=To:From:Subject:Date:From; b=MWkXZzOvbXrVmCD24N3pzWPV0zFJ3nKgRf8m4W9Gqw90X9n8irOlB1zPhuWMKyhuY IipzDAQpt4LTq5qHSVq8ZyhuwvVBENQRRdQHp7LEbXikge1tceI7nS8hCnyK4zXQG8 lCJSQby9Ukg3rR/fOCFIiZPlgm/4QmKvjmvQ5FBA= X-Virus-Scanned: Debian amavisd-new at smtp2 Original-Received: from smtp-prv.univ-nantes.fr ([127.0.0.1]) by localhost (smtp2.u12.univ-nantes.prive [127.0.0.1]) (amavisd-new, port 10024) with LMTP id VmNPaPulSRpA for ; Fri, 15 Dec 2017 09:39:04 +0100 (CET) Original-Received: from [172.18.241.142] (mcclintock.u915.irt.univ-nantes.prive [172.18.241.142]) by smtp-prv.univ-nantes.fr (Postfix) with ESMTP id AD868AB9F76 for ; Fri, 15 Dec 2017 09:39:04 +0100 (CET) Content-Language: en-US X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 193.52.82.19 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Original-Sender: "guile-user" Xref: news.gmane.org gmane.lisp.guile.user:14361 Archived-At: (Cross-posted https://stackoverflow.com/questions/47819563/how-to-configu= re-ac-with-optional-gnu-guile-library-with-guile ) Hi all, I'm looking for a simple example of configure.ac for an optional support = of libguile I'm a complete beginner with configure.ac, I'm trying to create a simple = program that would only use the GNU guile library if the user invokes: ``` configure --with-guile ``` so the C program would be something like: ``` #include "config.h" #include #ifdef HAVE_GUILE #include #endif int main(int argc,char** argv) { #ifdef HAVE_GUILE =C2=A0=C2=A0=C2=A0 printf("Guile supported\n"); =C2=A0=C2=A0=C2=A0 scm_init_guile(); #else =C2=A0=C2=A0=C2=A0 printf("Guile not supported\n"); #endif return 0; } `````` GNU guile uses guile-config compile and guile-config link to obtain the p= ath to the include directory and the libraries. I've not found a tutorial where the paths above are obtained via an exter= nal program. So far my `configure.ac` is ``` AC_INIT(program, 1.0) AC_PROG_CC AC_CONFIG_HEADERS(config.h) with_guile=3Dno AC_ARG_WITH(guile, [AS_HELP_STRING([--with-guile], [use gnu guile])],[],[= with_guile=3Dyes]) if test "x$with_guile" !=3D no then =C2=A0=C2=A0=C2=A0 AC_MSG_CHECKING(for Guile) =C2=A0=C2=A0=C2=A0 guile-config link > /dev/null || { =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 echo "configure: cannot find = guile-config; is Guile installed?" 1>&2 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 exit 1 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 } =C2=A0=C2=A0=C2=A0 CFLAGS=3D"$CFLAGS `guile-config compile`" =C2=A0=C2=A0=C2=A0 LDFLAGS=3D"$LDFLAGS `guile-config link`" =C2=A0=C2=A0=C2=A0 AC_DEFINE([HAVE_GUILE],[1],[Guile supported]) =C2=A0=C2=A0=C2=A0 #PKG_CHECK_MODULES([GUILE],[guile-2.0]) =C2=A0=C2=A0=C2=A0 #AC_CHECK_HEADERS([libguile.h], [], [AC_MSG_ERROR([gu= ile include files not found])]) =C2=A0=C2=A0=C2=A0 #AC_CHECK_LIB([guile], [scm_with_guile], [AC_MSG_ERRO= R([guile library files not found])]) fi dnl Process Makefile.in to create Makefile AC_OUTPUT(Makefile) ``` I've removed AC_CHECK_HEADERS and AC_CHECK_LIB because they doesn't work = (the files are not found). Here I'm lost: how can I add the guile paths to CFLAGS and LDFLAGS, how c= an I generate HAVE_GUILE in config.h current Makefile.in: ``` CC=3D@CC@ LD=3D@CC@ program: program.o =C2=A0=C2=A0=C2=A0 $(LD) -o $@ $^ .PHONY: clean clean: =C2=A0=C2=A0=C2=A0 rm -f program *.o ``` Thanks in advance for your help, P.