configure option --enable-relpath

add relative path ../lib to spinit for codemodels
and search path in ivars.c, independently from
install path which has to be an absolute path
This commit is contained in:
h_vogt 2017-08-12 17:37:19 +02:00
parent a1d27b4257
commit 07ea6466ad
3 changed files with 38 additions and 6 deletions

View File

@ -171,6 +171,10 @@ AC_ARG_ENABLE([help],
AC_ARG_ENABLE([xgraph],
[AS_HELP_STRING([--enable-xgraph], [Enable xgraph compilation.])])
# --enable-relpath: Relative path for binary and data. Default is "no".
# ngspice shared may want relative paths for spinit etc.
AC_ARG_ENABLE([relpath],
[AS_HELP_STRING([--enable-relpath], [Enable relative paths for spinit etc.])])
# --with-readline: Includes GNU readline support into CLI. Default is "no".
AC_ARG_WITH([readline],
[AS_HELP_STRING([--with-readline[=yes/no]], [Enable GNU readline support for CLI. Default=no.])])
@ -774,8 +778,15 @@ if test "x$getopt_long" = xtrue; then
AC_DEFINE([HAVE_GETOPT_LONG], [1], [Have fcn getopt_long()])
fi
AM_CONDITIONAL([RELPATH], [test "x$enable_relpath" = xyes])
if test "x$enable_relpath" = xyes; then
AC_DEFINE_UNQUOTED([NGSPICEBINDIR], ["`echo ../bin`"], [Define the directory for executables])
AC_DEFINE_UNQUOTED([NGSPICEDATADIR], ["`echo ../share/ngspice`"], [Define the directory for architecture independent data files])
AC_DEFINE([HAS_RELPATH], [1], [rel. path of libraries and scripts])
else
AC_DEFINE_UNQUOTED([NGSPICEBINDIR], ["`echo $dprefix/bin`"], [Define the directory for executables])
AC_DEFINE_UNQUOTED([NGSPICEDATADIR], ["`echo $dprefix/share/ngspice`"], [Define the directory for architecture independent data files])
fi
AC_DEFINE_UNQUOTED([NGSPICEBUILDDATE], ["`date`"], [Define the build date])
if test "x$with_wingui" = xyes; then

View File

@ -293,13 +293,19 @@ ngspice.idx: ngmakeidx$(EXEEXT) $(srcdir)/ngspice.txt
endif !SHWIN
endif !WINGUI
if RELPATH
spinitpath=../lib/ngspice
endif RELPATH
if !RELPATH
spinitpath=$(pkglibdir)
endif !RELPATH
## create spinit at compile time, see
## (info "(autoconf) Installation Directory Variables")
edit = sed \
-e 's|@XSPICEINIT[@]|$(XSPICEINIT)|g' \
-e 's|@pkglibdir[@]|$(pkglibdir)|g'
-e 's|@pkglibdir[@]|$(spinitpath)|g'
spinit tclspinit : Makefile
rm -f $@ $@.tmp

View File

@ -33,16 +33,30 @@ mkvar(char **p, char *path_prefix, char *var_dir, char *env_var)
*p = tprintf("%s%s%s", path_prefix, DIR_PATHSEP, var_dir);
}
/* $dprefix has been set to /usr/local or C:/Spice (Windows) in configure.ac,
or to <path> given by prefix="<path>" as parameter to ./configure command.
NGSPICEBINDIR has been set to $dprefix/bin in config.h.
NGSPICEDATADIR has been set to $dprefix/share/ngspice in config.h.
If --enable-relpath is selected as paramter to the ./configure command, then
NGSPICEBINDIR is set to ../bin in config.h.
NGSPICEDATADIR is set to ../share/ngspice in config.h.
Spice_Exec_Dir has been set to NGSPICEBINDIR in conf.c,
may be overridden here by environmental variable SPICE_EXEC_DIR.
Spice_Lib_Dir has been set to NGSPICEDATADIR in conf.c,
may be overridden here by environmental variable SPICE_LIB_DIR.
The search path for codemodels in spinit contains $dprefix, or, if --enable-relpath
is given, to ../lib, set by src/makefile.am. With Visual C, it is set manually by
an entry to ngspice\visualc\src\include\ngspice\config.h.*/
void
ivars(char *argv0)
{
char *temp=NULL;
/* $dprefix has been set to /usr/local or C:/Spice (Windows) in configure.ac,
NGSPICEBINDIR has been set to $dprefix/bin in configure.ac,
Spice_Exec_Dir has been set to NGSPICEBINDIR in conf.c,
may be overridden here by environmental variable SPICE_EXEC_DIR */
env_overr(&Spice_Exec_Dir, "SPICE_EXEC_DIR");
#ifdef HAS_RELPATH
Spice_Lib_Dir = temp = copy("../share/ngspice");
#else
env_overr(&Spice_Lib_Dir, "SPICE_LIB_DIR");
#endif
/* for printing a news file */
mkvar(&News_File, Spice_Lib_Dir, "news", "SPICE_NEWS");
@ -52,6 +66,7 @@ ivars(char *argv0)
mkvar(&Lib_Path, Spice_Lib_Dir, "scripts", "SPICE_SCRIPTS");
/* used to call ngspice with aspice command, not used in Windows mode */
mkvar(&Spice_Path, Spice_Exec_Dir, "ngspice", "SPICE_PATH");
tfree(temp);
/* may be used to store input files (*.lib, *.include, ...) */
/* get directory where ngspice resides */
#if defined (HAS_WINGUI) || defined (__MINGW32__) || defined (_MSC_VER)