libtool/tests/standalone.at

161 lines
3.7 KiB
Plaintext
Raw Normal View History

# Hand crafted tests for GNU Libtool. -*- Autotest -*-
# Copyright 2005 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA.
AT_BANNER([Standalone Libltdl.])
## ------------------------ ##
## Softlinked libltdl tree. ##
## ------------------------ ##
AT_SETUP([compiling softlinked libltdl])
LT_AT_LIBTOOLIZE([--ltdl=.])
LT_AT_CONFIGURE
LT_AT_MAKE
AT_CHECK([test -f libltdlc.la])
AT_CLEANUP
## -------------------- ##
## Copied libltdl tree. ##
## -------------------- ##
AT_SETUP([compiling copied libltdl])
LT_AT_LIBTOOLIZE([--copy --ltdl=.])
LT_AT_CONFIGURE
LT_AT_MAKE
AT_CHECK([test -f libltdlc.la])
AT_CLEANUP
## ------------------------- ##
## Installable libltdl tree. ##
## ------------------------- ##
AT_SETUP([installable libltdl])
prefix=`pwd`/_inst
LT_AT_LIBTOOLIZE([--copy --ltdl=.])
LT_AT_CONFIGURE([--enable-ltdl-install --prefix=$prefix])
LT_AT_MAKE([all install])
AT_CHECK([test -f $prefix/lib/libltdl.la])
AT_CHECK([test -f $prefix/include/ltdl.h])
AT_CLEANUP
## ----------------------------------------------- ##
## libltdl is usable without Autoconf or Automake. ##
## ----------------------------------------------- ##
AT_SETUP([linking libltdl without autotools])
AT_DATA([module.c],
[[const char *
hello (void)
{
return "Hello!";
}
]])
AT_DATA([main.c],
[[#include <stdio.h>
#include "ltdl.h"
int
main (int argc, char **argv)
{
lt_dlhandle handle;
const char *(*func) (void) = 0;
int status = 1;
LTDL_SET_PRELOADED_SYMBOLS();
if (lt_dlinit() != 0) {
fprintf (stderr, "error during initialisation: %s\n", lt_dlerror());
return 1;
}
handle = lt_dlopen("module.la");
if (!handle) {
fprintf (stderr, "error dlopening module.la: %s\n", lt_dlerror());
goto finish;
}
func = (const char *(*)(void)) lt_dlsym (handle, "hello");
if (!func) {
fprintf (stderr, "error fetching func: %s\n", lt_dlerror());
goto finish;
}
printf ("%s\n", (*func) ());
status = 0;
finish:
lt_dlexit();
return status;
}
]])
AT_DATA([Makefile],
[[LIBTOOL = ./libltdl/libtool
INCLUDES = -I./libltdl
MODFLAGS = -module -avoid-version -no-undefined
LTCOMPILE = $(LIBTOOL) --tag=CC $(LIBTOOLFLAGS) --mode=compile \
$(CC) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)
LTLINK = $(LIBTOOL) --tag=CC $(LIBTOOLFLAGS) --mode=link \
$(CC) $(CFLAGS) $(LDFLAGS)
TARGETS = libltdl/libltdlc.la module.la ltdldemo$(EXEEXT)
all: $(TARGETS)
$(LIBTOOL) libltdl/libltdlc.la:
cd libltdl && ./configure $(CONFIGURE_OPTIONS) && $(MAKE)
ltdldemo$(EXEEXT): $(LIBTOOL) module.la libltdl/libltdlc.la main.lo
$(LTLINK) -o ltdldemo main.lo -dlopen module.la ./libltdl/libltdlc.la
main.lo: $(LIBTOOL) main.c
$(LTCOMPILE) -c main.c
module.la: $(LIBTOOL) module.lo
$(LTLINK) -o module.la module.lo $(MODFLAGS) -rpath /dev/null
module.lo: $(LIBTOOL) module.c
$(LTCOMPILE) -c module.c
]])
LT_AT_LIBTOOLIZE([--copy --ltdl])
LT_AT_MAKE([], [CC="$CC" LIBTOOLFLAGS="$LIBTOOLFLAGS" CPPFLAGS="$CPPFLAGS" \
CFLAGS="$CFLAGS" LDFLAGS="$LDFLAGS" \
CONFIGURE_OPTIONS="$configure_options"])
LT_AT_EXEC_CHECK([./ltdldemo], 0, [ignore])
AT_CLEANUP