~ubuntu-branches/ubuntu/gutsy/scigraphica/gutsy

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
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
dnl Process this file with autoconf to produce a configure script.
dnl debian changes
AC_PREREQ(2.52)
dnl debian changes end
AC_INIT(src)

AM_MAINTAINER_MODE
AM_CONFIG_HEADER(config.h)
AC_CANONICAL_SYSTEM

AM_INIT_AUTOMAKE(scigraphica, 0.8.0)

dnl --- Checks for programs.


dnl AM_ACLOCAL_INCLUDE(macros)

AC_ISC_POSIX
AC_PROG_CC
AC_PROG_RANLIB
AC_PROG_MAKE_SET
AC_STDC_HEADERS
AC_ARG_PROGRAM
AC_PROG_LIBTOOL

dnl Extra include and library paths

readline_path=""
AC_ARG_WITH(readline-path,   --with-readline-path=DIR		specify readline library path,
    readline_path=$withval)

termcap_path=""
AC_ARG_WITH(termcap-path,   --with-termcap-path=DIR		specify termcap library path,
    termcap_path=$withval)

LIBS="$LIBS  -L$termcap_path -L$readline_path"

readline_include_path=""
AC_ARG_WITH(readline-include-path,   --with-readline-include-path=DIR		specify readline include path,
    readline_include_path=$withval)

termcap_include_path=""
AC_ARG_WITH(termcap-include-path,   --with-termcap-include-path=DIR		specify termcap include path,
    termcap_include_path=$withval)

CFLAGS="$CFLAGS -I$termcap_include_path -I$readline_include_path"

dnl Check for termcap - fatal if it fails
AC_CHECK_LIB(termcap, tgoto,[TERMCAP_LIB="-ltermcap"],
AC_MSG_ERROR(Termcap not found))

dnl Check for readline
AC_CHECK_LIB(readline,readline,
[LIBS="$LIBS -lreadline $TERMCAP_LIB"],
AC_MSG_ERROR(Readline library not found),
$TERMCAP_LIB)

# SuSE-7.1 seems to need libncurses:
# not fatal if it fails, not all readlines use it
AC_CHECK_LIB(ncurses,tgoto,
[LIBS="$LIBS -lncurses"],,)

# FreeBSD needs -pthread flag with gcc
if test `uname` = FreeBSD ; then
  AC_CHECK_LIB(c_r,pthread_create,
  [LIBS="$LIBS -pthread"],,)
fi

AC_CHECK_LIB(readline,rl_free_line_state, 
[CFLAGS="$CFLAGS -DREADLINE_4"])

dnl echo "Readline library 4 or newer not found, terminal may be flakey...",$TERMCAP_LIB)

AC_SUBST(READLINE_LIB)

AC_PATH_PROG(XML_CONFIG,xml-config,no)
if test x$XML_CONFIG = xno; then
  AC_MSG_ERROR(Couldn't find xml-config)
fi
XML_LIBS=`xml-config --libs`
XML_CFLAGS=`xml-config --cflags`
AC_SUBST(XML_LIBS)
AC_SUBST(XML_CFLAGS)

dnl Check to make sure that we have libxml >= 1.7.2 installed
old_LIBS="$LIBS"
LIBS="$XML_LIBS $LIBS"
AC_CHECK_FUNC(xmlSAXUserParseFile,,
AC_MSG_ERROR([*** libxml >= 1.7.2 is required to compile libglade]))
LIBS="$old_LIBS"

dnl Set up Gnome
dnl Hmm, this causes autoheader to fail for LIBSM...
dnl GNOME_X_CHECKS

AC_ARG_ENABLE(imlib, [  --disable-imlib       Compile without imlib],
		    , [with_imlib=yes
AM_PATH_GDK_IMLIB(1.9.7,
            [LIBS="$LIBS $GDK_IMLIB_LIBS" CFLAGS="$CFLAGS $GDK_IMLIB_CFLAGS -DWITH_GDK_IMLIB"],
            AC_MSG_RESULT(Cannot find GdkImlib: disabling image handling))])


#AM_PATH_IMLIB(1.9.7,
#            [LIBS="$LIBS $IMLIB_LIBS" CFLAGS="$CFLAGS $IMLIB_CFLAGS -DWITH_IMLIB"],
#            (Cannot find Imlib: Is imlib-config in path?))

#AM_PATH_GDK_IMLIB(1.9.7,
#            [LIBS="$LIBS $GDK_IMLIB_LIBS" CFLAGS="$CFLAGS $GDK_IMLIB_CFLAGS -DWITH_GDK_IMLIB"],
#            AC_MSG_RESULT(Cannot find GdkImlib: disabling image handling))

AM_PATH_GTK(1.2.0,
            [LIBS="$LIBS $GTK_LIBS" CFLAGS="$CFLAGS $GTK_CFLAGS"],
            AC_MSG_ERROR(Cannot find GTK: Is gtk-config in path?))

AM_PATH_GTK_EXTRA(0.99.17,
            [LIBS="$LIBS $GTK_EXTRA_LIBS" CFLAGS="$CFLAGS $GTK_CFLAGS"],
            AC_MSG_ERROR(Cannot find GTK+EXTRA: Is gtkextra-config in path?))





enable_gnome=no
dnl GNOME_INIT_HOOK (script-if-gnome-enabled, [failflag], [additional-inits])
#GNOME_INIT_HOOK(enable_gnome=yes
#LIBS="$LIBS `$GNOME_CONFIG --libs gnome gnomeui`"
#CFLAGS="$CFLAGS `$GNOME_CONFIG --cflags gnome gnomeui` -DWITH_GNOME"
#GNOME_VERSION="`$GNOME_CONFIG --modversion`"
#
#,no_gnome)

### Check for Bonobo
bonobo=""

if eval "test x$enable_gnome != xno"; then

#AM_PATH_LIBART(,[LIBS="$LIBS $LIBART_LIBS" CFLAGS="$CFLAGS $LIBART_CFLAGS -DWITH_LIBART"],
#            AC_MSG_RESULT(Cannot find LIBART, disabling anti-aliasing))
#AM_PATH_GNOME_PRINT(,[CFLAGS="$CFLAGS -DWITH_GNOME_PRINT"],
#            AC_MSG_RESULT(Cannot find GNOME-PRINT, continuing))

AC_CHECK_PROG(libart_config_found,libart-config, yes,no)
AC_CHECK_LIB(art_lgpl, art_pixbuf_new_rgb,
[libart_found=yes],
AC_MSG_RESULT(Cannot find LIBART, disabling anti-aliasing)) 

if eval "test x$libart_found != xno && test x$libart_config_found != xno"; then
 LIBART_CFLAGS="`libart-config --cflags`"
 AC_SUBST(LIBART_CFLAGS)
 CFLAGS="$CFLAGS $LIBART_CFLAGS -DWITH_LIBART"
 LIBART_LIBS="`libart-config --libs`"
 AC_SUBST(LIBART_LIBS)
 LIBS="$LIBS $LIBART_LIBS"
fi

AC_ARG_WITH(bonobo,   --with-bonobo		compile with bonobo support,
   [ bonobo=$withval
bonobo_msg=no
AC_MSG_CHECKING(for Bonobo >= 0.18)
if gnome-config --libs bonobox_print > /dev/null 2>&1; then
	verstxt=`gnome-config --modversion bonobox_print`
	vers=`echo "$verstxt" | sed -e "s/^bonobo-//" | \
		awk -F. '{ printf "%d", $1 * 1000 + $2; }'`

	if test "$vers" -ge 18; then
		bonobo_ok=true
		AC_SUBST(WITH_BONOBO)
		AM_CONDITIONAL(WITH_BONOBO,$bonobo_ok)
		AC_DEFINE(WITH_BONOBO)
		BONOBO_CFLAGS=`gnome-config --cflags bonobox_print`
		BONOBO_LIBS="-lbonobo-print `gnome-config --libs bonobox_print`"
		bonobo_msg=yes
	else
		bonobo_ok=false
	fi
else
	bonobo_ok=false
fi

if $bonobo_ok; then
	AC_MSG_RESULT($vers found)
	AC_MSG_CHECKING(if Bonobo uses OAF)
	if ( gnome-config --libs bonobo | grep oaf ) > /dev/null 2>&1 ; then
		enable_oaf="yes"
	else
		enable_oaf="no"
	fi

	AC_MSG_RESULT("$enable_oaf")

	if test "x$enable_oaf" = "xyes"; then
        	AC_PATH_PROG(OAF_CONFIG,oaf-config,no)
	        if test x$OAF_CONFIG = xno; then
        	        AC_MSG_ERROR("You enabled OAF support but oaf-config was not found")
	        else
dnl Success
	                OAF_LIBS=`$OAF_CONFIG --libs`
	                OAF_CFLAGS=`$OAF_CONFIG --cflags`


	        fi
	else
	        OAF_LIBS=
	        OAF_CFLAGS=
	fi
	AC_SUBST(OAF_LIBS)
	AC_SUBST(OAF_CFLAGS)
	AC_SUBST(BONOBO_LIBS)
	AC_SUBST(BONOBO_CFLAGS)
else
	AC_MSG_RESULT(not found)
fi])

else
  AM_CONDITIONAL(HAVE_ORBIT, false)
  AM_CONDITIONAL(HAVE_GNORBA, false)
  AM_CONDITIONAL(WITH_BONOBO, false)
fi

dnl
dnl gnome-pty-support checks
dnl

AC_MSG_CHECKING([for Unix98 sendmsg])
AC_TRY_LINK([
#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
],[
struct msghdr hdr;
hdr.msg_control = NULL;
hdr.msg_controllen = 0;
sendmsg (0, &hdr, 0);
],[
AC_DEFINE(HAVE_SENDMSG)
AC_MSG_RESULT(yes)],[AC_MSG_RESULT(no)])

dnl AC_CHECK_UTMP
dnl AC_CHECK_LASTLOG

AC_CHECK_HEADERS(pty.h util.h libutil.h ttyent.h)

AC_CHECK_LIB(util, openpty,
    [
    AC_CHECK_LIB(util, login_tty, [AC_DEFINE(HAVE_LOGIN_TTY)])
    AC_DEFINE(HAVE_OPENPTY)
    AC_DEFINE(HAVE_LIBUTIL)
    UTIL_LIBS="-lutil"
    AC_SUBST(UTIL_LIBS)
    ])

AC_CHECK_FUNCS(grantpt utmpxname utmpname getutmpx getutent getttyent)
AC_CHECK_FUNCS(updwtmpx updwtmp fcntl flock strrchr seteuid setreuid)

AC_CHECK_HEADER(stropts.h, AC_DEFINE(HAVE_STROPTS_H))
AC_CHECK_HEADER(dlfcn.h, AC_DEFINE(HAVE_DLFCN_H))

dnl And workaround for a Autoconf 2.4 bug:
if test x$ac_cv_func_grantpt = xyes; then
    :
else
    AC_CHECK_LIB(pt, grantpt)
fi


dnl --- Checks for libraries.







dnl --- Check for printing subsys
dnl these printer tests might need to be better arranged.
dnl I think there should be a standard printing.m4 program or something.

lp_path=":"
AC_ARG_ENABLE(lp_path, [  --with-lp=DIR           set lp command location],
if eval "test x$with_lp != x"; then
    lp_path=$with_lp
fi)
lpr_path=":"
AC_ARG_ENABLE(lpr_path, [  --with-lpr=DIR          set lpr command location],
if eval "test x$with_lpr != x"; then
    lpr_path=$with_lpr
fi)

dnl whether lp/lpr is available or not doesn't affect building, so
dnl these are commented out on Debian packaging.

dnl tests for lp

#if eval "test x$with_lpr = x"; then
#  AC_PATH_PROG(LP_COMMAND, "lp", $lp_path,
#    $PATH:/usr/bin:/usr/sbin:/usr/ucb:/usr/bsd)
#
#  if test $ac_cv_path_LP_COMMAND != ":"; then
#    AC_DEFINE_UNQUOTED(PRINT_COMMAND, "$ac_cv_path_LP_COMMAND")
#    using_lp=1
#  fi
#fi

dnl tests for lpr

#if eval "test x$using_lp = x"; then
#  AC_PATH_PROG(LPR_COMMAND, "lpr", $lpr_path,
#    $PATH:/usr/bin:/usr/sbin:/usr/ucb:/usr/bsd)
#
#  if test $ac_cv_path_LPR_COMMAND != ":"; then
#    AC_DEFINE_UNQUOTED(PRINT_COMMAND, "$ac_cv_path_LPR_COMMAND")
#    using_lpr=1 
#  fi
#fi

test "x$prefix" = xNONE && prefix=$ac_default_prefix

AC_DEFINE_UNQUOTED(LOCALEDIR, "${prefix}/share/locale")

dnl **************************************************
dnl * Check for Python
dnl **************************************************
dnl
dnl debian changes
dnl AC_CHECK_PROG(python_val, python, true, false)
if test "x$PYTHON" = x; then
  PYTHON="python"
fi
dnl debian changes ends
numpy=false


if $python_val; then
           pysga_prefix=""
           AC_ARG_WITH(python-script-prefix,   --with-python-script-prefix=DIR	specify python script installation prefix,
               pysga_prefix=$withval)
           python_prefix=""
           AC_ARG_WITH(python-prefix,   --with-python-prefix=DIR	specify alternative (non-system) python installation directory,
               python_prefix=$withval)
          if test x$python_prefix = x; then 
           PY_PREFIX=`$PYTHON -c 'import sys ; print sys.prefix'`
           PY_EXEC_PREFIX=`$PYTHON -c 'import sys ; print sys.exec_prefix'`
          else
           echo "Using alternative python installation under $python_prefix"
           PY_PREFIX=$python_prefix
           PY_EXEC_PREFIX=$python_prefix
          fi

	  changequote(<<, >>)dnl
	  PY_VERSION=`$PYTHON -c 'import sys ; print sys.version[0:3]'`
          PY_VVERSION=`$PYTHON -c 'import sys ; print sys.version[0:5]'`
	  changequote([, ])dnl
          echo "Searching for arrayobject.h"
	  if test -f $PY_PREFIX/include/python$PY_VERSION/Python.h; then
		  PY_LIBS="python$PY_VERSION"
		  PY_LIB_LOC="$PY_EXEC_PREFIX/lib/python$PY_VERSION/"
                  array_loc=`find $PY_PREFIX/include/python$PY_VERSION/ -name arrayobject.h | sed s/arrayobject\.h//`
                  if test x$array_loc = x; then 
                    echo "...trying from $PY_PREFIX" 
                    array_loc=`find $PY_PREFIX/ -name arrayobject.h | sed s/arrayobject\.h//`
                  fi
                  echo arrayobject.h location: $array_loc
                  PY_CFLAGS="-I$PY_PREFIX/include/python$PY_VERSION"
                  if  test -n $array_loc; then
                   if  test -d $array_loc; then
                     PY_CFLAGS="$PY_CFLAGS -I$array_loc -DWITH_NUMERIC_PYTHON"
                     numpy=true
                   fi
                  fi 

		  PY_MAKEFILE="$PY_EXEC_PREFIX/lib/python$PY_VERSION/config/Makefile"
		  PY_LOCALMODLIBS=`sed -n -e 's/^LOCALMODLIBS=\(.*\)/\1/p' $PY_MAKEFILE`
		  PY_BASEMODLIBS=`sed -n -e 's/^BASEMODLIBS=\(.*\)/\1/p' $PY_MAKEFILE`
		  PY_OTHER_LIBS=`sed -n -e 's/^LIBS=\(.*\)/\1/p' $PY_MAKEFILE`
		  PY_EXTRA_LIBS="$PY_LOCALMODLIBS $PY_BASEMODLIBS $PY_OTHER_LIBS"
		  AC_SUBST(PY_LIBS)
		  AC_SUBST(PY_LIB_LOC)
		  AC_SUBST(PY_CFLAGS)
		  AC_SUBST(PY_EXTRA_LIBS)
	  else
		  python_val=false
                  echo Python.h header file not found
	  fi
fi

AM_CONDITIONAL(WITH_PYTHON, $python_val)
if eval "test x$array_loc = x"; then
 echo Numerical python not found!
 exit
fi

if test x$pysga_prefix = x; then 
 PYTHON_MOD_DIR=${datadir}/scigraphica/python
else
 PYTHON_MOD_DIR=$pysga_prefix
fi

 AC_SUBST(PYTHON_MOD_DIR)

dnl if test x$enable_gnome = xno; then
 CFLAGS="$CFLAGS -I../zvt -I../../zvt"
 LIBS="$LIBS -L../zvt -lsgvt"
dnl fi

UNAME=`uname -s -m -r -p`
GTK_EXTRA_VERSION=`$GTK_EXTRA_CONFIG --version`
GTK_VERSION=`$GTK_CONFIG --version`
XML_VERSION=`$XML_CONFIG --version`

# strip duplicate entries in compiler flags
echo "stripping compiler flags"
COMPILER_FLAGS=""
for i in $CC $CFLAGS $XML_CFLAGS $GDK_IMLIB_CFLAGS $GTK_CFLAGS $GTK_EXTRA_CFLAGS \
         $PY_CFLAGS $LIBS $XML_LIBS $GDK_IMLIB_LIBS $GTK_LIBS $GTK_EXTRA_LIBS $LDFLAGS
do
   found="false"
   for k in $COMPILER_FLAGS
   do
      test "$i" = "$k" && { found="true" ; break ; }
   done
   test "$found" = "false" && COMPILER_FLAGS="$COMPILER_FLAGS $i"
done

AC_DEFINE_UNQUOTED(VERSION_INFO, "sg-$VERSION\\n$UNAME\\n\
gtk-$GTK_VERSION  gtkextra-$GTK_EXTRA_VERSION  $GNOME_VERSION\\n\
xml-$XML_VERSION  python-$PY_VVERSION  $array_loc\\n"\
__DATE__ " " __TIME__ "\\n\
Compiler flags:$COMPILER_FLAGS\\n\
(C) 2000 Adrian E. Feiguin\\n"
)

AC_DEFINE_UNQUOTED(SG_ROOT, "$prefix")

AC_DEFINE_UNQUOTED(SG_DOCVIEWER, "sensible-browser %s >/dev/null 2>&1")

AC_OUTPUT(
Makefile
sg.spec
sg-mdk.spec
docs/Makefile
src/Makefile
src/python/Makefile
pixmaps/Makefile
zvt/Makefile
macros/Makefile
examples/Makefile
)