Statistics
| Branch: | Revision:

root / configure.in @ 7f251033

History | View | Annotate | Download (48.6 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 wish.
851
    AC_CHECK_PROGS(WISH, $WISH wish wish86 wish8.6 wish85 wish8.5 wish84 wish8.4 cygwish cygwish86 cygwish85 cygwish84, nope)
852
    if test "$WISH" = nope; then
853
       AC_MSG_ERROR([Cannot find wish, part of Tcl/Tk -- maybe it is not in the PATH or has some exotic name (tested names were: wish wish86 wish8.6 wish85 wish8.5 wish84 wish8.4 cygwish cygwish86 cygwish85 cygwish84)])
854
    fi
855
    if echo 'puts OK; exit' | $WISH | grep OK >/dev/null; then :; else
856
        AC_MSG_ERROR([Cannot run wish (wish command "puts OK; exit" failed): maybe you are not running X or DISPLAY environment variable not set?])
857
    fi
858
    if echo 'catch {package require Tk 8.4; puts OK}; exit' | $WISH | grep OK >/dev/null; then :; else
859
        AC_MSG_ERROR([wish command "package require Tk 8.4" failed: probably old Tcl/Tk version, version 8.4.0+ required])
860
    fi
861

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

    
865

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

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

    
883
    # and build samples using Tkenv
884
    ALL_ENV_LIBS='$(TKENV_LIBS) $(CMDENV_LIBS)'
885

    
886
fi # end of Tcl tests ($NO_TCL=="" branch)
887

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

    
896
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
897
SYS_LIBS="$SYS_LIBS $PTHREAD_LIBS"
898

    
899

    
900
#----------------------
901
# Check for libatomic-ops-dev
902
#----------------------
903
OPP_CHECK_LIB(ATOMIC-OPS, atomic_ops.h, AO_load, $ATOMIC_OPS_CFLAGS, $ATOMIC_OPS_LIBS, atomic_ops_ok)
904
if test $atomic_ops_ok = no; then
905
    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.])
906
fi
907

    
908
CFLAGS="$CFLAGS $ATOMIC_OPS_CFLAGS"
909
USER_CFLAGS="$USER_CFLAGS $ATOMIC_OPS_CFLAGS"
910
SYS_LIBS="$SYS_LIBS $ATOMIC_OPS_LIBS"
911

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

    
921
#----------------------
922
# Check for JDK
923
#----------------------
924

    
925
if test "$JAVA_CFLAGS" = ""; then
926
   if test "$JDK" = ""; then
927
     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"
928
     for dir in $javahome_candidates; do
929
         if test "$JAVA_HOME" = "" -a -d "$dir"; then
930
             JAVA_HOME=$dir
931
         fi
932
     done
933
   else
934
     JAVA_HOME=$JDK
935
   fi
936
   if test "$JAVA_HOME" = ""; then
937
      AC_MSG_WARN(JAVA_HOME variable not set.)
938
   else
939
      JAVA_CFLAGS="-fno-strict-aliasing -I$JAVA_HOME/include -I$JAVA_HOME/include/$jni_platform"
940
      JAVA_LIBS="-L$JAVA_HOME/jre/lib/i386/client -Wl,-rpath,$JAVA_HOME/jre/lib/i386/client:. -ljvm"
941
   fi
942
fi
943

    
944
OPP_CHECK_LIB_NOLINK(JNI, jni.h, JNI_GetCreatedJavaVMs(0,0,0), $CFLAGS_RELEASE $JAVA_CFLAGS, jni_ok)
945

    
946
if test "$jni_ok" = "no" -o "$SWIG" = "not found"; then
947
   JNILIBS_IF_POSSIBLE=missing-dependency
948
else
949
   JNILIBS_IF_POSSIBLE=jnilibs
950
fi
951

    
952
#----------------------
953
# Check for MPI.
954
#----------------------
955

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

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

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

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

    
995

    
996
#----------------------
997
# Check for PCAP.
998
#----------------------
999

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

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

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

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

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

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

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

    
1096
CFLAGS_DEBUG="$CFLAGS_DEBUG -DXMLPARSER=$XMLPARSER"
1097
CFLAGS_RELEASE="$CFLAGS_RELEASE -DXMLPARSER=$XMLPARSER"
1098

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

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

    
1119

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

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

    
1158

    
1159
#----------------------
1160
# Files to be generated
1161
#----------------------
1162
AC_CONFIG_FILES(
1163
  Makefile.inc
1164
)
1165

    
1166
#----------------------
1167
# Substitutions.
1168
#----------------------
1169

    
1170
AC_SUBST(OMNETPP_PRODUCT)
1171
AC_SUBST(OMNETPP_RELEASE)
1172
AC_SUBST(OMNETPP_VERSION)
1173
AC_SUBST(OMNETPP_BUILDID)
1174
AC_SUBST(OMNETPP_EDITION)
1175

    
1176
AC_SUBST(OMNETPP_ROOT)
1177
AC_SUBST(OMNETPP_BIN_DIR)
1178
AC_SUBST(OMNETPP_INCL_DIR)
1179
AC_SUBST(OMNETPP_OUT_DIR)
1180
AC_SUBST(OMNETPP_LIB_DIR)
1181
AC_SUBST(OMNETPP_IMAGE_PATH)
1182

    
1183
AC_SUBST(OMNETPP_SRC_DIR)
1184
AC_SUBST(OMNETPP_UI_DIR)
1185
AC_SUBST(OMNETPP_UTILS_DIR)
1186
AC_SUBST(OMNETPP_DOC_DIR)
1187
AC_SUBST(OMNETPP_TEST_DIR)
1188

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

    
1216
AC_SUBST(SHARED_LIBS)
1217
AC_SUBST(A_LIB_SUFFIX)
1218
AC_SUBST(SHARED_LIB_SUFFIX)
1219
AC_SUBST(JNI_LIB_SUFFIX)
1220
AC_SUBST(SO_LIB_SUFFIX)
1221
AC_SUBST(DLL_LIB_SUFFIX)
1222
AC_SUBST(EXE_SUFFIX)
1223
AC_SUBST(LIB_PREFIX)
1224

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

    
1244
AC_SUBST(XMLPARSER)
1245
AC_SUBST(XML_CFLAGS)
1246
AC_SUBST(XML_LIBS)
1247

    
1248
AC_SUBST(AKAROA_CFLAGS)
1249
AC_SUBST(AKAROA_LIBS)
1250

    
1251
AC_SUBST(TKENV_IF_POSSIBLE)
1252
AC_SUBST(JNILIBS_IF_POSSIBLE)
1253

    
1254
AC_SUBST(ALL_ENV_LIBS)
1255

    
1256
AC_SUBST(EMBED_TCL_CODE)
1257
AC_SUBST(OMNETPP_TKENV_DIR)
1258

    
1259
AC_SUBST(WITH_NETBUILDER)
1260
AC_SUBST(WITH_PARSIM)
1261

    
1262
AC_SUBST(JAVA_CFLAGS)
1263
AC_SUBST(JAVA_LIBS)
1264
AC_SUBST(SWIG)
1265
AC_SUBST(PLATFORM)
1266

    
1267
#
1268
# Generate files
1269
#
1270
AC_OUTPUT
1271

    
1272
chmod +x src/utils/opp_makemake
1273
chmod +x src/utils/opp_test
1274
chmod +x src/utils/opp_makedep
1275
chmod +x src/utils/omnest
1276
chmod +x src/utils/omnetpp
1277
chmod +x src/utils/opp_test
1278

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

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

    
1318
#----------------------
1319
# Check $OPP_PROBLEM_PACKAGES
1320
#----------------------
1321

    
1322
if test "$OPP_PROBLEM_PACKAGES" != ""; then
1323
  cat 1>&2 << EOT
1324

    
1325
WARNING: The configuration script could not detect the following packages:
1326

    
1327
  $OPP_PROBLEM_PACKAGES
1328

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

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

    
1340
EOT
1341
  fi
1342
fi
1343

    
1344

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

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

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

    
1372
EOT
1373
    else
1374
      cat 1>&2 << EOT
1375

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

    
1380
EOT
1381
    fi
1382
  fi
1383
  rm $omnetpp_bin_dir/$probefile
1384
fi
1385

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

    
1391
    cat 1>&2 << EOT
1392

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

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

    
1401
fi
1402

    
1403
#----------------------
1404
# Check if TCL_LIBRARY is set.
1405
#----------------------
1406

    
1407
if test -n "$NO_TCL"; then
1408

    
1409
    cat << EOT
1410

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

    
1416
elif test "$PLATFORM" = "macosx"; then
1417
    :
1418
elif test -z "$TCL_LIBRARY"; then
1419

    
1420
    cat 1>&2 << EOT
1421

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

    
1425
Add the following line to your .profile or .bash_profile (provided you use bash):
1426
  export TCL_LIBRARY=$tcl_library
1427

    
1428
For additional information, please visit the "Common installation problems"
1429
page on www.omnetpp.org.
1430
EOT
1431

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

    
1434
    cat 1>&2 << EOT
1435

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

    
1440
else
1441
    echo
1442
    echo "TCL_LIBRARY is set. Good!"
1443
fi
1444