summaryrefslogtreecommitdiff
path: root/acinclude.m4
blob: d3c9dfdd4ddf9bbe2bb99289cb61f75b2f3429ad (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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
dnl
dnl Added macros
dnl JAPHAR_GREP_CFLAGS
dnl CLASSPATH_CHECK_JAPHAR
dnl CLASSPATH_CHECK_KAFFE
dnl CLASSPATH_CHECK_THREADS
dnl CLASSPATH_CHECK_GLIB
dnl CLASSPATH_CHECK_GTK
dnl

dnl JAPHAR_GREP_CFLAGS(flag, cmd_if_missing, cmd_if_present)
AC_DEFUN(JAPHAR_GREP_CFLAGS,
[case "$CFLAGS" in
"$1" | "$1 "* | *" $1" | *" $1 "* )
  ifelse($#, 3, [$3], [:])
  ;;
*)
  $2
  ;;
esac
])

dnl CLASSPATH_INTERNAL_CHECK_JAPHAR
AC_DEFUN(CLASSPATH_INTERNAL_CHECK_JAPHAR,
[
  if test "$1" = ""; then
    AC_PATH_PROG(JAPHAR_CONFIG, japhar-config, "", $PATH:/usr/local/japhar/bin:/usr/japhar/bin)
  else
    AC_PATH_PROG(JAPHAR_CONFIG, japhar-config, "", $1/bin:$PATH)
  fi
  if test "$JAPHAR_CONFIG" = ""; then
    echo "configure: cannot find japhar-config: is Japhar installed?" 1>&2
    exit 1
  fi
  AC_MSG_CHECKING(for Japhar)
  JAPHAR_PREFIX="`$JAPHAR_CONFIG --prefix`"
  JAPHAR_CFLAGS="`$JAPHAR_CONFIG compile`"
  JAPHAR_LIBS="`$JAPHAR_CONFIG link`"
  JVM="yes"
  JVM_REFERENCE="reference"
  AC_SUBST(JAPHAR_PREFIX)
  AC_SUBST(JAPHAR_CFLAGS)
  AC_SUBST(JAPHAR_LIBS)
  AC_SUBST(JVM)
  AC_SUBST(JVM_REFERENCE)
  conditional_with_japhar=true
  AC_MSG_RESULT(yes)

  dnl define WITH_JAPHAR for native compilation
  AC_DEFINE(WITH_JAPHAR)

  dnl Reset prefix so that we install into Japhar directory
  prefix=$JAPHAR_PREFIX
  AC_SUBST(prefix)

  dnl programs we probably need somewhere
  _t_bindir=`$JAPHAR_CONFIG info bindir`
  _t_datadir=`$JAPHAR_CONFIG info datadir`
  AC_PATH_PROG(JAPHAR_JABBA, japhar, "", $_t_bindir:$PATH)
  AC_PATH_PROG(JAPHAR_JAVAC, javac, "", $_t_bindir:$PATH)
  AC_PATH_PROG(JAPHAR_JAVAH, javah, "", $_t_bindir:$PATH)
  AC_MSG_CHECKING(for Japhar classes)
  if test -e $_t_datadir/classes.zip; then
    JAPHAR_CLASSLIB=$_t_datadir/classes.zip
  elif test -e $_t_datadir/classes.jar; then
    JAPHAR_CLASSLIB=$_t_datadir/classes.jar
  elif test -e $_t_datadir/rt.jar; then
    JAPHAR_CLASSLIB=$_t_datadir/rt.jar
  elif test -e $_t_datadir/rt.zip; then
    JAPHAR_CLASSLIB=$_t_datadir/rt.zip
  fi
  if test $JAPHAR_CLASSLIB ; then
    AC_MSG_RESULT(yes)
  else
    AC_MSG_RESULT(no)
  fi
  AC_SUBST(JAPHAR_CLASSLIB)
])

dnl CLASSPATH_INTERNAL_CHECK_KAFFE
AC_DEFUN(CLASSPATH_INTERNAL_CHECK_KAFFE,
[
  AC_PATH_PROG(KAFFE_CONFIG, kaffe-config, "", $PATH:/usr/local/kaffe/bin:/usr/kaffe/bin)
  if test "$KAFFE_CONFIG" = ""; then
    echo "configure: cannot find kaffe-config: is Kaffe installed?" 1>&2
    exit 1
  fi
  AC_MSG_CHECKING(for Kaffe)

  KAFFE_PREFIX="`$KAFFE_CONFIG --prefix`"
  KAFFE_CFLAGS="`$KAFFE_CONFIG compile`"
  KAFFE_LIBS="`$KAFFE_CONFIG link`"
  JVM="yes"
  JVM_REFERENCE="kaffe"
  AC_SUBST(KAFFE_PREFIX)
  AC_SUBST(KAFFE_CFLAGS)
  AC_SUBST(KAFFE_LIBS)
  AC_SUBST(JVM)
  AC_SUBST(JVM_REFERENCE)

  conditional_with_kaffe=true
  AC_MSG_RESULT(yes)

  dnl define WITH_KAFFE for native compilation
  AC_DEFINE(WITH_KAFFE)

  dnl Reset prefix so that we install into the Kaffe directory
  prefix=$KAFFE_PREFIX
  AC_SUBST(prefix)

  dnl programs we probably need somewhere
  _t_bindir=`$KAFFE_CONFIG info bindir`
  _t_datadir=`$KAFFE_CONFIG info datadir`
  AC_PATH_PROG(KAFFE_JABBA, kaffe, "", $_t_bindir:$PATH)

  AC_MSG_CHECKING(for kjc)
  if test -e $_t_datadir/kaffe/kjc.jar; then
    KJC_CLASSPATH=$_t_datadir/kaffe/kjc.jar
    AC_SUBST(KJC_CLASSPATH)
    conditional_with_kjc=true
    AC_MSG_RESULT(${withval})
  elif test -e $_t_datadir/kjc.jar; then
    KJC_CLASSPATH=$_t_datadir/kjc.jar
    AC_SUBST(KJC_CLASSPATH)
    conditional_with_kjc=true
    AC_MSG_RESULT(${withval})
  else
    conditional_with_kjc=false
    AC_MSG_RESULT(no)
  fi
  
  AC_PATH_PROG(KAFFE_JAVAH, kaffeh, "", $_t_bindir:$PATH)

  AC_MSG_CHECKING(for Kaffe classes)
  KAFFE_CLASSLIB=""
  if test -e $_t_datadir/glibj.jar; then
    KAFFE_CLASSLIB=$_t_datadir/glibj.jar
  elif test -e $_t_datadir/kaffe/glibj.jar; then
    KAFFE_CLASSLIB=$_t_datadir/kaffe/glibj.jar
  elif test -e $_t_datadir/Klasses.jar; then
    KAFFE_CLASSLIB=$_t_datadir/Klasses.jar
  elif test -e $_t_datadir/kaffe/Klasses.jar; then
    KAFFE_CLASSLIB=$_t_datadir/kaffe/Klasses.jar
  else
    AC_MSG_RESULT(no)
  fi
  AC_MSG_RESULT(yes)
  if test -e $_t_datadir/rmi.jar; then
    KAFFE_CLASSLIB=$KAFFE_CLASSLIB:$_t_datadir/rmi.jar
  fi
  if test -e $_t_datadir/kaffe/rmi.jar; then
    KAFFE_CLASSLIB=$KAFFE_CLASSLIB:$_t_datadir/kaffe/rmi.jar
  fi
  if test -e $_t_datadir/tools.jar; then
    KAFFE_CLASSLIB=$KAFFE_CLASSLIB:$_t_datadir/tools.jar
  fi
  if test -e $_t_datadir/kaffe/tools.jar; then
    KAFFE_CLASSLIB=$KAFFE_CLASSLIB:$_t_datadir/kaffe/tools.jar
  fi

  AC_SUBST(KAFFE_CLASSLIB)
])

dnl CLASSPATH_CHECK_JAPHAR - checks for japhar
AC_DEFUN(CLASSPATH_CHECK_JAPHAR,
[
  AC_ARG_WITH(japhar, 
  [  --with-japhar		  configure GNU Classpath for Japhar [default=yes]],
  [
    if test ${withval} = "yes" || test ${withval} = ""; then
      CLASSPATH_INTERNAL_CHECK_JAPHAR
    elif test ${withval} != "no" || test ${withval} != "false"; then
      CLASSPATH_INTERNAL_CHECK_JAPHAR(${withval})
    fi
  ],
  [ 
    conditional_with_japhar=false
    JAPHAR_CFLAGS=""
    AC_SUBST(JAPHAR_CFLAGS)
  ])
])

dnl CLASSPATH_CHECK_KAFFE - checks for which java virtual machine to use
AC_DEFUN(CLASSPATH_CHECK_KAFFE,
[
  AC_ARG_WITH(kaffe, 
  [  --with-kaffe		  configure GNU Classpath for Kaffe [default=no]],
  [   
    if test ${withval} = "yes" || test ${withval} = ""; then
      CLASSPATH_INTERNAL_CHECK_KAFFE
    fi
  ],
  [ conditional_with_kaffe=false
    KAFFE_CFLAGS=""
    AC_SUBST(KAFFE_CFLAGS)
  ])
])

dnl threads packages (mostly stolen from Japhar)
dnl given that japhar-config gives -lpthread, may not need this (cbj)
AC_DEFUN(CLASSPATH_CHECK_THREADS,
[
  threads=no

  if test "x${threads}" = xno; then
    AC_CHECK_LIB(threads, cthread_fork)
    if test "x${ac_cv_lib_threads_cthread_fork}" = xyes; then
        AC_DEFINE(USE_CTHREADS, )
        threads=yes
    fi
  fi

  if test "x${threads}" = xno; then
    AC_CHECK_FUNCS(_beginthreadex)
    if test "x${ac_cv_CreateThread}" = xyes; then
        AC_DEFINE(USE_WIN32_THREADS, )
        AC_CHECK_FUNCS(CloseHandle SetThreadPriority ExitThread Sleep \
                GetCurrentThreadId TlsAlloc TlsSetValue TlsGetValue)
        threads=yes
    fi
  fi

  if test "x${threads}" = xno; then
    AC_CHECK_LIB(pthread, pthread_create)
    if test "x${ac_cv_lib_pthread_pthread_create}" = xyes; then
      threads=yes
    fi

    if test "x${threads}" = xno; then
      AC_CHECK_LIB(c_r, pthread_create)
      if test "x${ac_cv_lib_c_r_pthread_create}" = xyes; then
        threads=yes
      fi
    fi

    if test "x${threads}" = xno; then
      # HP/UX 10.20 uses -lcma
      AC_CHECK_LIB(cma, pthread_create)
      if test "x${ac_cv_lib_cma_pthread_create}" = xyes; then
        threads=yes
      fi
    fi

    if test "x${threads}" = xno; then
      AC_CHECK_LIB(c, pthread_create)
      if test "x${ac_cv_lib_c_pthread_create}" = xyes; then
        threads=yes
      fi
    fi

    if test "x${threads}" = xyes; then
      AC_DEFINE(USE_PTHREADS, )
    fi
  fi
])

dnl CLASSPATH_INTERNAL_CHECK_JIKES
AC_DEFUN(CLASSPATH_INTERNAL_CHECK_JIKES,
[
  AC_PATH_PROG(JIKES, jikes, "", $PATH:/usr/local/bin)
  if test "$JIKES" = ""; then
    echo "configure: cannot find jikes: is jikes in your path?" 1>&2
    exit 1
  fi
])


dnl CLASSPATH_CHECK_JIKES - checks for jikes
AC_DEFUN(CLASSPATH_CHECK_JIKES,
[
  AC_ARG_WITH(jikes, 
  [  --with-jikes		  compile classes with jikes [default=no]],
  [
    if test ${withval} != "no"; then
      if test ${withval} = "" || test ${withval} = "yes"; then
        CLASSPATH_INTERNAL_CHECK_JIKES
      else 
        JIKES=${withval}
	AC_SUBST(JIKES)
      fi
      conditional_with_jikes=true
    fi
  ],
  [ 
    conditional_with_jikes=false
  ])
])


dnl CLASSPATH_CHECK_KJC - checks for kjc
AC_DEFUN(CLASSPATH_CHECK_KJC,
[
  AC_ARG_WITH(kjc, 
  [  --with-kjc=DIR	  compile classes with kjc [default=no]],
  [
    if test ${withval} != "no"; then
      AC_MSG_CHECKING(for kjc)
      if test ${withval} = "" || test ${withval} = "yes"; then
        AC_MSG_ERROR(specify a classpath to kjc)
      fi
      KJC_CLASSPATH=${withval}
      AC_SUBST(KJC_CLASSPATH)
      conditional_with_kjc=true
      AC_MSG_RESULT(${withval})
    fi
  ],
  [ 
    conditional_with_kjc=false
  ])
])