summaryrefslogtreecommitdiff
path: root/otherlibs/labltk/configure.in
blob: 05097b94aa0216ce257a009fedcae691977b4572 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
dnl     This file is an input file used by the GNU "autoconf" program to
dnl     generate the file "configure", which in turn produces the files
dnl     "Makefile.config" and "labltklink".
dnl	If you don't have autoconf installed, simply use the "configure"
dnl	script.
dnl     Usage: 
dnl	  $ autoconf configure.in > configure
dnl	  edit site.config
dnl       $ ./configure -with-config=site.config
dnl     NOTE: autoconf 2.4 CHOKES on this. Use a newer version (e.g 2.7).

dnl This is the file that must exist in srcdir
AC_INIT(Widgets.src)

dnl Rather use gcc
AC_PROG_CC
AC_HAVE_HEADERS(unistd.h limits.h)

dnl Defaults for variables, overriden in site.config
LIBEXT=
TKNAME=tk

dnl We need locations in the first place
AC_ARG_WITH(config,
   [    --with-config=Site specific locations of various software. Check the INSTALL instructions],
   if test -f $withval; then
     SITECFG=`dirname $withval`/`basename $withval`
     . $SITECFG
   else
    AC_MSG_ERROR($withval does not exist)
   fi,
   AC_MSG_ERROR(
You must provide a file giving the location of various software using the option --with-config=file. Check the INSTALL instructions))

if test -z "$OCAMLLIBDIR"; then
  AC_MSG_ERROR("OCAMLLIBDIR is still undefined. Edit $SITECFG")
fi

if test -z "$INSTALLDIR"; then
  AC_MSG_ERROR("INSTALLDIR is still undefined. Edit $SITECFG")
fi

if test -z "$INSTALLBINDIR"; then
  AC_MSG_ERROR("INSTALLBINDIR is still undefined. Edit $SITECFG")
fi

dnl builtin rule for X
AC_PATH_XTRA
WITH_X="$X_LIBS $X_PRE_LIBS -lX11 $X_EXTRA_LIBS"
CPPFLAGS="$CPPFLAGS $X_CFLAGS"

dnl builtin rule for ranlib
AC_PROG_RANLIB

dnl where is cpp
AC_PATH_PROG(CPPPROG, cpp, /lib/cpp, $PATH)

dnl As soon as we use this, we must have install-sh available. Damn.
dnl AC_CANONICAL_HOST

LIBS="-lm"

### We probably need more
AC_CHECK_LIB(dl, dlopen, LIBS="-ldl $LIBS")

### Check for Tcl7.5(7.6,8.0) and Tk4.1(4.2)
AC_CHECKING(Tcl and Tk includes and libraries)

AC_CHECK_HEADERS(tcl.h,,
  AC_MSG_ERROR(Can't find tcl.h. Check the CPPFLAGS variable in $SITECFG))

AC_CHECK_HEADERS(tk.h,,
  AC_MSG_ERROR(Can't find tk.h. Check the CPPFLAGS variable in $SITECFG))

AC_MSG_CHECKING(Tcl version)
### Check Tcl version
tclver=no
AC_EGREP_CPP(^VERSION=.*7\.5, [#include <tcl.h>
VERSION=TCL_VERSION], tclver=7.5)
if test $tclver = no; then
AC_EGREP_CPP(^VERSION=.*7\.6, [#include <tcl.h>
VERSION=TCL_VERSION], tclver=7.6)
fi
if test $tclver = no; then
AC_EGREP_CPP(^VERSION=.*8\.0, [#include <tcl.h>
VERSION=TCL_VERSION], tclver=8.0)
fi
if test $tclver = no; then
AC_EGREP_CPP(^VERSION=.*8\.1, [#include <tcl.h>
VERSION=TCL_VERSION], tclver=8.1)
fi
if test $tclver = no; then
AC_EGREP_CPP(^VERSION=.*8\.2, [#include <tcl.h>
VERSION=TCL_VERSION], tclver=8.2)
fi
AC_MSG_RESULT($tclver)

case $tclver in
7.5) tclmaj=7 tclmin=5 tkmaj=4 tkmin=1 ;;
7.6) tclmaj=7 tclmin=6 tkmaj=4 tkmin=2 ;;
8.0) tclmaj=8 tclmin=0 tkmaj=8 tkmin=0 ;;
8.1) tclmaj=8 tclmin=1 tkmaj=8 tkmin=1 ;;
8.2) tclmaj=8 tclmin=2 tkmaj=8 tkmin=2 ;;
esac

if test x$tkmaj = x8; then
  CPPFLAGS="-DTK80 $CPPFLAGS"
fi

tcllib="tcl$tclmaj$tclmin$LIBEXT"
tcllibd="tcl$tclmaj.$tclmin$LIBEXT"

dnl We use Tcl_DoOneEvent to be sure to get version >= 7.5
AC_CHECK_LIB($tcllibd, Tcl_DoOneEvent,
             LIBS="-l$tcllibd $LIBS" tkver=$tkmaj.$tkmin,
 AC_CHECK_LIB($tcllib, Tcl_DoOneEvent,
	      LIBS="-l$tcllib $LIBS" tkver=$tkmaj$tkmin,
  AC_CHECK_LIB(tcl$LIBEXT, Tcl_DoOneEvent, LIBS="-ltcl$LIBEXT $LIBS",
    AC_MSG_ERROR(Can't find a tcl library.
Check config.log to see what happened, and try setting LDFLAGS in $SITECFG),
   $X_EXTRA_LIBS),
  $X_EXTRA_LIBS),
 $X_EXTRA_LIBS)

tklib="${TKNAME}${tkver}${LIBEXT}"

dnl We use Tk_SetGrid to be sure to get version >= 4.1
AC_CHECK_LIB($tklib, Tk_SetGrid, LIBS="-l$tklib $LIBS",
  AC_MSG_ERROR(Can't find a tk library.
Check config.log to see what happened, and try setting LDFLAGS in $SITECFG),
  $WITH_X -lm)

dnl This is the file that we produce
dnl These are the variables that are substituted in Makefile.config.in to
dnl produce Makefile.config

dnl The OCAML library
AC_SUBST(OCAMLLIBDIR)

dnl Install dir
AC_SUBST(INSTALLDIR)
AC_SUBST(INSTALLBINDIR)

dnl Info collected about X
dnl The includes and options
dnl AC_SUBST(X_CFLAGS)

dnl The libraries
dnl special trick to substitute -L and -l ...
dnl All options (for cc compilation)
AC_SUBST(WITH_X)
dnl X link options
AC_SUBST(X_LIBS)
THE_X_LIBS="$X_PRE_LIBS -lX11 $X_EXTRA_LIBS"
AC_SUBST(THE_X_LIBS)

dnl Tcl/Tk
dnl CPPFLAGS, LIBS and LDFLAGS are substituted by default

dnl Info collected about ranlib
AC_SUBST(RANLIB)
AC_SUBST(CPPPROG)
dnl LIBS is subsituted by default
AC_SUBST(OCAMLSRCDIR)

dnl Files to generate
AC_OUTPUT(Makefile.config labltk labltklink labltkopt)