dnl Process this file with autoconf to produce a configure script. dnl dnl OPP_CHECK_LIB( -- macro to check availability of a library dnl $1: LIBRARY-NAME, -- descriptive name (only for printout) dnl $2: HEADER, -- optional: header file to #include dnl $3: FUNCTION, -- optional: function WITH ARG LIST, e.g. floor(0.5) dnl $4: CFLAGS, -- optional: compiler flags dnl $5: LDFLAGS, -- optional: linker flags dnl $6: RESULT-VAR -- will contain "yes" or "no" dnl $7: ACTION-IF-FOUND dnl $8: ACTION-IF-NOT-FOUND dnl ) dnl AC_DEFUN(OPP_CHECK_LIB,[ save_CXXFLAGS=$CXXFLAGS save_LIBS=$LIBS CXXFLAGS="$4" LIBS="$5" AC_MSG_CHECKING(for $1 with CFLAGS="$4" LIBS="$5") AC_LINK_IFELSE( [AC_LANG_PROGRAM([[#include <$2>]], [[$3;]])], [AC_MSG_RESULT(yes); $6=yes; $7], [AC_MSG_RESULT(no); $6=no; $8]) CXXFLAGS=$save_CXXFLAGS LIBS=$save_LIBS ]) # # Autoconf initialization # AC_INIT AC_CONFIG_SRCDIR(include/omnetpp.h) AC_LANG(C++) AC_CONFIG_AUX_DIR(src/utils) AC_CANONICAL_HOST() # figure out here if we have gcc or not -- we'll need it soon #FIXME: skip if CC var already exists AC_PROG_CC AC_PROG_CXX # # OMNeT++ version number # OMNETPP_VERSION=`cat Version | sed 's/omnetpp-//'` # # Set system/arch specific values # case $host in sparc-sun-*) CFLAGS_ARCH="-DSUNSPARC" ;; *-*-cygwin*) cygwin=yes ;; *-*-mingw32*) mingw=yes ;; *-hp-hpux*) SO_LIB_SUFFIX=".sl" ;; *) ;; esac # # Location of various components. Can be overridden in configure.user. # OMNETPP_ROOT=`pwd` if test "$mingw" = yes; then OMNETPP_ROOT=`pwd -W` fi if test "$cygwin" = yes; then OMNETPP_ROOT=`cygpath -w $OMNETPP_ROOT | sed 's|\\\\|/|g'` fi OMNETPP_SRC_DIR="$OMNETPP_ROOT/src" OMNETPP_UTILS_DIR="$OMNETPP_SRC_DIR/utils" OMNETPP_DOC_DIR="$OMNETPP_ROOT/doc" OMNETPP_SAMPLES_DIR="$OMNETPP_ROOT/samples" OMNETPP_TUTORIAL_DIR="$OMNETPP_ROOT/tutorial" # OMNETPP_MODELS_DIR="$OMNETPP_ROOT/models" OMNETPP_TEST_DIR="$OMNETPP_ROOT/test" OMNETPP_BITMAP_PATH=".;./bitmaps;$OMNETPP_ROOT/bitmaps" OMNETPP_BIN_DIR="$OMNETPP_ROOT/bin" OMNETPP_INCL_DIR="$OMNETPP_ROOT/include" OMNETPP_LIB_DIR="$OMNETPP_ROOT/lib" OMNETPP_TKENV_DIR="$OMNETPP_SRC_DIR/tkenv" OMNETPP_GNED_DIR="$OMNETPP_SRC_DIR/gned" OMNETPP_NEDC_DIR="$OMNETPP_SRC_DIR/nedc" OMNETPP_PLOVE_DIR="$OMNETPP_SRC_DIR/plove" CFLAGS='-g Wall' #CFLAGS='-O3 -DNDEBUG=1' NEDCFLAGS='-Wno-unused' LDFLAGS= AS="as" AR="ar cr" SHLIB_LD="$CXX -shared -fPIC" SHLIB_CFLAGS="-fPIC" NEDC="nedc" MSGC="opp_msgc" MAKEDEPEND="opp_makedep -Y --objdirtree" if test "$cygwin" = yes; then MYPWD="$OMNETPP_SRC_DIR/utils/cygpwd" else MYPWD="pwd" fi # # set default library suffixes. May be already defined # with system/arch specific values # A_LIB_SUFFIX=${A_LIB_SUFFIX:-".a"} SO_LIB_SUFFIX=${SO_LIB_SUFFIX:-".so"} if test "$cygwin" = yes; then EXE_SUFFIX=".exe" else EXE_SUFFIX= fi # total stack size on NT defaults to 128MB (will be added to LDFLAGS later): CYGWIN_STACKSIZE=134217728 build_shared_libs=if-not-cygwin #build_shared_libs=yes #build_shared_libs=no #---------------------- # Default flags for values for other variables that come from configure.user. #---------------------- # for Tcl/Tk # following line relies on having AC_PROG_CXX earlier! if test "$GCC" = "yes"; then TK_CFLAGS="-fwritable-strings" else # other compilers use different flag, but we can't figure it out here TK_CFLAGS= fi TK_LIBS= # for MPI MPI_CFLAGS= MPI_LIBS= # for PVM if test -n "$PVM_ROOT"; then PVM_CFLAGS="-I$PVM_ROOT/include" PVM_LIBS="-L$PVM_ROOT/$PVM_ARCH/lib -lgpvm3 -lpvm3" else PVM_CFLAGS= PVM_LIBS="-lgpvm3 -lpvm3" fi # for Expat EXPAT_CFLAGS= EXPAT_LIBS=-lexpat # for LibXML LIBXML_CFLAGS= LIBXML_LIBS="-lxml2 -liconv" # for Akaroa AKAROA_CFLAGS= AKAROA_LIBS="-lakaroa" #---------------------- # Read user settings (and allow override the above settings) #---------------------- AC_MSG_NOTICE(-----------------------------------------------) AC_MSG_NOTICE(reading configure.user for your custom settings) AC_MSG_NOTICE(-----------------------------------------------) . ./configure.user #---------------------- # set arch specific flags #---------------------- CFLAGS="$CFLAGS $CFLAGS_ARCH" #---------------------- # Checks for programs. #---------------------- AC_PROG_YACC if test "$YACC" = "yacc"; then AC_MSG_WARN([neither bison nor byacc is found...]) fi AC_PROG_LEX # AC_PROG_CC -- these are needed at the top # AC_PROG_CXX AC_PROG_RANLIB # doxygen is used for generation of api doc AC_ARG_VAR(DOXYGEN, The Doxygen documentation tool) AC_CHECK_PROG(DOXYGEN, doxygen, doxygen, not found) if test "$DOXYGEN" = "not found"; then AC_MSG_WARN(doxygen is needed to create the OMNeT++ API reference.) AC_MSG_WARN(It is available from http://www.doxygen.org/) fi # perl is needed for experimental nedc message subclassing AC_ARG_VAR(PERL, The Perl interpreter) AC_CHECK_PROG(PERL, perl, perl, not found) # xsltproc AC_ARG_VAR(XSLTPROC, A command line xslt processor) AC_CHECK_PROG(XSLTPROC, xsltproc, xsltproc, not found) if test "$XSLTPROC" = "not found"; then AC_MSG_WARN(xsltproc is needed for opp_neddoc.) AC_MSG_WARN(You can get it from http://xmlsoft.org/XSLT/) fi #---------------------- # Checks for standard libraries. #---------------------- SYS_LIBS="" # math functions OPP_CHECK_LIB(math, math.h, floor(0), , , math_ok) if test $math_ok = no; then OPP_CHECK_LIB(math, math.h, floor(0), , -lm, math_ok, SYS_LIBS="-lm $SYS_LIBS") fi if test $math_ok = no; then AC_MSG_ERROR([standard C math library -lm not found]) fi # -lstdc++ OPP_CHECK_LIB(standard C++ lib, iostream, /**/, , -lstdc++, stdcpp_ok, SYS_LIBS="-lstdc++ $SYS_LIBS") if test $stdcpp_ok = no; then OPP_CHECK_LIB(standard C++ lib, iostream, /**/, , -lcxx, stdcpp_ok, SYS_LIBS="-lcxx $SYS_LIBS") fi if test $stdcpp_ok = no; then AC_MSG_ERROR([standard C++ library -lstdc++ or -lcxx not found]) fi # dlopen() OPP_CHECK_LIB(dlopen, dlfcn.h, dlopen("",0), , , dl_ok) if test $dl_ok = no; then OPP_CHECK_LIB(dlopen, dlfcn.h, dlopen("",0), , -ldl, dl_ok, SYS_LIBS="-ldl $SYS_LIBS") fi if test $dl_ok = yes; then HAVE_DLOPEN=1 else HAVE_DLOPEN=0 AC_MSG_WARN([no dlopen(): dynamic loading of libs not possible]) fi #---------------------- # Check for wish. #---------------------- AC_CHECK_PROGS(WISH, $WISH wish wish84 wish83 wish82 cygwish cygwish84 cygwish83 cygwish82, nope) if test "$WISH" = nope -a ! "$PLOVE_EMBED_TCL" = yes; then AC_MSG_WARN([cannot find wish, part of Tcl/Tk - Plove will not work]) fi #---------------------- # Check for Tcl/Tk. #---------------------- OPP_CHECK_LIB(Tcl/Tk, tk.h, Tk_MainLoop(), $TK_CFLAGS, $TK_LIBS, tcltk_ok) if test $tcltk_ok = no; then # try to find Tcl/Tk ourselves, but it usually needs to link with Xlib AC_PATH_X if test "$no_x" = "yes"; then opp_x11inc= opp_x11lib= else if test -n "$x_includes"; then opp_x11inc="-I$x_includes" fi if test -n "$x_libraries"; then opp_x11lib="-L$x_libraries -lX11" fi fi fi if test $tcltk_ok = no; then OPP_CHECK_LIB(Tcl/Tk, tk.h, Tk_MainLoop(), $opp_x11inc $TK_CFLAGS, $opp_x11lib -ltk84 -ltcl84, tcltk_ok, TK_LIBS="$opp_x11lib -ltk84 -ltcl84") fi if test $tcltk_ok = no; then OPP_CHECK_LIB(Tcl/Tk, tk.h, Tk_MainLoop(), $opp_x11inc $TK_CFLAGS, $opp_x11lib -ltk8.4 -ltcl8.4, tcltk_ok, TK_LIBS="$opp_x11lib -ltk8.4 -ltcl8.4") fi if test $tcltk_ok = no -a "$cygwin" = yes; then OPP_CHECK_LIB(Tcl/Tk, tk.h, Tk_MainLoop(), $opp_x11inc $TK_CFLAGS, $opp_x11lib -lcygtk84 -lcygtcl84, tcltk_ok, TK_LIBS="$opp_x11lib -lcygtk84 -lcygtcl84") fi if test $tcltk_ok = no; then OPP_CHECK_LIB(Tcl/Tk, tk.h, Tk_MainLoop(), $opp_x11inc $TK_CFLAGS, $opp_x11lib -ltk83 -ltcl83, tcltk_ok, TK_LIBS="$opp_x11lib -ltk83 -ltcl83") fi if test $tcltk_ok = no; then OPP_CHECK_LIB(Tcl/Tk, tk.h, Tk_MainLoop(), $opp_x11inc $TK_CFLAGS, $opp_x11lib -ltk8.3 -ltcl8.3, tcltk_ok, TK_LIBS="$opp_x11lib -ltk8.3 -ltcl8.3") fi if test $tcltk_ok = no -a "$cygwin" = yes; then OPP_CHECK_LIB(Tcl/Tk, tk.h, Tk_MainLoop(), $opp_x11inc $TK_CFLAGS, $opp_x11lib -lcygtk83 -lcygtcl83, tcltk_ok, TK_LIBS="$opp_x11lib -lcygtk83 -lcygtcl83") fi if test $tcltk_ok = no; then OPP_CHECK_LIB(Tcl/Tk, tk.h, Tk_MainLoop(), $opp_x11inc $TK_CFLAGS, $opp_x11lib -ltk82 -ltcl82, tcltk_ok, TK_LIBS="$opp_x11lib -ltk82 -ltcl82") fi if test $tcltk_ok = no; then OPP_CHECK_LIB(Tcl/Tk, tk.h, Tk_MainLoop(), $opp_x11inc $TK_CFLAGS, $opp_x11lib -ltk8.2 -ltcl8.2, tcltk_ok, TK_LIBS="$opp_x11lib -ltk8.2 -ltcl8.2") fi if test $tcltk_ok = yes; then TKENV_IF_POSSIBLE=tkenv GNED_IF_POSSIBLE=gned PLOVE_IF_POSSIBLE=plove else TKENV_IF_POSSIBLE=missing-library GNED_IF_POSSIBLE=missing-library PLOVE_IF_POSSIBLE=missing-library if test "$no_x" = "yes"; then if test "$cygwin" = yes; then AC_MSG_ERROR([cannot build Tcl/Tk apps, probably due to missing X11 headers -- try installing the XFree86 packages or get the X headers from the OMNeT++ site]) else AC_MSG_ERROR([cannot build Tcl/Tk apps, probably due to misconfigured or missing X11 headers or libs]) fi else AC_MSG_ERROR([Tcl/Tk not found, needed for all GUI parts; version 8.2+ needed]) fi fi #---------------------- # Check for MPI. #---------------------- OPP_CHECK_LIB(MPI, mpi.h, MPI_Init(0,0), $MPI_CFLAGS, $MPI_LIBS, mpi_ok) if test $mpi_ok = yes; then SIM_MPI_IF_POSSIBLE=sim_mpi else SIM_MPI_IF_POSSIBLE=missing-mpi-library fi #---------------------- # Check for PVM. #---------------------- OPP_CHECK_LIB(PVM, pvm3.h, pvm_joingroup(""), $PVM_CFLAGS, $PVM_LIBS, pvm_ok) if test $pvm_ok = yes; then SIM_PVM_IF_POSSIBLE=sim_pvm else SIM_PVM_IF_POSSIBLE=missing-pvm-library fi #---------------------- # Check for XML parsers: EXPAT and/or LIBXML #---------------------- OPP_CHECK_LIB(Expat XML parser, expat.h, XML_ParserCreate(0), $EXPAT_CFLAGS, $EXPAT_LIBS, expat_ok) OPP_CHECK_LIB(LibXML XML parser, libxml/parser.h, xmlInitParser(), $LIBXML_CFLAGS, $LIBXML_LIBS, libxml_ok) if test $libxml_ok = no; then OPP_CHECK_LIB(LibXML XML parser, libxml/parser.h, xmlInitParser(), $LIBXML_CFLAGS, -lxml2, libxml_ok, LIBXML_LIBS="-lxml2") fi if test $libxml_ok = no; then # for Cygwin: OPP_CHECK_LIB(LibXML XML parser, libxml/parser.h, xmlInitParser(), -I/usr/include/libxml2, $LIBXML_LIBS, libxml_ok, LIBXML_CFLAGS="-I/usr/include/libxml2") fi if test $expat_ok = yes; then AC_MSG_NOTICE([Using Expat for XML parsing in NEDXML.]) XMLPARSER=expat XML_CFLAGS=$EXPAT_CFLAGS XML_LIBS=$EXPAT_LIBS elif test $libxml_ok = yes; then AC_MSG_NOTICE([Using LIBXML for XML parsing in NEDXML.]) XMLPARSER=libxml XML_CFLAGS=$LIBXML_CFLAGS XML_LIBS=$LIBXML_LIBS else XMLPARSER=none AC_MSG_WARN([No suitable XML parser: nedtool and NEDXML lib won't support XML input]) fi #---------------------- # Check for Akaroa header and lib #---------------------- OPP_CHECK_LIB(Akaroa, akaroa.H, AkObservation(0.0), $AKAROA_CFLAGS, $AKAROA_LIBS, akaroa_ok) if test $akaroa_ok = yes; then CFLAGS="$CFLAGS -DWITH_AKAROA" SYS_LIBS="$SYS_LIBS $AKAROA_LIBS" fi #---------------------- # Linker flags #---------------------- # on NT, set total stack size if test "$cygwin" = yes; then LDFLAGS="$LDFLAGS -s -Xlinker --stack -Xlinker $CYGWIN_STACKSIZE" fi #---------------------- # shared or static libraries #---------------------- # If you change this setting, remember to delete the other set of libraries # (or at least the soft links from lib/). if test "$build_shared_libs" = if-not-cygwin; then if test "$cygwin" = yes; then build_shared_libs=no else build_shared_libs=yes fi fi if test "$build_shared_libs" = yes; then LIB_SUFFIX='$(SO_LIB_SUFFIX)' if test "$cygwin" = yes; then CFLAGS="$CFLAGS -DWIN32_DLL" else CFLAGS="$CFLAGS $SHLIB_CFLAGS" fi else LIB_SUFFIX='$(A_LIB_SUFFIX)' fi #---------------------- # Tcl code embedding. #---------------------- if test "$TKENV_EMBED_TCL" = yes; then TKENV_EMBED_SUFFIX=-e else TKENV_EMBED_SUFFIX= fi if test "$GNED_EMBED_TCL" = yes; then GNED_EMBED_SUFFIX=-e else GNED_EMBED_SUFFIX= fi if test "$PLOVE_EMBED_TCL" = yes; then PLOVE_VARIANT=plove-exe elif test "$cygwin" = yes; then PLOVE_VARIANT=plove-cyg else PLOVE_VARIANT=plove-sh fi #---------------------- # Files to be generated #---------------------- AC_CONFIG_FILES( Makefile src/cmdenv/Makefile src/envir/Makefile src/gned/Makefile src/nedxml/Makefile src/nedc/Makefile src/plove/Makefile src/sim/Makefile src/tkenv/Makefile src/utils/Makefile src/utils/opp_makemake src/utils/opp_neddoc samples/dyna/Makefile samples/dyna2/Makefile samples/fddi/Makefile samples/fifo1/Makefile samples/fifo2/Makefile samples/hcube/Makefile samples/hist/Makefile samples/nim/Makefile samples/token/Makefile samples/topo/Makefile samples/demo/Makefile tutorial/queues/Makefile include/Makefile test/Makefile ) #---------------------- # Substitutions. #---------------------- AC_SUBST(OMNETPP_VERSION) AC_SUBST(OMNETPP_BIN_DIR) AC_SUBST(OMNETPP_INCL_DIR) AC_SUBST(OMNETPP_LIB_DIR) AC_SUBST(OMNETPP_BITMAP_PATH) AC_SUBST(OMNETPP_SRC_DIR) AC_SUBST(OMNETPP_UTILS_DIR) AC_SUBST(OMNETPP_DOC_DIR) AC_SUBST(OMNETPP_SAMPLES_DIR) AC_SUBST(OMNETPP_TUTORIAL_DIR) AC_SUBST(OMNETPP_TEST_DIR) dnl AC_SUBST(OMNETPP_MODELS_DIR) AC_SUBST(YACC) AC_SUBST(LEX) AC_SUBST(CC) AC_SUBST(CXX) AC_SUBST(CPPFLAGS) AC_SUBST(MYPWD) AC_SUBST(NEDC) AC_SUBST(MSGC) AC_SUBST(NEDCFLAGS) AC_SUBST(AS) AC_SUBST(AR) AC_SUBST(RANLIB) AC_SUBST(SHLIB_LD) AC_SUBST(WISH) AC_SUBST(MAKEDEPEND) AC_SUBST(DOXYGEN) AC_SUBST(A_LIB_SUFFIX) AC_SUBST(SO_LIB_SUFFIX) AC_SUBST(LIB_SUFFIX) AC_SUBST(EXE_SUFFIX) AC_SUBST(HAVE_DLOPEN) AC_SUBST(TK_CFLAGS) AC_SUBST(TK_LIBS) AC_SUBST(MPI_CFLAGS) AC_SUBST(MPI_LIBS) AC_SUBST(PVM_CFLAGS) AC_SUBST(PVM_LIBS) AC_SUBST(SYS_LIBS) AC_SUBST(XMLPARSER) AC_SUBST(XML_CFLAGS) AC_SUBST(XML_LIBS) AC_SUBST(AKAROA_CFLAGS) AC_SUBST(AKAROA_LIBS) AC_SUBST(TKENV_IF_POSSIBLE) AC_SUBST(GNED_IF_POSSIBLE) AC_SUBST(PLOVE_IF_POSSIBLE) AC_SUBST(SIM_PVM_IF_POSSIBLE) AC_SUBST(SIM_MPI_IF_POSSIBLE) AC_SUBST(TKENV_EMBED_SUFFIX) AC_SUBST(GNED_EMBED_SUFFIX) AC_SUBST(PLOVE_VARIANT) AC_SUBST(OMNETPP_TKENV_DIR) AC_SUBST(OMNETPP_GNED_DIR) AC_SUBST(OMNETPP_PLOVE_DIR) # # Generate files # AC_OUTPUT chmod +x src/utils/opp_makemake chmod +x src/utils/opp_test chmod +x src/utils/opp_makedep chmod +x src/utils/opp_neddoc #---------------------- # Check if the path contains omnetpp/bin (it should) # Note: the method used here also works with Cygwin, but requires # write permission to $OMNETPP_BIN_DIR. #---------------------- # first we need to expand the ${HOME} variable and make sure the dir exists.. omnetpp_bin_dir=`eval echo $OMNETPP_BIN_DIR` if test ! -d $omnetpp_bin_dir; then echo "PROBLEM: the $OMNETPP_BIN_DIR directory does not exist!" else # ...then we create a small tmp file to check if the dir is in the path probefile=__probe__ echo '' >$omnetpp_bin_dir/$probefile chmod +x $omnetpp_bin_dir/$probefile if ($probefile) >/dev/null 2>/dev/null; then echo "Your PATH contains $OMNETPP_BIN_DIR. Good!" else if test "$cygwin" = yes; then opp_bin_dir=`cygpath -u $OMNETPP_BIN_DIR` if test -z "$opp_bin_dir"; then opp_bin_dir=$OMNETPP_BIN_DIR; fi cat 1>&2 << EOT WARNING: your PATH doesn't contain $opp_bin_dir! Add the following line to your startup file, $HOME/.bash_profile: export PATH=\$PATH:$opp_bin_dir EOT else cat 1>&2 << EOT WARNING: your PATH doesn't contain $OMNETPP_BIN_DIR! Add the following line to your startup file: export PATH=\$PATH:$OMNETPP_BIN_DIR # .(bash_)profile if you use sh/bash setenv PATH \$PATH:$OMNETPP_BIN_DIR # .cshrc if you use csh,tcsh etc. EOT fi fi rm $omnetpp_bin_dir/$probefile fi #---------------------- # Check LD_LIBRARY path if we're building shared libs. This is not necessary # with Cygwin because Windows locates DLLs another way. #---------------------- if test "$build_shared_libs" = yes -a "$cygwin" != yes; then if echo $LD_LIBRARY_PATH | grep `eval echo $OMNETPP_LIB_DIR` >/dev/null; then echo "Your LD_LIBRARY_PATH is set. Good!" else cat 1>&2 << EOT WARNING: You selected shared libraries in configure.user, but your LD_LIBRARY_PATH doesn't seem to contain $OMNETPP_LIB_DIR! So that the dynamic linker can find the OMNeT++ shared libs, you either have to create symbolic links from /usr/lib to the OMNeT++ shared libraries (you can do it as root), or better, set the LD_LIBRARY_PATH environment variable. Add the corresponding line to your startup file: export LD_LIBRARY_PATH=\$LD_LIBRARY_PATH:$OMNETPP_LIB_DIR # into .(bash_)profile if you use bash or other sh-like shell setenv LD_LIBRARY_PATH \$LD_LIBRARY_PATH:$OMNETPP_LIB_DIR # into .cshrc if you use tcsh or other csh-like shell If you prefer static libraries, edit configure.user and change the build_shared_libs=yes line to build_shared_libs=no, then delete the shared libraries, re-run configure and make. EOT fi fi