2005-08-23 09:52:07 +08:00
|
|
|
# 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=.])
|
2005-10-05 16:58:19 +08:00
|
|
|
LT_AT_CONFIGURE
|
|
|
|
LT_AT_MAKE
|
2005-08-23 09:52:07 +08:00
|
|
|
|
|
|
|
AT_CHECK([test -f libltdlc.la])
|
|
|
|
|
|
|
|
AT_CLEANUP
|
|
|
|
|
|
|
|
|
|
|
|
## -------------------- ##
|
|
|
|
## Copied libltdl tree. ##
|
|
|
|
## -------------------- ##
|
|
|
|
|
|
|
|
AT_SETUP([compiling copied libltdl])
|
|
|
|
|
|
|
|
LT_AT_LIBTOOLIZE([--copy --ltdl=.])
|
2005-10-05 16:58:19 +08:00
|
|
|
LT_AT_CONFIGURE
|
|
|
|
LT_AT_MAKE
|
2005-08-23 09:52:07 +08:00
|
|
|
|
|
|
|
AT_CHECK([test -f libltdlc.la])
|
|
|
|
|
|
|
|
AT_CLEANUP
|
|
|
|
|
|
|
|
|
|
|
|
## ------------------------- ##
|
|
|
|
## Installable libltdl tree. ##
|
|
|
|
## ------------------------- ##
|
|
|
|
|
|
|
|
AT_SETUP([installable libltdl])
|
|
|
|
|
|
|
|
prefix=`pwd`/_inst
|
|
|
|
|
|
|
|
LT_AT_LIBTOOLIZE([--copy --ltdl=.])
|
2005-10-05 16:58:19 +08:00
|
|
|
LT_AT_CONFIGURE([--enable-ltdl-install --prefix=$prefix])
|
|
|
|
LT_AT_MAKE([all install])
|
2005-08-23 09:52:07 +08:00
|
|
|
|
|
|
|
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],
|
2005-08-26 18:00:18 +08:00
|
|
|
[[const char *
|
2005-08-23 09:52:07 +08:00
|
|
|
hello (void)
|
|
|
|
{
|
|
|
|
return "Hello!";
|
|
|
|
}
|
|
|
|
]])
|
|
|
|
|
|
|
|
AT_DATA([main.c],
|
|
|
|
[[#include <stdio.h>
|
|
|
|
#include "ltdl.h"
|
|
|
|
|
|
|
|
int
|
|
|
|
main (int argc, char **argv)
|
|
|
|
{
|
|
|
|
lt_dlhandle handle;
|
2005-08-26 18:00:18 +08:00
|
|
|
const char *(*func) (void) = 0;
|
2005-08-23 09:52:07 +08:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2005-08-26 18:00:18 +08:00
|
|
|
func = (const char *(*)(void)) lt_dlsym (handle, "hello");
|
2005-08-23 09:52:07 +08:00
|
|
|
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
|
2005-08-25 21:39:54 +08:00
|
|
|
MODFLAGS = -module -avoid-version -no-undefined
|
2005-08-23 09:52:07 +08:00
|
|
|
|
2005-08-25 21:39:54 +08:00
|
|
|
LTCOMPILE = $(LIBTOOL) --tag=CC $(LIBTOOLFLAGS) --mode=compile \
|
|
|
|
$(CC) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)
|
|
|
|
LTLINK = $(LIBTOOL) --tag=CC $(LIBTOOLFLAGS) --mode=link \
|
|
|
|
$(CC) $(CFLAGS) $(LDFLAGS)
|
2005-08-23 09:52:07 +08:00
|
|
|
|
2005-08-25 21:39:54 +08:00
|
|
|
TARGETS = libltdl/libltdlc.la module.la ltdldemo$(EXEEXT)
|
2005-08-23 09:52:07 +08:00
|
|
|
|
|
|
|
all: $(TARGETS)
|
|
|
|
|
|
|
|
$(LIBTOOL) libltdl/libltdlc.la:
|
2005-10-05 16:58:19 +08:00
|
|
|
cd libltdl && ./configure $(CONFIGURE_OPTIONS) && $(MAKE)
|
2005-08-23 09:52:07 +08:00
|
|
|
|
2005-08-25 21:39:54 +08:00
|
|
|
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
|
2005-08-23 09:52:07 +08:00
|
|
|
|
|
|
|
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])
|
2005-10-05 16:58:19 +08:00
|
|
|
LT_AT_MAKE([], [CC="$CC" LIBTOOLFLAGS="$LIBTOOLFLAGS" CPPFLAGS="$CPPFLAGS" \
|
|
|
|
CFLAGS="$CFLAGS" LDFLAGS="$LDFLAGS" \
|
|
|
|
CONFIGURE_OPTIONS="$configure_options"])
|
2005-08-23 09:52:07 +08:00
|
|
|
|
2005-08-26 18:00:18 +08:00
|
|
|
LT_AT_EXEC_CHECK([./ltdldemo], 0, [ignore])
|
2005-08-23 09:52:07 +08:00
|
|
|
|
|
|
|
AT_CLEANUP
|