Thread: Autoconf help

  1. #1
    Registered User
    Join Date
    Nov 2010
    Posts
    21

    Autoconf help

    Hallo,
    I need you help with auitoconf. I have a project with existing source. I need to convert that program and include support for mysql.
    Since I want to do it with the "right" way, I want to add the mysql autoconf macros I found at: ac-archive (Autoconf Macro Archive - ac-archive - ax_lib_mysql)
    So, I have a few questions:

    1. I want to make the ./configure script to check for the mysql.h and libmysqlclient.so files. Is that macro suitable for this?
    2. Is there any other simpler way to do it?
    3. The program's directory contains a subdirectory named "m4". Is this the target directory under which I have to add the macro? If not, how do I instruct autoconf to check for that macro?
    4. Finally, what should I run in order to build new configure scripts? Is an automake or autoreconf enough?

    And a final question: How do I instruct the ./configure && make to add the necessary -lmysqlclient -lz flags?

  2. #2
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,268
    1. Probably. I'm not familiar with the mysql macro.
    2. AC_CHECK_HEADER(mysql.h)
    AC_CHECK_LIB(mysqlclient)
    3. The m4 directory is a good place to put the macros.
    4. automake wont generate a new configure script. If you want to regenerate everything, run:
    autoheader
    aclocal
    autoconf
    automake

    And a final question: How do I instruct the ./configure && make to add the necessary -lmysqlclient -lz flags?
    Add those linker options to AM_LDFLAGS in your Makefile.am file.
    bit∙hub [bit-huhb] n. A source and destination for information.

  3. #3
    Registered User
    Join Date
    Nov 2010
    Posts
    21
    First of all, I really thank you for your answer.
    Now, I tried to just use the macro and not modifying the configure.ac script.
    So, I deleted all config* files from the project home directory, added the mysql.m4 macro in the m4 subdirectory and run the following commands:
    autoheader -f -I ./ -I ./m4
    aclocal -f -I ./ -I ./m4
    autoconf -f -I ./ -I ./m4
    automake --add-missing -f

    Then, I did something simple:
    grep -i mysql *.*
    No results. So, the m4 macro was not processed... So, I have to miss something... Should I add the checks in the configure.ac file and then re-run? Or the checks are performed from the macro file?

  4. #4
    Registered User
    Join Date
    Nov 2010
    Posts
    21
    OK, I found it. I added the AX_LIB_MYSQL() statement just before the libs.
    Now, since I want to test the functionality:
    I have installed on my pc the mysqlclient lib but not the mysql.h file.
    So, in theory the mysql.h should stop the ./configure process. However, it does continue. ./configure reports correctly that the mysql.h is missing but continues to process the rest of the files. How do I force it to stop?

  5. #5
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,268
    Quote Originally Posted by tpe View Post
    OK, I found it. I added the AX_LIB_MYSQL() statement just before the libs.
    Now, since I want to test the functionality:
    I have installed on my pc the mysqlclient lib but not the mysql.h file.
    So, in theory the mysql.h should stop the ./configure process. However, it does continue. ./configure reports correctly that the mysql.h is missing but continues to process the rest of the files. How do I force it to stop?
    To be honest, I'm not sure. I always found custom m4 macros to be more trouble than they were worth. It was always easier for me to just use AC_CHECK_HEADER and AC_CHECK_LIB.
    bit∙hub [bit-huhb] n. A source and destination for information.

  6. #6
    Registered User
    Join Date
    Nov 2010
    Posts
    21
    The problem is not the macro, because the mysql.h is part of the configure.ac. Specifically, I added the AC_CHECK_HEADER(mysql.h).
    It correctly reports that mysql.h is missing, but ./configure completes it's job. I want to make it stop when that check fails. How do I do that?

  7. #7
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,268
    AC_CHECK_HEADER(mysql.h,,AC_MSG_ERROR([cannot find mysql.h]))
    bit∙hub [bit-huhb] n. A source and destination for information.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. CBoard Community Project: Poll #1
    By brewbuck in forum Projects and Job Recruitment
    Replies: 148
    Last Post: 06-10-2009, 12:04 PM
  2. Error Using Autoconf in Cygwin
    By Tonto in forum Tech Board
    Replies: 13
    Last Post: 09-22-2007, 04:14 PM
  3. why can't build project in KDevelop C/C++
    By Lauris in forum Linux Programming
    Replies: 21
    Last Post: 09-04-2007, 10:41 AM
  4. AUTOCONF macro + gcc -Wunreachable-code = NOWORK
    By tomsky in forum Linux Programming
    Replies: 2
    Last Post: 10-11-2005, 11:37 AM