Hi Rambius,
On 7/9/10 9:54 PM, Ivan "Rambius" Ivanov wrote:
$ cat configure.in
The modern name is configure.ac. If this is a new project, I wold
consider changing to configure.ac.
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_INIT([cryptoexamples], [0.1], [rambiusparkisanius@xxxxxxxxx])
AC_CONFIG_AUX_DIR(config)
AC_CONFIG_SRCDIR([src])
AC_CONFIG_HEADERS([config.h])
AM_INIT_AUTOMAKE(cryptoexamples, 0.1)
You don't need to give PACKAGE and VERSION in AM_INIT_AUTOMAKE. automake
is smart and can figure out that from the arguments in AC_INIT.
# Checks for programs.
AC_PROG_CC
AC_PROG_RANLIB
# Checks for libraries.
AC_CHECK_LIB(ssl, SSL_library_init)
underquoted; I would use
AC_CHECK_LIB([ssl], [SSL_library_init])
# Checks for header files.
# Checks for typedefs, structures, and compiler characteristics.
# Checks for library functions.
AC_OUTPUT(Makefile src/Makefile)
same here
AC_OUTPUT([Makefile src/Makefile])
I also have Makefile.am and src/Makefile.am:
$ cat Makefile.am
SUBDIRS = src
$ cat src/Makefile.am
bin_PROGRAMS = countnb
countnb_SOURCES = countnb.c
lib_LIBRARIES = libseedprng.a
libseedprng_a_SOURCES = seed_prng.c
Now my questions are:
1) The default locations of openssl headers and libs are /usr/include
and /usr/libs on Mac OS X. However, I have newer version of openssl in
/opt/local with headers in /opt/local/include and libs in
/opt/local/lib. How to instruct autotools to use the version in
/opt/local on Mac OS X?
One way is to call configure as
./configure CPPFLAGS=-I/opt/local/include LDFLAGS=-L/opt/local/lib
2) In configure.in I make a check for openssl availability using the macro
AC_CHECK_LIB(ssl, SSL_library_init)
Later, when I run ./configure I get the message
checking for SSL_library_init in -lssl... yes
How can I instruct autoconf to fail if openssl is not found (in /opt/local)?
You can write
AC_CHECK_LIB([ssl], [SSL_library_init], [], [AC_MSG_FAILURE([could not find ssl])])
and configure will fail if ssl was not found. If you wanna fail if an
old ssl (in /usr) was found, I suggest you change the test to test for
some function that was introduced after that old version, which will
make the linker test fail when linking against that old version of ssl.
3) In src/Makefile.am I am trying to build libseedprng.a with
lib_LIBRARIES = libseedprng.a
libseedprng_a_SOURCES = seed_prng.c
How can I instruct it to link it against ssl and crypto libraries;
that is how can I pass -lssl and -lcrypto options to the linker?
LIBADD = -lssl -lcrypto
should make it although I think -lssl might not be needed as
AC_CHECK_LIB probably has added -lssl to LIBS already.
Hope that helps,
Peter
_______________________________________________
Autoconf mailing list
Autoconf@xxxxxxx
http://lists.gnu.org/mailman/listinfo/autoconf