Statistics
| Branch: | Revision:

root / configure.in @ master

History | View | Annotate | Download (48.9 KB)

1
# NOTE: set UNIVERSAL_BINARIES=yes to build universal binaries on Mac OS X 10.5
2
# NOTE: set TOOLCHAIN=mingw to use the MINGW compiler to cross compile to Windows on Linux
3

    
4
dnl Process this file with autoconf to produce a configure script.
5

    
6
dnl
7
dnl OPP_CHECK_LIB(      -- macro to check availability of a library
8
dnl   $1: LIBRARY-NAME, -- descriptive name (only for printout)
9
dnl   $2: HEADER,       -- optional: header file to #include
10
dnl   $3: FUNCTION,     -- optional: function WITH ARG LIST, e.g. floor(0.5)
11
dnl   $4: CFLAGS,       -- optional: compiler flags
12
dnl   $5: LDFLAGS,      -- optional: linker flags
13
dnl   $6: RESULT-VAR    -- will contain "yes" or "no"
14
dnl   $7: ACTION-IF-FOUND
15
dnl   $8: ACTION-IF-NOT-FOUND
16
dnl )
17
dnl
18
AC_DEFUN(OPP_CHECK_LIB,[
19
   save_CXXFLAGS=$CXXFLAGS
20
   save_LIBS=$LIBS
21

    
22
   CXXFLAGS="$4"
23
   LIBS="$5"
24

    
25
   AC_MSG_CHECKING(for $1 with CFLAGS="$4" LIBS="$5")
26

    
27
   AC_LINK_IFELSE(
28
     [AC_LANG_PROGRAM([[#include <$2>]], [[$3;]])],
29
     [AC_MSG_RESULT(yes); $6=yes; $7],
30
     [AC_MSG_RESULT(no); $6=no; $8])
31

    
32
   CXXFLAGS=$save_CXXFLAGS
33
   LIBS=$save_LIBS
34
])
35

    
36
dnl
37
dnl Same as OPP_CHECK_LIB(), but also tries to run the program (uses
38
dnl AC_RUN_IFELSE instead of AC_LINK_IFELSE).
39
dnl
40
dnl OPP_CHECK_AND_RUN_LIB(      -- macro to check availability of a library
41
dnl   $1: LIBRARY-NAME, -- descriptive name (only for printout)
42
dnl   $2: HEADER,       -- optional: header file to #include
43
dnl   $3: FUNCTION,     -- optional: function WITH ARG LIST, e.g. floor(0.5)
44
dnl   $4: CFLAGS,       -- optional: compiler flags
45
dnl   $5: LDFLAGS,      -- optional: linker flags
46
dnl   $6: RESULT-VAR    -- will contain "yes" or "no"
47
dnl   $7: ACTION-IF-FOUND
48
dnl   $8: ACTION-IF-NOT-FOUND
49
dnl )
50
dnl
51
AC_DEFUN(OPP_CHECK_AND_RUN_LIB,[
52
   save_CXXFLAGS=$CXXFLAGS
53
   save_LIBS=$LIBS
54

    
55
   CXXFLAGS="$4"
56
   LIBS="$5"
57

    
58
   AC_MSG_CHECKING(for $1 with CFLAGS="$4" LIBS="$5")
59

    
60
   AC_RUN_IFELSE(
61
     [AC_LANG_PROGRAM([[#include <$2>]], [[$3;]])],
62
     [AC_MSG_RESULT(yes); $6=yes; $7],
63
     [AC_MSG_RESULT(no); $6=no; $8])
64

    
65
   CXXFLAGS=$save_CXXFLAGS
66
   LIBS=$save_LIBS
67
])
68

    
69
dnl
70
dnl OPP_CHECK_LIB_NOLINK(      -- macro to check availability of a library
71
dnl   $1: LIBRARY-NAME, -- descriptive name (only for printout)
72
dnl   $2: HEADER,       -- optional: header file to #include
73
dnl   $3: FUNCTION,     -- optional: function WITH ARG LIST, e.g. floor(0.5)
74
dnl   $4: CFLAGS,       -- optional: compiler flags
75
dnl   $5: RESULT-VAR    -- will contain "yes" or "no"
76
dnl   $6: ACTION-IF-FOUND
77
dnl   $7: ACTION-IF-NOT-FOUND
78
dnl )
79
dnl
80
AC_DEFUN(OPP_CHECK_LIB_NOLINK,[
81
   save_CXXFLAGS=$CXXFLAGS
82
   CXXFLAGS="$4"
83

    
84
   AC_MSG_CHECKING(for $1 with CFLAGS="$4")
85

    
86
   AC_TRY_COMPILE(
87
     [#include <$2>], [$3;],
88
     [AC_MSG_RESULT(yes); $5=yes; $6],
89
     [AC_MSG_RESULT(no); $5=no; $7])
90

    
91
   CXXFLAGS=$save_CXXFLAGS
92
])
93

    
94
# usage: AC_PROG_CC_OPTION(--compiler-option, if-supported, if-unsupported)
95
# add this option to $(CC) if it is supported by the compiler
96
# if no sc
97
# Martin Waitz <tali@admingilde.org>
98
AC_DEFUN([AC_PROG_CXX_OPTION], [
99
    AC_MSG_CHECKING([whether $CXX supports $1])
100
    ac_save_CXX="$CXX"
101
    CXX="$CXX $1"
102
    AC_COMPILE_IFELSE(AC_LANG_PROGRAM(),[
103
        AC_MSG_RESULT([yes])
104
        ifelse($2, , [], [
105
        CXX="$ac_save_CXX"
106
        $2])
107
    ], [
108
        AC_MSG_RESULT([no])
109
        CXX="$ac_save_CXX"
110
        $3
111
    ])
112
])
113

    
114
#
115
# Autoconf initialization
116
#
117
AC_INIT
118
AC_CONFIG_SRCDIR(include/omnetpp.h)
119
AC_LANG(C++)
120
AC_CONFIG_AUX_DIR(src/utils)
121
AC_CANONICAL_HOST()
122

    
123
#
124
# OMNeT++/OMNEST version number
125
#
126
OMNETPP_PRODUCT="OMNeT++"
127
OMNETPP_RELEASE=`cat Version`
128
OMNETPP_VERSION=`cat Version | sed 's/^.*-//'`
129
OMNETPP_BUILDID="100611-4b63c38"
130
OMNETPP_EDITION="Academic Public License -- NOT FOR COMMERCIAL USE"
131

    
132
# We'll collect in this variable the components we've detected problems with
133
OPP_PROBLEM_PACKAGES=
134

    
135
#
136
# Location of various components. They are defined here so that they can be overridden in configure.user.
137
#
138

    
139
# determine OMNETPP_ROOT; note that 'case' branches on *host* platform not the target platform
140
case $host in
141
*-*-cygwin*)
142
    OMNETPP_ROOT=`cygpath -w $OMNETPP_ROOT | sed 's|\\\\|/|g'`
143
    ;;
144
*-*-mingw32*)
145
    OMNETPP_ROOT=`pwd -W`
146
    ;;
147
*)
148
    OMNETPP_ROOT=`pwd`
149
    ;;
150
esac
151

    
152
OMNETPP_SRC_DIR="$OMNETPP_ROOT/src"
153
OMNETPP_UI_DIR="$OMNETPP_ROOT/ui"
154
OMNETPP_UTILS_DIR="$OMNETPP_SRC_DIR/utils"
155
OMNETPP_DOC_DIR="$OMNETPP_ROOT/doc"
156
OMNETPP_TEST_DIR="$OMNETPP_ROOT/test"
157
OMNETPP_IMAGE_PATH="./bitmaps;./images;$OMNETPP_ROOT/images"
158

    
159
OMNETPP_BIN_DIR="$OMNETPP_ROOT/bin"
160
OMNETPP_INCL_DIR="$OMNETPP_ROOT/include"
161
OMNETPP_OUT_DIR="$OMNETPP_ROOT/out"
162
OMNETPP_LIB_DIR="$OMNETPP_ROOT/lib"
163

    
164
OMNETPP_TKENV_DIR="$OMNETPP_SRC_DIR/tkenv"
165

    
166
if test "$cygwin" = yes; then
167
    MYPWD="$OMNETPP_SRC_DIR/utils/cygpwd"
168
else
169
    MYPWD="pwd"
170
fi
171

    
172
#----------------------
173
# Read user settings (and allow override the above settings)
174
#----------------------
175
AC_MSG_NOTICE(-----------------------------------------------)
176
AC_MSG_NOTICE(reading configure.user for your custom settings)
177
AC_MSG_NOTICE(-----------------------------------------------)
178
. ./configure.user
179

    
180

    
181
#
182
# set default library suffixes. May be already defined
183
# with system/arch specific values
184
#
185
A_LIB_SUFFIX=${A_LIB_SUFFIX:-".a"}
186
SO_LIB_SUFFIX=${SO_LIB_SUFFIX:-".so"}
187
DLL_LIB_SUFFIX=${DLL_LIB_SUFFIX:-".dll"}
188
EXE_SUFFIX=
189
SHARED_LIB_SUFFIX='$(SO_LIB_SUFFIX)'
190
LIB_PREFIX="lib"
191

    
192
#
193
#  Figure out target platform
194
#
195
if test "$TOOLCHAIN" = "mingw"; then
196
    # cross compiling for mingw
197
    mingw=yes
198
    jni_platform=win32
199
    PLATFORM=win32.x86
200
    EXE_SUFFIX=".exe"
201
    SHARED_LIB_SUFFIX='$(DLL_LIB_SUFFIX)'
202
    LDFLAGS_ARCH="$LDFLAGS_ARCH -enable-auto-import -shared-libgcc"
203
else
204
    jni_platform=$host_os
205
    case $host in
206
    *-*-cygwin*)
207
        cygwin=yes
208
        jni_platform=win32
209
        PLATFORM=win32.x86
210
        EXE_SUFFIX=".exe"
211
        SHARED_LIB_SUFFIX='$(DLL_LIB_SUFFIX)'
212
        # on NT, set total stack size
213
        LDFLAGS_ARCH="$LDFLAGS_ARCH -Xlinker --stack -Xlinker $CYGWIN_STACKSIZE"
214
        ;;
215
    *-*-mingw32*)
216
        mingw=yes
217
        jni_platform=win32
218
        PLATFORM=win32.x86
219
        EXE_SUFFIX=".exe"
220
        SHARED_LIB_SUFFIX='$(DLL_LIB_SUFFIX)'
221
        # add default include and lib paths to make it similar to gcc on Linux
222
        CFLAGS_ARCH="$CFLAGS_ARCH -I/usr/include"
223
        # on MinGW dll auto importing is used and must be linked with shared gcc and stdc++
224
        # otherwise exceptions cant be thrown across dll boundaries
225
        LDFLAGS_ARCH="$LDFLAGS_ARCH -enable-auto-import -shared-libgcc -L/usr/bin -L/usr/lib"
226
        ;;
227
    x86_64-*-linux*)
228
        jni_platform=linux
229
        PLATFORM=linux.x86_64
230
        ;;
231
    *-linux*)
232
        jni_platform=linux
233
        PLATFORM=linux.x86
234
        ;;
235
    *darwin*)
236
        jni_platform=
237
        PLATFORM=macosx
238
        SO_LIB_SUFFIX=".dylib"
239
        JNI_LIB_SUFFIX=".jnilib"
240
        if test "$UNIVERSAL_BINARIES" = "yes"; then
241
           CFLAGS_ARCH="$CFLAGS_ARCH -arch ppc -arch i386"
242
           LDFLAGS_ARCH="$LDFLAGS_ARCH -arch ppc -arch i386"
243
        fi
244
        # CDT 6.x does not support 64 bit debugging so we force
245
        # the compiler to build 32 bit executable because on OS X 10.6,
246
        # gcc builds 64 bit executables by default. After upgrading to
247
        # CDT 7.0 these lines can be removed.
248
        CFLAGS_ARCH="$CFLAGS_ARCH -m32"
249
        LDFLAGS_ARCH="$LDFLAGS_ARCH -m32"
250
        ;;
251
    *)
252
        ;;
253
    esac
254
fi
255

    
256
JNI_LIB_SUFFIX=${JNI_LIB_SUFFIX:-$SHARED_LIB_SUFFIX}
257

    
258
# total stack size on NT defaults to 128MB (will be added to LDFLAGS later):
259
CYGWIN_STACKSIZE=${CYGWIN_STACKSIZE:-134217728}
260

    
261
# Build shared library by default
262
SHARED_LIBS=${SHARED_LIBS:-yes}
263

    
264
#----------------------
265
# Default flags for values for other variables that come from configure.user.
266
#----------------------
267
#----------------------
268
# pthread for Horizon
269
#----------------------
270

    
271
PTHREAD_CFLAGS="-I /usr/include"
272
PTHREAD_LIBS="-lpthread"
273
#----------------------
274
# Set variables to defaults if not already set.
275
# Note: ${VAR:-defaultvalue} used below appears to be a POSIX syntax.
276
#----------------------
277
# on mingw special debug option is needed to debug with gdb.
278
if test "$mingw" = "yes"; then
279
  CFLAGS_DEBUG=${CFLAGS_DEBUG:- -gstabs+ -Wall}
280
else
281
  CFLAGS_DEBUG=${CFLAGS_DEBUG:- -g -Wall}
282
fi
283

    
284
CFLAGS_RELEASE=${CFLAGS_RELEASE:- -O2 -DNDEBUG=1}
285

    
286
WHOLE_ARCHIVE_ON=
287
WHOLE_ARCHIVE_OFF=
288

    
289
MSGC=${MSGC:-opp_msgc}
290
NEDTOOL=${NEDTOOL:-nedtool}
291
MAKEDEPEND=${MAKEDEPEND:-opp_makedep -Y --objdirtree}
292
LN=${LN:-ln -sf}
293
MKPATH=${MKPATH:-mkdir -p}
294
SHLIB_POSTPROCESS=${SHLIB_POSTPROCESS:-opp_shlib_postprocess}
295

    
296
#----------------------
297
# Check compiler
298
#----------------------
299

    
300
if test "$TOOLCHAIN" = "mingw"; then
301
    cc_candidates="i586-mingw32msvc-gcc"
302
    cxx_candidates="i586-mingw32msvc-g++"
303
else
304
    # icc, icpc: Intel compiler (further ones: Sun Studio: cxx, IBM: xlC)
305
    cc_candidates="icc gcc cc xlc"
306
    cxx_candidates="icpc g++ c++ cxx xlC"
307
fi
308

    
309
# the below macros should be present only ONCE in the whole file (otherwise bad things will happen)
310
AC_PROG_CC($cc_candidates)
311
AC_PROG_CXX($cxx_candidates)
312

    
313
AC_CHECK_PROG(tmp_CXX, $CXX, $CXX, not found)
314
if test "$tmp_CXX" = "not found"; then
315
   OPP_PROBLEM_PACKAGES="$OPP_PROBLEM_PACKAGES g++"
316
   AC_MSG_ERROR([No C++ compiler found -- one is required to build OMNeT++/OMNEST, and also for model development.])
317
fi
318

    
319
if test "$TOOLCHAIN" = "mingw"; then
320
    AS=${AS:-i586-mingw32msvc-as}
321
    AR=${AR:-i586-mingw32msvc-ar cr}
322
    SHLIB_LD=${SHLIB_LD:-$CXX -shared}
323
    DLLTOOL=${DLLTOOL:-i586-mingw32msvc-dlltool}
324
    STRIP=${STRIP:-i586-mingw32msvc-strip}
325
    RANLIB=${RANLIB:-i586-mingw32msvc-ranlib}
326
else
327
    if test "$CXX" = "icpc"; then
328
        # disable useless warnings and 'remarks' with the Intel compiler:
329
        #
330
        # warning #654: overloaded virtual function "NEDElement::setAttribute" is only partially overridden
331
        # warning #177: label "yyerrlab1" was declared but never referenced
332
        # remark #869: parameter "node" was never referenced
333
        # remark #981: operands are evaluated in unspecified order
334
        # remark #279: controlling expression is constant  (occurs in unfinished cppmsggenerator.cc code)
335
        # remark #1572: floating-point equality and inequality comparisons are unreliable
336
        # remark #424: extra ";" ignored
337
        # remark #1682: implicit conversion of a 64-bit integral type to a smaller integral type (potential portability..
338
        # remark #1683: explicit conversion of a 64-bit integral type to a smaller integral type (potential portability..
339
        # remark #810: conversion from "unsigned int" to "char" may lose significant bits
340
        # remark #810: conversion from "long" to "double" may lose significant bits
341
        # remark #1418: external definition with no prior declaration
342
        # remark #1419: external declaration in primary source file
343
        # remark #383: value copied to temporary, reference to temporary used
344
        #
345
        #CFLAGS="$CFLAGS -wd654 -wd177 -wd869 -wd981 -wd279 -wd1572 -wd424 -wd1682 -wd1683 -wd810 -wd1418 -wd1419"
346

    
347
        # -w1 disables all remarks
348
        CFLAGS_DEBUG="$CFLAGS_DEBUG -w1 -wd654 -wd177"
349
        CFLAGS_RELEASE="$CFLAGS_RELEASE -w1 -wd654 -wd177"
350
    fi
351
    AS=${AS:-as}
352
    AR=${AR:-ar cr}
353
    if test "$PLATFORM" = "macosx"; then
354
        SHLIB_LD=${SHLIB_LD:-$CXX -dynamiclib}
355
    else
356
        SHLIB_LD=${SHLIB_LD:-$CXX -shared}
357
    fi
358
    DLLTOOL=${DLLTOOL:-dlltool}
359
    STRIP=${STRIP:-strip}
360
    AC_PROG_RANLIB
361
fi
362

    
363

    
364
# determine toolchain name, used in opp_makemake-generated Makefiles as part of the linker path
365
if test "$TOOLCHAIN_NAME" = ""; then
366
    if test "$mingw" = yes; then
367
        TOOLCHAIN_NAME="gcc"
368
    elif test "$cygwin" = yes; then
369
        TOOLCHAIN_NAME="cygwin"
370
    else
371
        # toolchain name: compiler ($CC) without path
372
        # note: doubling the brackets is needed, otherwise M4 swallows them!
373
        TOOLCHAIN_NAME=`echo $CC | sed 's!^.*/!!g' | sed 's![[ :]]!_!'g`
374
    fi
375
fi
376

    
377
#----------------------
378
# check and disable stack checking to avoid opplibs.so dependence on glibc 2.4
379
#----------------------
380
AC_PROG_CXX_OPTION(-fno-stack-protector, CFLAGS_RELEASE="$CFLAGS_RELEASE -fno-stack-protector")
381
AC_PROG_CXX_OPTION(-fno-stack-protector, CFLAGS_DEBUG="$CFLAGS_DEBUG -fno-stack-protector")
382

    
383
#----------------------
384
# Test if "-fPIC" is needed for shared libs (there's a performance penalty if we use it unnecessarily)
385
#----------------------
386
# To test, we try to compile the following code into a shared library:
387
#      int x;
388
#      int getX() {return x;}
389
#
390

    
391
AC_MSG_CHECKING(if shared libs need -fPIC)
392
echo 'int x;' >conftest.cc
393
echo 'int getX() {return x;}' >>conftest.cc
394
fpic="x"
395
if echo $CFLAGS_DEBUG | grep -i -- "-fPIC" >/dev/null 2>/dev/null; then
396
   if echo $CFLAGS_RELEASE | grep -i -- "-fPIC" >/dev/null 2>/dev/null; then
397
        AC_MSG_RESULT([skip (already in CFLAGS)])
398
        fpic=""
399
   fi
400
fi
401
if test "$fpic" = "x" && \
402
   $CXX -c conftest.cc >/dev/null 2>/dev/null && \
403
   $SHLIB_LD -o conftest.so conftest.o >/dev/null 2>/dev/null; \
404
then
405
   AC_MSG_RESULT(no)
406
   fpic=""
407
fi
408
if test "$fpic" = "x" && \
409
   $CXX -fPIC -c conftest.cc >/dev/null 2>/dev/null && \
410
   $SHLIB_LD -fPIC -o conftest.so conftest.o >/dev/null 2>/dev/null; \
411
then
412
   AC_MSG_RESULT(yes)
413
   fpic="-fPIC"
414
fi
415
if test "$fpic" = "x" && \
416
   $CXX -fpic -c conftest.cc >/dev/null 2>/dev/null && \
417
   $SHLIB_LD -fpic -o conftest.so conftest.o >/dev/null 2>/dev/null; \
418
then
419
   AC_MSG_RESULT(-fpic)
420
   fpic="-fpic"
421
fi
422
if test "$fpic" = "x"; then
423
   AC_MSG_RESULT(failure)
424
   AC_MSG_WARN([COULD NOT FIGURE OUT HOW TO BUILD SHARED LIBRARY -- reverting to static libs])
425
   SHARED_LIBS="no"
426
else
427
   CFLAGS_DEBUG="$CFLAGS_DEBUG $fpic"
428
   CFLAGS_RELEASE="$CFLAGS_RELEASE $fpic"
429
   SHLIB_LD="$SHLIB_LD $fpic"
430
fi
431
rm -f conftest.*
432

    
433

    
434
#----------------------
435
# Test if --export-dynamic or -E linker option is accepted and/or needed
436
#----------------------
437
# We want to be able to dynamically load extensions into simulation executables,
438
# so we need to ensure that all symbols in the executable are visible to
439
# dynamically loaded libraries. However, not all linkers need or support
440
# --export-dynamic.
441
# Strategy: we'll compile the following program into a shared library:
442
#      void function_from_main();
443
#      void some_func() {func_from_main();}
444
# Then we *independently* compile with the following program:
445
#      #include <dlfcn.h>
446
#      void func_from_main() {}
447
#      int main() {return dlopen("libconftest_a.so",RTLD_NOW)==0;}
448
# And we expect to be able to run the program successfully.
449
#
450

    
451
# first check if we need "-ldl" for dlopen() [Laura Marie Feeney suggests it's not needed for FreeBSD]
452
OPP_CHECK_LIB(dlopen, dlfcn.h, dlopen("",0), , , ldl_not_needed, ldl="", ldl="-ldl")
453

    
454
# then go ahead
455
AC_MSG_CHECKING(if --export-dynamic linker option is supported/needed)
456
echo 'void func_from_main();' >conftest_a.cc
457
echo 'void some_func() {func_from_main();}' >>conftest_a.cc
458
echo '#include <dlfcn.h>' >conftest_m.cc
459
echo '#include <stdio.h>' >>conftest_m.cc
460
echo 'void func_from_main() {}' >>conftest_m.cc
461
echo 'int main() {if (dlopen("./libconftest_a.so",RTLD_NOW)!=0) return 0; printf("%s",dlerror()); return 1;}' >>conftest_m.cc
462
if $CXX -c conftest_a.cc >/dev/null 2>/dev/null && \
463
   $CXX -c conftest_m.cc >/dev/null 2>/dev/null && \
464
   $SHLIB_LD -o libconftest_a.so conftest_a.o >/dev/null 2>/dev/null; \
465
then
466
   silly_ok="no"
467
   # 1st try.
468
   if $CXX -o conftest conftest_m.o $ldl >/dev/null 2>/dev/null; then
469
      if ./conftest >/dev/null 2>/dev/null; then
470
         AC_MSG_RESULT(not needed)
471
         silly_ok="yes"
472
      fi
473
   fi
474
   # 2nd try.
475
   if test $silly_ok = "no" && \
476
      $CXX -o conftest -Wl,--export-dynamic conftest_m.o $ldl >/dev/null 2>/dev/null; \
477
   then
478
      if ./conftest >/dev/null 2>/dev/null; then
479
         AC_MSG_RESULT(both)
480
         LDFLAGS="$LDFLAGS -Wl,--export-dynamic"
481
         silly_ok="yes"
482
      fi
483
   fi
484
   # no solution found
485
   if test $silly_ok = "no"; then
486
      AC_MSG_RESULT(no solution found)
487
      AC_MSG_WARN([No way was detected to export symbols from executables to shared])
488
      AC_MSG_WARN([libraries. You probably will not be able to dynamically load])
489
      AC_MSG_WARN([simple modules or other extensions written in C++ into simulation])
490
      AC_MSG_WARN([programs like INET.])
491
   fi
492
else
493
   # note: expected failure on MinGW, because there's no dlopen().
494
   # fixing this would mean overturning and re-testing the whole configure script
495
   AC_MSG_RESULT(test failed)
496
fi
497
rm -f conftest_a.* conftest_m.* libconftest_a.so conftest
498

    
499
#----------------------
500
# Test for "-z allextract" (Sun) or "--whole-archive" (GNU) linker option,
501
#----------------------
502
# Goal: to eliminate "silly linker problem", that is, to convince the linker
503
# to include constructors of static C++ objects in statically linked libraries.
504
# To test, we'll compile the following code into a static library:
505
#      #include <stdio.h>
506
#      class A { public: A() {printf("=WORKS=");} };
507
#      static A a;
508
# Then we link it with the following program:
509
#      int main() {return 0;}
510
# And check if the executable prints '=WORKS=' when run.
511
#
512
AC_MSG_CHECKING(for flags needed to link with static libs containing simple modules)
513
echo '#include <stdio.h>' >conftest_a.cc
514
# NOTE: do not write "=WORKS=\n" because sh on OS X resolves it
515
echo 'class A { public: A() {printf("=WORKS=");} };' >>conftest_a.cc
516
echo 'static A a;' >> conftest_a.cc
517
echo 'int main() {return 0;}' >> conftest_m.cc
518
if $CXX -c conftest_a.cc >/dev/null 2>/dev/null && \
519
   $CXX -c conftest_m.cc >/dev/null 2>/dev/null && \
520
   $AR libconftest_a.a conftest_a.o >/dev/null 2>/dev/null && \
521
   $RANLIB libconftest_a.a >/dev/null 2>/dev/null; \
522
then
523
   silly_ok="no"
524
   # 1st try.
525
   if $CXX -o conftest conftest_m.o libconftest_a.a >/dev/null 2>/dev/null; then
526
      if ./conftest 2>/dev/null | grep '=WORKS=' >/dev/null; then
527
         AC_MSG_RESULT(none)
528
         silly_ok="yes"
529
      fi
530
   fi
531

    
532
   # 2nd try.
533
   silly1=-Wl,--whole-archive
534
   silly2=-Wl,--no-whole-archive
535
   if test $silly_ok = "no" && \
536
      $CXX -o conftest conftest_m.o $silly1 libconftest_a.a $silly2 >/dev/null 2>/dev/null && \
537
      ./conftest 2>/dev/null | grep '=WORKS=' >/dev/null; \
538
   then
539
      AC_MSG_RESULT(--whole-archive)
540
      AC_MSG_NOTICE([NOTE: Use the following syntax when linking with static libraries])
541
      AC_MSG_NOTICE([containing simple modules and other dynamically registered components:])
542
      AC_MSG_NOTICE([   $CXX ... $silly1 <libs> $silly2 ...])
543
      silly_ok="yes"
544
      WHOLE_ARCHIVE_ON=$silly1
545
      WHOLE_ARCHIVE_OFF=$silly2
546
   fi
547

    
548
   # 3rd try.
549
   silly1=-Wl,-z,allextract
550
   silly2=-Wl,-z,defaultextract
551
   if test $silly_ok = "no" && \
552
      $CXX -o conftest conftest_m.o $silly1 libconftest_a.a $silly2 >/dev/null 2>/dev/null && \
553
      ./conftest 2>/dev/null | grep '=WORKS=' >/dev/null; \
554
   then
555
      AC_MSG_RESULT([-z,allextract])
556
      AC_MSG_NOTICE([NOTE: Use the following syntax when linking with static libraries])
557
      AC_MSG_NOTICE([containing simple modules and other dynamically registered components:])
558
      AC_MSG_NOTICE([   $CXX ... $silly1 <libs> $silly2 ...])
559
      silly_ok="yes"
560
      WHOLE_ARCHIVE_ON=$silly1
561
      WHOLE_ARCHIVE_OFF=$silly2
562
   fi
563

    
564
   # 4th try.
565
   silly1=-Wl,-all_load
566
   silly2=
567
   if test $silly_ok = "no" && \
568
      $CXX -o conftest conftest_m.o $silly1 libconftest_a.a $silly2 >/dev/null 2>/dev/null && \
569
      ./conftest 2>/dev/null | grep '=WORKS=' >/dev/null; \
570
   then
571
      AC_MSG_RESULT([-all_load])
572
      AC_MSG_NOTICE([NOTE: Use the following syntax when linking with static libraries])
573
      AC_MSG_NOTICE([containing simple modules and other dynamically registered components:])
574
      AC_MSG_NOTICE([   $CXX ... $silly1 <libs> $silly2 ...])
575
      silly_ok="yes"
576
      WHOLE_ARCHIVE_ON=$silly1
577
      WHOLE_ARCHIVE_OFF=$silly2
578
   fi
579
   # no solution found
580
   if test $silly_ok = "no"; then
581
      AC_MSG_RESULT(no solution found)
582
      AC_MSG_WARN([Avoid linking with static libraries containing simple modules])
583
      AC_MSG_WARN([and other dynamically registered components. Those components])
584
      AC_MSG_WARN([will not be found by the simulation program, because the linker])
585
      AC_MSG_WARN([leaves them out from the executable.])
586
   fi
587
else
588
   AC_MSG_RESULT(test failed)
589
fi
590
rm -f conftest_a.* conftest_m.* libconftest_a.a conftest
591

    
592

    
593
#----------------------
594
# Check Cygwin
595
#----------------------
596
if test "$WITH_PARSIM" = "yes" -a "$cygwin" = "yes"; then
597
   AC_MSG_ERROR([WITH_PARSIM=yes not supported with Cygwin -- please edit configure.user!])
598
fi
599

    
600
#----------------------
601
# set arch specific flags
602
#----------------------
603
CFLAGS_DEBUG="$CFLAGS_DEBUG $CFLAGS_ARCH"
604
CFLAGS_RELEASE="$CFLAGS_RELEASE $CFLAGS_ARCH"
605
LDFLAGS="$LDFLAGS $LDFLAGS_ARCH"
606

    
607
#----------------------
608
# Check for rpath
609
#----------------------
610
# add RUNTIME_PATH option if supported, so that setting LD_LIBRARY_PATH is no longer needed when using shared libs.
611
# Also, we add "." to rpath so that opp_run -L option does not need full path of the library
612
AC_MSG_CHECKING(whether linker supports -rpath)
613
LDFLAGS_SAVE="$LDFLAGS"
614
LDFLAGS="$LDFLAGS -Wl,-rpath,\$(OMNETPP_LIB_DIR) -Wl,-rpath,."
615
AC_LINK_IFELSE(
616
     [AC_LANG_PROGRAM()],
617
     [AC_MSG_RESULT(yes)],
618
     [AC_MSG_RESULT(no); RPATH_UNSUPPORTED="true"; LDFLAGS="$LDFLAGS_SAVE"])
619

    
620
#----------------------
621
# Checks for programs.
622
#----------------------
623

    
624
AC_PROG_YACC
625
if test "$YACC" = "yacc"; then
626
   AC_MSG_ERROR([Bison not found, needed to build OMNeT++/OMNEST -- please install it!])
627
fi
628
BISON_VER_LINE=`$YACC --version | grep "bison.* [[234]]\\."`
629
if test -z "$BISON_VER_LINE"; then
630
   AC_MSG_ERROR([At least bison version 2.0 required -- type '$YACC --version' to see the version number])
631
fi
632

    
633
AC_PROG_LEX
634
if test "$LEX" != "flex"; then
635
   AC_MSG_ERROR([Flex not found, needed to build OMNeT++/OMNEST -- please install it!])
636
fi
637
FLEX_VER_LINE=`$LEX --version | grep "flex.* 2\\.[[5-9]]"`
638
if test -z "$FLEX_VER_LINE"; then
639
   AC_MSG_ERROR([At least flex version 2.5 required -- type '$LEX --version' to see the version number])
640
fi
641

    
642
# make must be GNU make
643
AC_CHECK_PROG(MAKE, make , make, not found)
644
if test "$MAKE" = "not found"; then
645
   OPP_PROBLEM_PACKAGES="$OPP_PROBLEM_PACKAGES make"
646
   AC_MSG_ERROR(make program not found -- it is required to build OMNeT++/OMNEST, and also for model development.)
647
else
648
   if "$MAKE" --version 2>/dev/null | grep -i GNU >/dev/null; then :; else
649
       AC_MSG_ERROR(GNU Make is required to build OMNeT++/OMNEST.)
650
   fi
651
fi
652

    
653
# perl is needed for opp_msgc
654
AC_ARG_VAR(PERL, The Perl interpreter)
655
AC_CHECK_PROG(PERL, perl, perl, not found)
656
if test "$PERL" = "not found"; then
657
   OPP_PROBLEM_PACKAGES="$OPP_PROBLEM_PACKAGES  perl"
658
   AC_MSG_WARN(Perl not found -- please install it! Perl is required by opp_msgc, opp_makemake and other features.)
659
fi
660
if test ! -x /usr/bin/perl; then
661
   this_perl=`which perl`
662
   AC_MSG_ERROR(Perl MUST be available as /usr/bin/perl. Creating a soft link should help: ln -s $this_perl /usr/bin/perl)
663
fi
664

    
665
# swig is used for building the ui support libs
666
AC_ARG_VAR(SWIG, The Swig interface generator)
667
AC_CHECK_PROG(SWIG, swig, swig, not found)
668

    
669

    
670
#----------------------
671
# Checks for standard libraries.
672
#----------------------
673

    
674
SYS_LIBS=""
675

    
676
# time functions
677
OPP_CHECK_LIB(time, time.h, clock_gettime(0,0), , , time_ok)
678
if test $time_ok = no; then
679
   OPP_CHECK_LIB(time, time.h, clock_gettime(0,0), ,-lrt, time_ok, SYS_LIBS="-lrt $SYS_LIBS")
680
fi
681
if test $time_ok = no; then
682
   AC_MSG_ERROR([Time library -lrt not found])
683
fi
684

    
685
# math functions
686
OPP_CHECK_LIB(math, math.h, floor(0), , , math_ok)
687
if test $math_ok = no; then
688
   OPP_CHECK_LIB(math, math.h, floor(0), , -lm, math_ok, SYS_LIBS="-lm $SYS_LIBS")
689
fi
690
if test $math_ok = no; then
691
   AC_MSG_ERROR([Standard C math library -lm not found])
692
fi
693

    
694
# -lstdc++
695
# currently we have a modified version of mingw which has a shared stdc++ by default so the below
696
# check is not needed
697
#if test "$mingw" = "yes"; then
698
#   # check for shared version (on mingw)
699
#   OPP_CHECK_LIB(standard C++ lib, iostream, /**/, , -lstdc++_s, stdcpp_ok, SYS_LIBS="-lstdc++_s $SYS_LIBS")
700
#else
701
   OPP_CHECK_LIB(standard C++ lib, iostream, /**/, , -lstdc++, stdcpp_ok, SYS_LIBS="-lstdc++ $SYS_LIBS")
702
   if test $stdcpp_ok = no; then
703
      OPP_CHECK_LIB(standard C++ lib, iostream, /**/, , -lcxx, stdcpp_ok, SYS_LIBS="-lcxx $SYS_LIBS")
704
   fi
705
   if test $stdcpp_ok = no; then
706
      OPP_CHECK_LIB(standard C++ lib, iostream, /**/, , -lcxa, stdcpp_ok, SYS_LIBS="-lcxa $SYS_LIBS")
707
   fi
708
#fi
709
if test $stdcpp_ok = no; then
710
   AC_MSG_ERROR([Standard C++ library -lstdc++_s or -lstdc++ or -lcxx or -lcxa not found])
711
fi
712

    
713
# dlopen()
714
OPP_CHECK_LIB(dlopen, dlfcn.h, dlopen("",0), , , dl_ok)
715
if test $dl_ok = no; then
716
   OPP_CHECK_LIB(dlopen, dlfcn.h, dlopen("",0), , -ldl, dl_ok, SYS_LIBS="-ldl $SYS_LIBS")
717
fi
718
if test $dl_ok = yes; then
719
   HAVE_DLOPEN=1
720
else
721
   HAVE_DLOPEN=0
722
   AC_MSG_WARN([no dlopen(): dynamic loading of libs not possible])
723
fi
724

    
725
# winsock (for MinGW)
726
OPP_CHECK_LIB(winsock, winsock.h, socket(0,0,0), , -lwsock32, wsock_ok, SYS_LIBS="-lwsock32 $SYS_LIBS")
727

    
728
# zlib
729
if test "$ZLIB_LIBS" = ""; then
730
    ZLIB_LIBS=-lz
731
fi
732
OPP_CHECK_LIB(zlib, zlib.h, gzopen("",""), $CFLAGS_RELEASE $ZLIB_CFLAGS, $ZLIB_LIBS, zlib_ok)
733
# on mingw/msys try a different library name
734
if test $zlib_ok = no -a "$mingw" = yes; then
735
    ZLIB_LIBS="-lzlib1"
736
    OPP_CHECK_LIB(zlib, zlib.h, gzopen("",""), $CFLAGS_RELEASE $ZLIB_CFLAGS, $ZLIB_LIBS, zlib_ok)
737
fi
738
if test $zlib_ok = no; then
739
   AC_MSG_ERROR([zlib or zlib header file not found, please install it])
740
fi
741

    
742

    
743
#----------------------
744
# Check for Tcl/Tk.
745
#----------------------
746
if test -n "$NO_TCL"; then
747

    
748
    # skip testing for TCL
749
    TKENV_IF_POSSIBLE=missing-dependency
750

    
751
    # and build samples using Cmdenv (TBD)
752
    ALL_ENV_LIBS='$(CMDENV_LIBS)'
753

    
754
else  #matching "fi" is after BLT testing
755

    
756
   if test -d /usr/include/tcl8.4; then
757
        # this was reported to be the case on Debian 3.1 "sarge"
758
        TK_CFLAGS84=${TK_CFLAGS:-"-I/usr/include/tcl8.4"}
759
   fi
760
   if test -d /usr/include/tcl8.5; then
761
        TK_CFLAGS85=${TK_CFLAGS:-"-I/usr/include/tcl8.5"}
762
   fi
763
   if test -d /usr/include/tcl8.6; then
764
        TK_CFLAGS86=${TK_CFLAGS:-"-I/usr/include/tcl8.6"}
765
   fi
766

    
767
   if test -n "$TK_LIBS"; then
768
        OPP_CHECK_LIB(Tcl/Tk, tk.h, Tk_MainLoop(), $TK_CFLAGS, $TK_LIBS, tcltk_ok)
769
    else
770
        # try to use tcl/tk without X (e.g. on Mac OS X native aqua Tcl/Tk impl)
771
        OPP_CHECK_LIB(Tcl/Tk 8.6, tk.h, Tk_MainLoop(), $CFLAGS_RELEASE $TK_CFLAGS86, -ltk8.6 -ltcl8.6,
772
                          tcltk_ok, TK_LIBS="-ltk8.6 -ltcl8.6" TK_CFLAGS=$TK_CFLAGS86)
773
        if test $tcltk_ok = no; then
774
           OPP_CHECK_LIB(Tcl/Tk 8.5, tk.h, Tk_MainLoop(), $CFLAGS_RELEASE $TK_CFLAGS85, -ltk8.5 -ltcl8.5,
775
                          tcltk_ok, TK_LIBS="-ltk8.5 -ltcl8.5" TK_CFLAGS=$TK_CFLAGS85)
776
        fi
777
        if test $tcltk_ok = no; then
778
            OPP_CHECK_LIB(Tcl/Tk 8.4, tk.h, Tk_MainLoop(), $CFLAGS_RELEASE $TK_CFLAGS84, -ltk8.4 -ltcl8.4,
779
                          tcltk_ok, TK_LIBS="-ltk8.4 -ltcl8.4" TK_CFLAGS=$TK_CFLAGS84)
780
        fi
781
        # look for X window libs and headers
782
        if test $tcltk_ok = no; then
783
            # try to find Tcl/Tk ourselves, but it usually needs to link with Xlib
784
            AC_PATH_X
785
            if test "$no_x" = "yes"; then
786
                opp_x11inc=
787
                opp_x11lib=
788
            else
789
               if test -n "$x_includes"; then
790
                   opp_x11inc="-I$x_includes"
791
               fi
792
               if test -n "$x_libraries"; then
793
                   opp_x11lib="-L$x_libraries -lX11"
794
               fi
795
            fi
796
        fi
797
        if test $tcltk_ok = no; then
798
            OPP_CHECK_LIB(Tcl/Tk 8.6, tk.h, Tk_MainLoop(), $CFLAGS_RELEASE $opp_x11inc $TK_CFLAGS86, $opp_x11lib -ltk86 -ltcl86,
799
                          tcltk_ok, TK_LIBS="$opp_x11lib -ltk86 -ltcl86" TK_CFLAGS=$TK_CFLAGS86)
800
        fi
801
        if test $tcltk_ok = no; then
802
            OPP_CHECK_LIB(Tcl/Tk 8.6, tk.h, Tk_MainLoop(), $CFLAGS_RELEASE $opp_x11inc $TK_CFLAGS86, $opp_x11lib -ltk8.6 -ltcl8.6,
803
                          tcltk_ok, TK_LIBS="$opp_x11lib -ltk8.6 -ltcl8.6" TK_CFLAGS=$TK_CFLAGS86)
804
        fi
805
        if test $tcltk_ok = no -a "$cygwin" = yes; then
806
            OPP_CHECK_LIB(Tcl/Tk 8.6, tk.h, Tk_MainLoop(), $CFLAGS_RELEASE $opp_x11inc $TK_CFLAGS86, $opp_x11lib -lcygtk86 -lcygtcl86,
807
                          tcltk_ok, TK_LIBS="$opp_x11lib -lcygtk86 -lcygtcl86" TK_CFLAGS=$TK_CFLAGS86)
808
        fi
809
        # check for 8.5
810
        if test $tcltk_ok = no; then
811
            OPP_CHECK_LIB(Tcl/Tk 8.5, tk.h, Tk_MainLoop(), $CFLAGS_RELEASE $opp_x11inc $TK_CFLAGS85, $opp_x11lib -ltk85 -ltcl85,
812
                          tcltk_ok, TK_LIBS="$opp_x11lib -ltk85 -ltcl85" TK_CFLAGS=$TK_CFLAGS85)
813
        fi
814
        if test $tcltk_ok = no; then
815
            OPP_CHECK_LIB(Tcl/Tk 8.5, tk.h, Tk_MainLoop(), $CFLAGS_RELEASE $opp_x11inc $TK_CFLAGS85, $opp_x11lib -ltk8.5 -ltcl8.5,
816
                          tcltk_ok, TK_LIBS="$opp_x11lib -ltk8.5 -ltcl8.5" TK_CFLAGS=$TK_CFLAGS85)
817
        fi
818
        if test $tcltk_ok = no -a "$cygwin" = yes; then
819
            OPP_CHECK_LIB(Tcl/Tk 8.5, tk.h, Tk_MainLoop(), $CFLAGS_RELEASE $opp_x11inc $TK_CFLAGS85, $opp_x11lib -lcygtk85 -lcygtcl85,
820
                          tcltk_ok, TK_LIBS="$opp_x11lib -lcygtk85 -lcygtcl85" TK_CFLAGS=$TK_CFLAGS85)
821
        fi
822
        # check for 8.4
823
        if test $tcltk_ok = no; then
824
            OPP_CHECK_LIB(Tcl/Tk 8.4, tk.h, Tk_MainLoop(), $CFLAGS_RELEASE $opp_x11inc $TK_CFLAGS84, $opp_x11lib -ltk84 -ltcl84,
825
                          tcltk_ok, TK_LIBS="$opp_x11lib -ltk84 -ltcl84" TK_CFLAGS=$TK_CFLAGS84)
826
        fi
827
        if test $tcltk_ok = no; then
828
            OPP_CHECK_LIB(Tcl/Tk 8.4, tk.h, Tk_MainLoop(), $CFLAGS_RELEASE $opp_x11inc $TK_CFLAGS84, $opp_x11lib -ltk8.4 -ltcl8.4,
829
                          tcltk_ok, TK_LIBS="$opp_x11lib -ltk8.4 -ltcl8.4" TK_CFLAGS=$TK_CFLAGS84)
830
        fi
831
        if test $tcltk_ok = no -a "$cygwin" = yes; then
832
            OPP_CHECK_LIB(Tcl/Tk 8.4, tk.h, Tk_MainLoop(), $CFLAGS_RELEASE $opp_x11inc $TK_CFLAGS84, $opp_x11lib -lcygtk84 -lcygtcl84,
833
                          tcltk_ok, TK_LIBS="$opp_x11lib -lcygtk84 -lcygtcl84" TK_CFLAGS=$TK_CFLAGS84)
834
        fi
835
    fi
836

    
837
    if test $tcltk_ok = no; then
838
        # try to give a hint in the error message about the problem
839
        if test "$no_x" = "yes"; then
840
            if test "$cygwin" = yes; then
841
                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 www.omnetpp.org.])
842
            else
843
                AC_MSG_ERROR([Cannot build Tcl/Tk apps, probably due to misconfigured or missing X11 headers or libs. Check config.log for more info!])
844
            fi
845
        else
846
            AC_MSG_ERROR([Tcl/Tk not found, needed for all GUI parts. Version 8.4.0+ and devel package required. Check config.log for more info!])
847
        fi
848
    fi
849

    
850
    # Check for tclsh.
851
    AC_CHECK_PROGS(TCLSH, $TCLSH tclsh tclsh86 tclsh8.6 tclsh85 tclsh8.5 tclsh84 tclsh8.4 cygtclsh cygtclsh86 cygtclsh85 cygtclsh84, nope)
852
    if test "$TCLSH" = nope; then
853
       AC_MSG_ERROR([Cannot find tclsh, part of Tcl/Tk -- maybe it is not in the PATH or has some exotic name (tested names were: tclsh tclsh86 tclsh8.6 tclsh85 tclsh8.5 tclsh84 tclsh8.4 cygtclsh cygtclsh86 cygtclsh85 cygtclsh84)])
854
    fi
855
    if echo 'puts OK; exit' | $TCLSH | grep OK >/dev/null; then :; else
856
        AC_MSG_ERROR([Cannot run tclsh (tclsh command "puts OK; exit" failed): maybe your TCL installation is broken?])
857
    fi
858

    
859
    # disabled because this check actually only works with a running X server. However, the OPP_CHECK_LIB checks above should cover this check most of the time.
860
    #if echo 'catch {package require Tk 8.4; puts OK}; exit' | $TCLSH | grep OK >/dev/null; then :; else
861
    #    AC_MSG_ERROR([tclsh command "package require Tk 8.4" failed: probably old Tcl/Tk version, version 8.4.0+ required])
862
    #fi
863

    
864
    # note: square brackets necessary otherwise M4 messes up the Tcl command
865
    [tcl_library=`echo 'puts [info library]; exit' | $TCLSH`]
866

    
867

    
868
    #----------------------
869
    # Check for BLT. NOTE: since plove and scalars are out, blt-devel is no longer needed
870
    #----------------------
871
    if echo 'catch {package require BLT 2.4; puts OK}; exit' | $TCLSH | grep OK >/dev/null; then
872
        HAVE_BLT=yes
873
    else
874
        HAVE_BLT=no
875
        # Native Tcl/Tk (aqua) on Mac OS does not support BLT so we do not annoy the users
876
        if test "$PLATFORM" != "macosx"; then
877
            OPP_PROBLEM_PACKAGES="$OPP_PROBLEM_PACKAGES  BLT (optional)"
878
            AC_MSG_WARN([Tcl cannot load BLT (wish command "package require BLT 2.4" failed), BLT not installed?])
879
        fi
880
    fi
881

    
882
    # if we got through until here, enable building of the following progs:
883
    TKENV_IF_POSSIBLE=tkenv
884

    
885
    # and build samples using Tkenv
886
    ALL_ENV_LIBS='$(TKENV_LIBS) $(CMDENV_LIBS)'
887

    
888
fi # end of Tcl tests ($NO_TCL=="" branch)
889

    
890
#----------------------
891
# Check for pthread
892
#----------------------
893
OPP_CHECK_LIB(PTHREAD, pthread.h, pthread_join, $PTHREAD_CFLAGS, $PTHREAD_LIBS, pthread_ok)
894
if test $pthread_ok = no; then
895
	AC_MSG_ERROR([pthread lib not found.])
896
fi
897

    
898
CFLAGS_DEBUG="$CFLAGS_DEBUG $PTHREAD_CFLAGS"
899
CFLAGS_RELEASE="$CFLAGS_RELEASE $PTHREAD_CFLAGS"
900
SYS_LIBS="$SYS_LIBS $PTHREAD_LIBS"
901

    
902

    
903
#----------------------
904
# Check for libatomic-ops-dev
905
#----------------------
906
OPP_CHECK_LIB(ATOMIC-OPS, atomic_ops.h, AO_load, $ATOMIC_OPS_CFLAGS, $ATOMIC_OPS_LIBS, atomic_ops_ok)
907
if test $atomic_ops_ok = no; then
908
    AC_MSG_ERROR([libatomic-ops not found. You can disable use of this library in configure.user, but be warned that this might cause data corruption at runtime.])
909
fi
910

    
911
CFLAGS_DEBUG="$CFLAGS_DEBUG $ATOMIC_OPS_CFLAGS"
912
CFLAGS_RELEASE="$CFLAGS_RELEASE $ATOMIC_OPS_CFLAGS"
913
SYS_LIBS="$SYS_LIBS $ATOMIC_OPS_LIBS"
914

    
915
#----------------------
916
# Check for JRE
917
#----------------------
918
AC_CHECK_PROGS(JRE, $JRE java, nope)
919
if test "$JRE" = nope; then
920
   OPP_PROBLEM_PACKAGES="$OPP_PROBLEM_PACKAGES  JRE (recommended)"
921
   AC_MSG_WARN([Cannot find a suitable Java Runtime Environment - The IDE requires JRE 1.5 or later. Please install it before configuring])
922
fi
923

    
924
#----------------------
925
# Check for JDK
926
#----------------------
927

    
928
if test "$JAVA_CFLAGS" = ""; then
929
   if test "$JDK" = ""; then
930
     javahome_candidates="/usr/lib/jvm/java /usr/lib/jvm/java-6-sun /usr/lib/jvm/java-6-openjdk /usr/lib/jvm/java-1.6.0-sun /usr/lib/jvm/java-5-sun /usr/lib/jvm/java-1.5.0-sun /usr/java/jdk /Library/Java/Home"
931
     for dir in $javahome_candidates; do
932
         if test "$JAVA_HOME" = "" -a -d "$dir"; then
933
             JAVA_HOME=$dir
934
         fi
935
     done
936
   else
937
     JAVA_HOME=$JDK
938
   fi
939
   if test "$JAVA_HOME" = ""; then
940
      AC_MSG_WARN(JAVA_HOME variable not set.)
941
   else
942
      JAVA_CFLAGS="-fno-strict-aliasing -I$JAVA_HOME/include -I$JAVA_HOME/include/$jni_platform"
943
      JAVA_LIBS="-L$JAVA_HOME/jre/lib/i386/client -Wl,-rpath,$JAVA_HOME/jre/lib/i386/client:. -ljvm"
944
   fi
945
fi
946

    
947
OPP_CHECK_LIB_NOLINK(JNI, jni.h, JNI_GetCreatedJavaVMs(0,0,0), $CFLAGS_RELEASE $JAVA_CFLAGS, jni_ok)
948

    
949
if test "$jni_ok" = "no" -o "$SWIG" = "not found"; then
950
   JNILIBS_IF_POSSIBLE=missing-dependency
951
else
952
   JNILIBS_IF_POSSIBLE=jnilibs
953
fi
954

    
955
#----------------------
956
# Check for MPI.
957
#----------------------
958

    
959
if test -n "$MPI_LIBS"; then
960
    OPP_CHECK_LIB(MPI, mpi.h, MPI_Init(0,0), $CFLAGS_RELEASE $MPI_CFLAGS, $LDFLAGS $MPI_LIBS, mpi_ok)
961
else
962
    mpi_ok=no
963
    # LAM and OpenMPI support mpic++ -showme
964
    # NOTE: on some systems (e.g. RHEL and Fedora), "module load openmpi_i386" or similar command may be additionally needed to make MPI accessible
965
    AC_CHECK_PROG(MPICPP, mpic++, mpic++, not found)
966
    if test "$MPICPP" != "not found"; then
967
        MPI_CFLAGS=`mpic++ -showme:compile`
968
        MPI_LIBS=`mpic++ -showme:link`
969
        OPP_CHECK_LIB(MPI, mpi.h, MPI_Init(0,0), $CFLAGS_RELEASE $MPI_CFLAGS, $LDFLAGS $MPI_LIBS, mpi_ok)
970
    fi
971

    
972
    if test $mpi_ok = no; then
973
          # MPICH2 has mpicxx -compile-info and -link-info, slightly broken
974
          # (both print the same string, which includes the compiler name too)
975
          AC_CHECK_PROG(MPICXX, mpicxx, mpicxx, not found)
976
          if test "$MPICXX" != "not found"; then
977
              MPI_CFLAGS=`mpicxx -c -compile-info | sed 's/^[^ ]*//'`
978
              MPI_LIBS=`mpicxx -link-info | sed 's/^[^ ]*//'`
979
              OPP_CHECK_LIB(MPI, mpi.h, MPI_Init(0,0), $CFLAGS_RELEASE $MPI_CFLAGS, $LDFLAGS $MPI_LIBS, mpi_ok)
980
          fi
981
    fi
982

    
983
    if test $mpi_ok = no; then
984
       mpilibs="-lmpi"   #SGI and mingw (on MinGW modify mpi.h and insert #include <wchar.h> at the top of the file)
985
       OPP_CHECK_LIB(MPI, mpi.h, MPI_Init(0,0), $CFLAGS_RELEASE $MPI_CFLAGS, $LDFLAGS $mpilibs, mpi_ok, MPI_LIBS="$mpilibs")
986
    fi
987
fi
988

    
989
if test $mpi_ok = yes; then
990
   HAVE_MPI=yes
991
   MPI_CFLAGS="$MPI_CFLAGS -DWITH_MPI"
992
else
993
   HAVE_MPI=no
994
   OPP_PROBLEM_PACKAGES="$OPP_PROBLEM_PACKAGES  MPI (optional)"
995
   AC_MSG_WARN([Optional package MPI (needed for parallel simulation) not found.])
996
fi
997

    
998

    
999
#----------------------
1000
# Check for PCAP.
1001
#----------------------
1002

    
1003
# Note: on Windows, we need to check beforehand if wpcap.dll exists, because
1004
# otherwise the test program (that links with pcap.lib) brings up a GUI (!)
1005
# error dialog complaining that wpcap.dll was missing
1006
case $host in
1007
*-*-cygwin* | *-*-mingw32*)
1008
    OPP_CHECK_AND_RUN_LIB(WinPCAP, windows.h, return LoadLibrary("wpcap.dll")==NULL ? 1 : 0, $CFLAGS_RELEASE, , wpcap_dll)
1009
    ;;
1010
*)
1011
    wpcap_dll=notneeded
1012
    ;;
1013
esac
1014

    
1015
if test $wpcap_dll = "no"; then
1016
    pcap_ok=no
1017
    AC_MSG_NOTICE([WinPCAP not found -- if you need packet capture functionality in your models, install it from winpcap.org])
1018
else
1019
    if test -n "$PCAP_LIBS"; then
1020
        OPP_CHECK_AND_RUN_LIB(PCAP, pcap.h, pcap_lib_version(), $CFLAGS_RELEASE $PCAP_CFLAGS, $PCAP_LIBS, pcap_ok)
1021
    else
1022
        PCAP_LIBS="-lpcap"
1023
        OPP_CHECK_AND_RUN_LIB(PCAP, pcap.h, pcap_lib_version(), $CFLAGS_RELEASE $PCAP_CFLAGS, $PCAP_LIBS, pcap_ok)
1024
    fi
1025
fi
1026
if test $pcap_ok = yes; then
1027
    HAVE_PCAP=yes
1028
    CFLAGS_RELEASE="$CFLAGS_RELEASE $PCAP_CFLAGS -DHAVE_PCAP"
1029
    CFLAGS_DEBUG="$CFLAGS_DEBUG $PCAP_CFLAGS -DHAVE_PCAP"
1030
else
1031
    HAVE_PCAP=no
1032
    PCAP_CFLAGS=""
1033
    PCAP_LIBS=""
1034
    OPP_PROBLEM_PACKAGES="$OPP_PROBLEM_PACKAGES  PCAP (optional)"
1035
fi
1036

    
1037
#----------------------
1038
# Check for PTHREAD.
1039
# On MinGW, add "-mthread" to PTHREAD_CFLAGS and PTHREAD_LIBS to force using
1040
# the multithreaded standard libraries.
1041
#----------------------
1042

    
1043
if test -n "$PTHREAD_LIBS"; then
1044
    OPP_CHECK_LIB(PTHREAD, pthread.h, pthread_rwlock_rdlock(0), $CFLAGS_RELEASE $PTHREAD_CFLAGS, $PTHREAD_LIBS, pthread_ok)
1045
else
1046
    PTHREAD_LIBS="-lpthread"
1047
    OPP_CHECK_LIB(PTHREAD, pthread.h, pthread_rwlock_rdlock(0), $CFLAGS_RELEASE $PTHREAD_CFLAGS, $PTHREAD_LIBS, pthread_ok)
1048
fi
1049
if test $pthread_ok = yes; then
1050
    HAVE_PTHREAD=yes
1051
    if test "$mingw" = yes; then
1052
        PTHREAD_CFLAGS="$PTHREAD_CFLAGS -mthreads"
1053
        PTHREAD_LIBS="$PTHREAD_LIBS -mthreads"
1054
    fi
1055
else
1056
    HAVE_PTHREAD=no
1057
    PTHREAD_CFLAGS=""
1058
    PTHREAD_LIBS=""
1059
fi
1060

    
1061
#----------------------
1062
# Check for XML parsers: EXPAT and/or LIBXML
1063
#----------------------
1064
if test -n "$LIBXML_LIBS"; then
1065
    OPP_CHECK_LIB(LibXML XML parser, libxml/parser.h, xmlInitParser(), $CFLAGS_RELEASE $LIBXML_CFLAGS, $LIBXML_LIBS, libxml_ok)
1066
else
1067
    OPP_CHECK_LIB(LibXML XML parser, libxml/parser.h, xmlInitParser(), $CFLAGS_RELEASE $LIBXML_CFLAGS, -lxml2,
1068
                  libxml_ok, LIBXML_LIBS="-lxml2")
1069

    
1070
    if test $libxml_ok = no; then
1071
        OPP_CHECK_LIB(LibXML XML parser, libxml/parser.h, xmlInitParser(), $CFLAGS_RELEASE -I/usr/include/libxml2, -lxml2,
1072
                      libxml_ok, LIBXML_CFLAGS="-I/usr/include/libxml2" LIBXML_LIBS="-lxml2")
1073
    fi
1074
fi
1075
if test -n "$EXPAT_LIBS"; then
1076
    OPP_CHECK_LIB(Expat XML parser, expat.h, XML_ParserCreate(0), $CFLAGS_RELEASE $EXPAT_CFLAGS, $EXPAT_LIBS, expat_ok)
1077
else
1078
    expatlibs="-lexpat"
1079
    OPP_CHECK_LIB(Expat XML parser, expat.h, XML_ParserCreate(0), $CFLAGS_RELEASE $EXPAT_CFLAGS, $expatlibs, expat_ok, EXPAT_LIBS=$expatlibs)
1080
fi
1081

    
1082
if test $libxml_ok = yes; then
1083
   AC_MSG_NOTICE([Using LibXML for XML parsing])
1084
   XMLPARSER=libxml
1085
   XML_CFLAGS=$LIBXML_CFLAGS
1086
   XML_LIBS=$LIBXML_LIBS
1087
elif test $expat_ok = yes; then
1088
   AC_MSG_NOTICE([Using Expat for XML parsing])
1089
   AC_MSG_WARN([DTD validation is not supported with Expat, only with LibXML!])
1090
   XMLPARSER=expat
1091
   XML_CFLAGS=$EXPAT_CFLAGS
1092
   XML_LIBS=$EXPAT_LIBS
1093
else
1094
   XMLPARSER=none
1095
   OPP_PROBLEM_PACKAGES="$OPP_PROBLEM_PACKAGES  LibXML/Expat"
1096
   AC_MSG_WARN([No suitable XML parser found: no support for XML input])
1097
fi
1098

    
1099
CFLAGS_DEBUG="$CFLAGS_DEBUG -DXMLPARSER=$XMLPARSER"
1100
CFLAGS_RELEASE="$CFLAGS_RELEASE -DXMLPARSER=$XMLPARSER"
1101

    
1102
#----------------------
1103
# Check for Akaroa header and lib
1104
#----------------------
1105
if test -z "$AKAROA_CFLAGS"; then
1106
    AKAROA_CFLAGS="-I/usr/local/akaroa/include"
1107
fi
1108
if test -z "$AKAROA_LIBS"; then
1109
    AKAROA_LIBS="-L/usr/local/akaroa/lib -lakaroa -lfl"
1110
fi
1111

    
1112
OPP_CHECK_LIB(Akaroa, akaroa.H, AkObservation(0.0), $CFLAGS_RELEASE $AKAROA_CFLAGS, $AKAROA_LIBS, akaroa_ok)
1113
if test $akaroa_ok = yes; then
1114
   CFLAGS_DEBUG="$CFLAGS_DEBUG $AKAROA_CFLAGS -DWITH_AKAROA"
1115
   CFLAGS_RELEASE="$CFLAGS_RELEASE $AKAROA_CFLAGS -DWITH_AKAROA"
1116
   SYS_LIBS="$SYS_LIBS $AKAROA_LIBS"
1117
else
1118
   OPP_PROBLEM_PACKAGES="$OPP_PROBLEM_PACKAGES  Akaroa (optional)"
1119
   AC_MSG_WARN([Optional package Akaroa not found])
1120
fi
1121

    
1122

    
1123
#----------------------
1124
# #defines in CFLAGS
1125
#----------------------
1126
if test "$WITH_PARSIM" = yes; then
1127
   CFLAGS_DEBUG="$CFLAGS_DEBUG -DWITH_PARSIM"
1128
   CFLAGS_RELEASE="$CFLAGS_RELEASE -DWITH_PARSIM"
1129
fi
1130
if test "$WITH_NETBUILDER" = yes; then
1131
   CFLAGS_DEBUG="$CFLAGS_DEBUG -DWITH_NETBUILDER"
1132
   CFLAGS_RELEASE="$CFLAGS_RELEASE -DWITH_NETBUILDER"
1133
fi
1134

    
1135
if test "$WITH_MUTEXES" = yes; then
1136
   CFLAGS="$CFLAGS -DMUTEXES"
1137
   CFLAGS_DEBUG="$CFLAGS_DEBUG -DMUTEXES"
1138
   CFLAGS_RELEASE="$CFLAGS_RELEASE -DMUTEXES"
1139
fi
1140
if test "$NOBARRIER" = yes; then
1141
   CFLAGS_DEBUG="$CFLAGS_DEBUG -DNOBARRIER"
1142
   CFLAGS_RELEASE="$CFLAGS_RELEASE -DNOBARRIER"
1143
fi
1144
if test "$ENABLE_OWNERSHIP" = yes; then
1145
   CFLAGS_DEBUG="$CFLAGS_DEBUG -DENABLE_OWNERSHIP"
1146
   CFLAGS_RELEASE="$CFLAGS_RELEASE -DENABLE_OWNERSHIP"
1147
fi
1148
if test "$WITH_CACHE_LINE_SIZE" != 0; then
1149
   CFLAGS_DEBUG="$CFLAGS_DEBUG -DCACHE_LINE_SIZE=$WITH_CACHE_LINE_SIZE"
1150
   CFLAGS_RELEASE="$CFLAGS_RELEASE -DCACHE_LINE_SIZE=$WITH_CACHE_LINE_SIZE"
1151
fi
1152
if test "$ATOMIC_OPS_DEBUG" = yes; then
1153
   CFLAGS_DEBUG="$CFLAGS_DEBUG -DATOMIC_OPS_DEBUG"
1154
   CFLAGS_RELEASE="$CFLAGS_RELEASE -DATOMIC_OPS_DEBUG"
1155
fi
1156
if test "$ATOMIC_OPS_DEBUG_PLAIN" = yes; then
1157
   CFLAGS_DEBUG="$CFLAGS_DEBUG -DATOMIC_OPS_DEBUG_PLAIN"
1158
   CFLAGS_RELEASE="$CFLAGS_RELEASE -DATOMIC_OPS_DEBUG_PLAIN"
1159
fi
1160

    
1161

    
1162
#----------------------
1163
# Files to be generated
1164
#----------------------
1165
AC_CONFIG_FILES(
1166
  Makefile.inc
1167
)
1168

    
1169
#----------------------
1170
# Substitutions.
1171
#----------------------
1172

    
1173
AC_SUBST(OMNETPP_PRODUCT)
1174
AC_SUBST(OMNETPP_RELEASE)
1175
AC_SUBST(OMNETPP_VERSION)
1176
AC_SUBST(OMNETPP_BUILDID)
1177
AC_SUBST(OMNETPP_EDITION)
1178

    
1179
AC_SUBST(OMNETPP_ROOT)
1180
AC_SUBST(OMNETPP_BIN_DIR)
1181
AC_SUBST(OMNETPP_INCL_DIR)
1182
AC_SUBST(OMNETPP_OUT_DIR)
1183
AC_SUBST(OMNETPP_LIB_DIR)
1184
AC_SUBST(OMNETPP_IMAGE_PATH)
1185

    
1186
AC_SUBST(OMNETPP_SRC_DIR)
1187
AC_SUBST(OMNETPP_UI_DIR)
1188
AC_SUBST(OMNETPP_UTILS_DIR)
1189
AC_SUBST(OMNETPP_DOC_DIR)
1190
AC_SUBST(OMNETPP_TEST_DIR)
1191

    
1192
AC_SUBST(PERL)
1193
AC_SUBST(YACC)
1194
AC_SUBST(LEX)
1195
AC_SUBST(CC)
1196
AC_SUBST(CXX)
1197
AC_SUBST(CPPFLAGS)
1198
AC_SUBST(CFLAGS_DEBUG)
1199
AC_SUBST(CFLAGS_RELEASE)
1200
AC_SUBST(LDFLAGS)
1201
AC_SUBST(WHOLE_ARCHIVE_ON)
1202
AC_SUBST(WHOLE_ARCHIVE_OFF)
1203
AC_SUBST(TOOLCHAIN_NAME)
1204
AC_SUBST(MYPWD)
1205
AC_SUBST(MSGC)
1206
AC_SUBST(NEDTOOL)
1207
AC_SUBST(AS)
1208
AC_SUBST(AR)
1209
AC_SUBST(RANLIB)
1210
AC_SUBST(SHLIB_LD)
1211
AC_SUBST(DLLTOOL)
1212
AC_SUBST(STRIP)
1213
AC_SUBST(TCLSH)
1214
AC_SUBST(MAKEDEPEND)
1215
AC_SUBST(LN)
1216
AC_SUBST(MKPATH)
1217
AC_SUBST(SHLIB_POSTPROCESS)
1218

    
1219
AC_SUBST(SHARED_LIBS)
1220
AC_SUBST(A_LIB_SUFFIX)
1221
AC_SUBST(SHARED_LIB_SUFFIX)
1222
AC_SUBST(JNI_LIB_SUFFIX)
1223
AC_SUBST(SO_LIB_SUFFIX)
1224
AC_SUBST(DLL_LIB_SUFFIX)
1225
AC_SUBST(EXE_SUFFIX)
1226
AC_SUBST(LIB_PREFIX)
1227

    
1228
AC_SUBST(NO_TCL)
1229
AC_SUBST(HAVE_DLOPEN)
1230
AC_SUBST(TK_CFLAGS)
1231
AC_SUBST(TK_LIBS)
1232
AC_SUBST(HAVE_BLT)
1233
AC_SUBST(BLT_LIBS)
1234
AC_SUBST(ZLIB_CFLAGS)
1235
AC_SUBST(ZLIB_LIBS)
1236
AC_SUBST(HAVE_MPI)
1237
AC_SUBST(MPI_CFLAGS)
1238
AC_SUBST(MPI_LIBS)
1239
AC_SUBST(HAVE_PCAP)
1240
AC_SUBST(PCAP_CFLAGS)
1241
AC_SUBST(PCAP_LIBS)
1242
AC_SUBST(SYS_LIBS)
1243
AC_SUBST(HAVE_PTHREAD)
1244
AC_SUBST(PTHREAD_CFLAGS)
1245
AC_SUBST(PTHREAD_LIBS)
1246

    
1247
AC_SUBST(XMLPARSER)
1248
AC_SUBST(XML_CFLAGS)
1249
AC_SUBST(XML_LIBS)
1250

    
1251
AC_SUBST(AKAROA_CFLAGS)
1252
AC_SUBST(AKAROA_LIBS)
1253

    
1254
AC_SUBST(TKENV_IF_POSSIBLE)
1255
AC_SUBST(JNILIBS_IF_POSSIBLE)
1256

    
1257
AC_SUBST(ALL_ENV_LIBS)
1258

    
1259
AC_SUBST(EMBED_TCL_CODE)
1260
AC_SUBST(OMNETPP_TKENV_DIR)
1261

    
1262
AC_SUBST(WITH_NETBUILDER)
1263
AC_SUBST(WITH_PARSIM)
1264

    
1265
AC_SUBST(JAVA_CFLAGS)
1266
AC_SUBST(JAVA_LIBS)
1267
AC_SUBST(SWIG)
1268
AC_SUBST(PLATFORM)
1269

    
1270
#
1271
# Generate files
1272
#
1273
AC_OUTPUT
1274

    
1275
chmod +x src/utils/opp_makemake
1276
chmod +x src/utils/opp_test
1277
chmod +x src/utils/opp_makedep
1278
chmod +x src/utils/omnest
1279
chmod +x src/utils/omnetpp
1280
chmod +x src/utils/opp_test
1281

    
1282
(
1283
cd src/common && cp ver.h.base ver.h && \
1284
echo "#define OMNETPP_PRODUCT \"$OMNETPP_PRODUCT\"" >>ver.h && \
1285
echo "#define OMNETPP_RELEASE \"$OMNETPP_RELEASE\"" >>ver.h && \
1286
echo "#define OMNETPP_VERSION_STR \"$OMNETPP_VERSION\"" >>ver.h && \
1287
echo "#define OMNETPP_BUILDID \"$OMNETPP_BUILDID\"" >>ver.h && \
1288
echo "#define OMNETPP_EDITION \"$OMNETPP_EDITION\"" >>ver.h
1289
)
1290

    
1291
# Test it the IDE was already configured. If not, copy the platform specific
1292
# files to the IDE root directory
1293
if test -d ide ; then
1294
  if test ! -d ide/configuration ; then
1295
    echo Configuring the IDE...
1296
    cp -r ide/linux/* ide
1297
    case $PLATFORM in
1298
    win32.x86)
1299
        cp -r ide/win32/* ide
1300
        echo osgi.instance.area.default=../samples >>ide/configuration/config.ini
1301
        ;;
1302
    linux.x86_64)
1303
        cp -r ide/linux64/* ide
1304
        echo osgi.instance.area.default=../samples >>ide/configuration/config.ini
1305
        ;;
1306
    linux.x86)
1307
        cp -r ide/linux/* ide
1308
        echo osgi.instance.area.default=../samples >>ide/configuration/config.ini
1309
        ;;
1310
    macosx)
1311
        cp -r ide/macosx/* ide
1312
        echo osgi.instance.area.default=../../../../samples >>ide/configuration/config.ini
1313
        ;;
1314
    *)
1315
        echo IDE is supported only on: Linux 32/64bit, Windows 32bit, MacOS X Intel. Not configured.
1316
        ;;
1317
    esac
1318
  fi
1319
fi
1320

    
1321
#----------------------
1322
# Check $OPP_PROBLEM_PACKAGES
1323
#----------------------
1324

    
1325
if test "$OPP_PROBLEM_PACKAGES" != ""; then
1326
  cat 1>&2 << EOT
1327

    
1328
WARNING: The configuration script could not detect the following packages:
1329

    
1330
  $OPP_PROBLEM_PACKAGES
1331

    
1332
Scroll up to see the warning messages (use shift+PgUp), and search config.log
1333
for more details. While you can use $OMNETPP_PRODUCT in the current configuration, 
1334
be aware that some functionality may be unavailable or incomplete.
1335

    
1336
EOT
1337
  if module avail >/dev/null 2>/dev/null; then
1338
    cat 1>&2 << EOT
1339
NOTE: Some packages like MPI may need to be loaded explicitly using a 
1340
"module load <MODULENAME>" command  prior to running ./configure. 
1341
Enter "module avail" to see the list of available modules on your system.
1342

    
1343
EOT
1344
  fi
1345
fi
1346

    
1347

    
1348
#----------------------
1349
# Check if the path contains omnetpp/bin (it should)
1350
# Note: the method used here also works with Cygwin, but requires
1351
# write permission to $OMNETPP_BIN_DIR.
1352
#----------------------
1353

    
1354
# first we need to expand the ${HOME} variable and make sure the dir exists..
1355
omnetpp_bin_dir=`eval echo $OMNETPP_BIN_DIR`
1356
if test ! -d $omnetpp_bin_dir; then
1357
   echo "PROBLEM: the $OMNETPP_BIN_DIR directory does not exist!"
1358
else
1359
  # ...then we create a small tmp file to check if the dir is in the path
1360
  probefile=__probe__
1361
  echo '' >$omnetpp_bin_dir/$probefile
1362
  chmod +x  $omnetpp_bin_dir/$probefile
1363
  if ($probefile) >/dev/null 2>/dev/null; then
1364
    echo "Your PATH contains $OMNETPP_BIN_DIR. Good!"
1365
  else
1366
    if test "$cygwin" = yes; then
1367
      opp_bin_dir=`cygpath -u $OMNETPP_BIN_DIR`
1368
      if test -z "$opp_bin_dir"; then opp_bin_dir=$OMNETPP_BIN_DIR; fi
1369
      cat 1>&2 << EOT
1370

    
1371
WARNING: your PATH doesn't contain $opp_bin_dir!
1372
Add the following line to your startup file, $HOME/.bash_profile:
1373
  export PATH=\$PATH:$opp_bin_dir
1374

    
1375
EOT
1376
    else
1377
      cat 1>&2 << EOT
1378

    
1379
WARNING: your PATH doesn't contain $OMNETPP_BIN_DIR!
1380
Add the following line to your .profile or .bash_profile (provided you use bash):
1381
  export PATH=\$PATH:$OMNETPP_BIN_DIR
1382

    
1383
EOT
1384
    fi
1385
  fi
1386
  rm $omnetpp_bin_dir/$probefile
1387
fi
1388

    
1389
#----------------------
1390
# Check if the rpath option is unsupported. in this warn the user to provide the LD_LIBRARY_PATH variable
1391
#----------------------
1392
if test -n "$RPATH_UNSUPPORTED"; then
1393

    
1394
    cat 1>&2 << EOT
1395

    
1396
WARNING: Your linker does not support the -rpath option.
1397
  You must set the LD_LIBRARY_PATH environment variable to point
1398
  to the directory where your shared libraries can be found.
1399

    
1400
Add the following line to your .profile or .bash_profile (provided you use bash):
1401
  export LD_LIBRARY_PATH=$OMNETPP_ROOT/lib:\$LD_LIBRARY_PATH
1402
EOT
1403

    
1404
fi
1405

    
1406
#----------------------
1407
# Check if TCL_LIBRARY is set.
1408
#----------------------
1409

    
1410
if test -n "$NO_TCL"; then
1411

    
1412
    cat << EOT
1413

    
1414
$OMNETPP_PRODUCT was configured without Tcl/Tk (\$NO_TCL set). Tkenv (the GUI
1415
runtime environment) will not be available, simulations need to be run
1416
under Cmdenv.
1417
EOT
1418

    
1419
elif test "$PLATFORM" = "macosx"; then
1420
    :
1421
elif test -z "$TCL_LIBRARY"; then
1422

    
1423
    cat 1>&2 << EOT
1424

    
1425
WARNING: The TCL_LIBRARY environment variable is not set, and without it
1426
Tkenv (the GUI runtime environment) may be unable to find the BLT library.
1427

    
1428
Add the following line to your .profile or .bash_profile (provided you use bash):
1429
  export TCL_LIBRARY=$tcl_library
1430

    
1431
For additional information, please visit the "Common installation problems"
1432
page on www.omnetpp.org.
1433
EOT
1434

    
1435
elif test ! -f "$TCL_LIBRARY/init.tcl" -a ! -f "$TCL_LIBRARY/tclConfig.sh"; then
1436

    
1437
    cat 1>&2 << EOT
1438

    
1439
WARNING: Your TCL_LIBRARY variable seems to be set incorrectly: there is no
1440
init.tcl or tclConfig.sh file in that directory. (Usual TCL_LIBRARY is /usr/lib/tcl8.4.)
1441
EOT
1442

    
1443
else
1444
    echo
1445
    echo "TCL_LIBRARY is set. Good!"
1446
fi
1447