diff --git a/configure.in b/configure.in index 0ad186231..a80bb3dd2 100644 --- a/configure.in +++ b/configure.in @@ -7,13 +7,25 @@ AC_PROG_CXX AC_CHECK_TOOL(STRIP, strip, true) AC_CHECK_HEADERS(getopt.h) AC_CHECK_HEADER(ipal.h, HAVE_IPAL=yes, HAVE_IPAL=) +AC_SUBST(HAVE_IPAL) AC_PROG_INSTALL -AC_CHECK_LIB(dl,main,[DLLIB=-ldl]) + +# -- +# Look for a dl library to use. First look for the standard dlopen +# functions, and failing that look for the HP specific shl_load function. + +AC_CHECK_HEADERS(dlfcn.h dl.h, break) + +DLLIB='' +AC_CHECK_LIB(dl,dlopen,[DLLIB=-ldl]) +if test -z "$DLLIB" ; then +AC_CHECK_LIB(dld,shl_load,[DLLIB=-ldld]) +fi AC_SUBST(DLLIB) + AC_CANONICAL_HOST # $host -AC_SUBST(HAVE_IPAL) ####################### ## test for underscores. The vpi module loader in vvm needs to know this @@ -22,6 +34,7 @@ AC_SUBST(HAVE_IPAL) AC_CYGWIN AC_EXEEXT +AC_SUBST(CYGWIN) AC_SUBST(EXEEXT) AC_MSG_CHECKING("for leading and/or trailing underscores") @@ -39,14 +52,7 @@ if test ! -z "$output" -a -z "$CYGWIN" ; then AC_DEFINE(NEED_LU) fi -PICFLAG=-fPIC -if test ! -z "$CYGWIN" ; then - PICFLAG= -fi - -AC_SUBST(CYGWIN) -AC_SUBST(PICFLAG) output=`nm underscore.o|grep underscore_ 2>&1` if test ! -z "$output"; then @@ -69,6 +75,26 @@ AC_MSG_RESULT("$CC_LEADING_UNDERSCORE $CC_TRAILING_UNDERSCORE") ## end of test for underscores ####################### +# The -fPIC flag is used to tell the compiler to make position +# independent code. It is needed when making shared objects. + +AC_MSG_CHECKING("for flag to make position independent code") +PICFLAG=-fPIC +case "${host}" in + + *-*-cygwin*) + PICFLAG= + ;; + + *-*-hpux*) + PICFLAG=+z + ;; + +esac +AC_SUBST(PICFLAG) +AC_MSG_RESULT($PICFLAG) + + # The -rdynamic flag is used by iverilog when compiling the target, # to know how to export symbols of the main program to loadable modules # that are brought in by -ldl @@ -89,18 +115,25 @@ case "${host}" in rdynamic="" ;; + *-*-hpux*) + rdynamic="-E" + ;; esac - AC_SUBST(rdynamic) - AC_MSG_RESULT($rdynamic) -AC_MSG_CHECKING("for shared library build flag") +AC_MSG_CHECKING("for shared library link flag") shared=-shared case "${host}" in + *-*-cygwin*) shared="-mdll -Wl,--enable-auto-image-base" ;; + + *-*-hpux*) + shared="-b" + ;; + esac AC_SUBST(shared) diff --git a/t-dll.cc b/t-dll.cc index 46e5cdbc5..080b8e2ce 100644 --- a/t-dll.cc +++ b/t-dll.cc @@ -17,14 +17,38 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: t-dll.cc,v 1.21 2000/12/14 23:23:07 steve Exp $" +#ident "$Id: t-dll.cc,v 1.22 2000/12/15 05:45:25 steve Exp $" #endif # include "compiler.h" # include "t-dll.h" -# include # include +#if defined(HAVE_DLFCN_H) +inline ivl_dll_t ivl_dlopen(const char*name) +{ return dlopen(name,RTLD_NOW); } + +inline void* ivl_dlsym(ivl_dll_t dll, const char*nm) +{ return dlsym(dll, nm); } + +inline void ivl_dlclose(ivl_dll_t dll) +{ dlclose(dll); } + +#elif defined(HAVE_DL_H) +inline ivl_dll_t ivl_dlopen(const char*name) +{ return shl_load(name, BIND_IMMEDIATE, 0); } + +inline void* ivl_dlsym(ivl_dll_t dll, const char*nm) +{ + void*sym; + int rc = shl_findsym(&dll, nm, TYPE_PROCEDURE, &sym); + return (rc == 0) ? sym : 0; +} + +inline void ivl_dlclose(ivl_dll_t dll) +{ shl_unload(dll); } +#endif + static struct dll_target dll_target_obj; /* @@ -149,7 +173,7 @@ static void scope_add_lpm(ivl_scope_t scope, ivl_lpm_t net) bool dll_target::start_design(const Design*des) { dll_path_ = des->get_flag("DLL"); - dll_ = dlopen(dll_path_.c_str(), RTLD_NOW); + dll_ = ivl_dlopen(dll_path_.c_str()); if (dll_ == 0) { cerr << dll_path_ << ": " << dlerror() << endl; return false; @@ -170,7 +194,7 @@ bool dll_target::start_design(const Design*des) des_.root_->nlpm_ = 0; des_.root_->lpm_ = 0; - target_ = (target_design_f)dlsym(dll_, LU "target_design" TU); + target_ = (target_design_f)ivl_dlsym(dll_, LU "target_design" TU); if (target_ == 0) { cerr << dll_path_ << ": error: target_design entry " "point is missing." << endl; @@ -187,7 +211,7 @@ bool dll_target::start_design(const Design*des) void dll_target::end_design(const Design*) { (target_)(&des_); - dlclose(dll_); + ivl_dlclose(dll_); } /* @@ -617,6 +641,9 @@ extern const struct target tgt_dll = { "dll", &dll_target_obj }; /* * $Log: t-dll.cc,v $ + * Revision 1.22 2000/12/15 05:45:25 steve + * Autoconfigure the dlopen functions. + * * Revision 1.21 2000/12/14 23:23:07 steve * Support more logic gate types. * diff --git a/t-dll.h b/t-dll.h index 3b1980fe3..a78954e69 100644 --- a/t-dll.h +++ b/t-dll.h @@ -19,12 +19,20 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: t-dll.h,v 1.19 2000/12/05 06:29:33 steve Exp $" +#ident "$Id: t-dll.h,v 1.20 2000/12/15 05:45:25 steve Exp $" #endif # include "target.h" # include "ivl_target.h" +#if defined(HAVE_DLFCN_H) +# include +typedef void* ivl_dll_t; +#elif defined(HAVE_DL_H) +# include +typedef shl_t ivl_dll_t; +#endif + struct ivl_design_s { ivl_scope_t root_; @@ -58,7 +66,7 @@ struct dll_target : public target_t, public expr_scan_t { void scope(const NetScope*); void signal(const NetNet*); - void*dll_; + ivl_dll_t dll_; string dll_path_; ivl_design_s des_; @@ -355,6 +363,9 @@ struct ivl_statement_s { /* * $Log: t-dll.h,v $ + * Revision 1.20 2000/12/15 05:45:25 steve + * Autoconfigure the dlopen functions. + * * Revision 1.19 2000/12/05 06:29:33 steve * Make signal attributes available to ivl_target API. *