File: configure

package info (click to toggle)
yorick-z 1.2.0%2Bcvs20080115-5
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, jessie, jessie-kfreebsd, stretch, wheezy
  • size: 296 kB
  • ctags: 269
  • sloc: ansic: 2,004; sh: 405; makefile: 107
file content (482 lines) | stat: -rwxr-xr-x 11,473 bytes parent folder | download | duplicates (3)
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
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
#!/bin/sh
# $Id: configure,v 1.4 2007/12/26 11:34:57 thiebaut Exp $

echo ""
echo "================ begin yorick-z configuration ===================="
echo ""

# note: ZLIB_INC, ZLIB_LIB, PNG_INC, PNG_LIB, JPEG_INC, JPEG_LIB,
#       AVCODEC_INC, AVCODEC_LIB
# environment variables can be used to set detailed default values
# --zlib=, --png=, --jpeg=, --avcodec= command line options are designed
# for the simple case in which the library has been built in place from
# its source distribution and NOT installed

curdate=`date`
cursystem=`uname -a`
fatality=0

# should LD_LIBRARY_PATH, LIBPATH (AIX), LPATH, SHLIB_PATH (HPUX) be saved?

yorick_exe="yorick"
zlib_path=
png_path=
jpeg_path=
av_path=
av_dlopen="no"
debug="no"
use_a="no"
for opt do
  case "$opt" in
  --debug) debug="yes"
  ;;
  --yorick=*) yorick_exe=`echo $opt | sed -e s/--yorick=//`
  ;;
  --zlib=*) zlib_path=`echo $opt | sed -e s/--zlib=//`
  ;;
  --png=*) png_path=`echo $opt | sed -e s/--png=//`
  ;;
  --jpeg=*) jpeg_path=`echo $opt | sed -e s/--jpeg=//`
  ;;
  --avcodec=*) av_path=`echo $opt | sed -e s/--avcodec=//`
  ;;
  --dl-avcodec) av_dlopen="yes"
  ;;
  --no-avcodec) av_dlopen="skip"
  ;;
  --a) use_a="yes"
  ;;
  *) cat <<EOF
Usage:   ./configure [options]
Options are one or more of:
  --yorick=/path/to/yorick
      set path to yorick executable (if not on your PATH)
  --zlib=/path/to/zlib-version
      set path to directory containing zlib.h and libz.a (uninstalled)
  --png=/path/to/png-version
      set path to directory containing png.h and libpng.a (uninstalled)
  --jpeg=/path/to/jpeg-version
      set path to directory containing jpeglib.h and libjpeg.a (uninstalled)
  --avcodec=/path/to/ffmpeg-version/libavcodec
      set path to directory containing avcodec.h and libavcodec.a (uninstalled)
  --dl-avcodec    search for libavcodec (ffmpeg) at runtime
      (allows code to work if not present, default if configure does
       not find libavcodec, overrides --avcodec=)
EOF
  exit 1
  ;;
  esac
done

rm -f cfg.* ycode.* yinit.* ywrap.*
rm -f core a.out *.o *.a *.so *.sl *.dylib *.dll *~ '#'*
rm -f yorick Makeyorz yorz.i test*.mpg test*.jpg test*.png cfg*

case "$yorick_exe" in
  */*)
    if test -x "$yorick_exe" -a ! -d "$yorick_exe"; then
      Y_BINDIR=`dirname "$yorick_exe"`
    fi
  ;;
  *)
    save_IFS=$IFS
    IFS=:
    for d in `echo "$PATH" | sed -e 's/^:/.:/' -e 's/::/:.:/g' -e 's/:$/:./'`
    do
      if test -x "$d/$yorick_exe" -a ! -d "$d/$yorick_exe"; then
        Y_BINDIR="$d"
        yorick_exe="$d/$yorick_exe"
        break;
      fi
    done
    IFS=$save_IFS
  ;;
esac

"$yorick_exe" -batch make.i

Y_HOME=`grep '^Y_MAKEDIR=' ./Makefile | sed -e 's/^Y_MAKEDIR=//'`
# try to handle escaped blanks in Y_MAKEDIR
Y_HOME=`echo $Y_HOME | sed -e 's/\\\\ / /g'`

CC=`grep '^CC=' "${Y_HOME}/Make.cfg" | sed -e 's/^CC=//'`
CFLAGS=`grep '^Y_CFLAGS=' "${Y_HOME}/Make.cfg" | sed -e 's/^Y_CFLAGS=//'`
LDFLAGS=`grep '^Y_LDFLAGS=' "${Y_HOME}/Make.cfg" | sed -e 's/^Y_LDFLAGS=//'`
PLUG_UDL=`grep '^PLUG_UDL=-D' "${Y_HOME}/Make.cfg" | sed -e 's/^PLUG_UDL=-D//'`
if test "x$PLUG_UDL" = xPLUG_UNSUPPORTED; then
  PLUG_UDL=""
fi

if test -z "$PLUG_UDL"; then
  if test $av_dlopen = yes; then
    echo "WARNING: dlopen not supported by $yorick_exe"
  fi
  av_dlopen=no
  DEFAULT_TARGET='$(THIS_EXE)'
  DEFAULT_INSTALL=install-exe
  DEFAULT_CHECK=check-exe
  Y_PLUG=
else
  DEFAULT_TARGET='$(THIS_L)$(PLUG_SFX)'
  DEFAULT_INSTALL=install-plug
  DEFAULT_CHECK=check-plug
  Y_PLUG='$(PLUG_PIC)'
fi

echo Using ${Y_HOME}/Make.cfg
echo   CC=$CC
echo   CFLAGS=$CFLAGS
echo   LDFLAGS=$LDFLAGS

CFLAGS="$CFLAGS"
LDFLAGS="$LDFLAGS"

need_lm=no

# list of places to look for headers, libraries
plist="/sw /usr/local"

#------------------------------------------------------------------------
# find zlib header and library
cat >cfg.c <<EOF
#include "zlib.h"
int main(int argc, char *argv[])
{
  z_stream zs;
  int flag = deflateInit(&zs, Z_DEFAULT_COMPRESSION);
  unsigned char data[4], result[256];
  zs.next_in = data;
  zs.avail_in = 4;
  zs.next_out = result;
  zs.avail_out = 256;
  flag = deflate(&zs, Z_FINISH);
  deflateEnd(&zs);
  return 0;
}
EOF

# unless ZLIB_INC or ZLIB_LIB environment variables set, they will be blank
if test -n "$zlib_path"; then
  ZLIB_INC="-I$zlib_path"
  if test $use_a = "yes" -a -r "$zlib_path/libz.a"; then
    ZLIB_LIB="$zlib_path/libz.a"
  else
    ZLIB_LIB="-L$zlib_path -lz"
  fi
else
  ZLIB_LIB=-lz
fi
ZLIB_INC0="$ZLIB_INC"

found="no"
if $CC $CFLAGS $ZLIB_INC -o cfg cfg.c $ZLIB_LIB >cfg.0 2>&1; then
  found="yes"
else
  if test -n "$zlib_path"; then
    echo "WARNING: --zlib=$zlib_path DID NOT WORK, IS IT BUILT?"
  fi
  for p in $plist; do
    ZLIB_INC=-I$p/include
    ZLIB_LIB="-L$p/lib -lz"
    if $CC $CFLAGS $ZLIB_INC -o cfg cfg.c $ZLIB_LIB >cfg.1 2>&1; then
      found="yes"
      break
    fi
  done
fi
if test $found = no; then
  has_zlib=no
  echo "zlib: not found"
  ZLIB_INC=
  ZLIB_LIB=
  ILIST=
  OLIST=
else
  has_zlib=yes
  echo "zlib: found"
  echo "  ZLIB_INC=$ZLIB_INC"
  echo "  ZLIB_LIB=$ZLIB_LIB"
  ZLIB_INC0=$ZLIB_INC
  ILIST=zlib.i
  OLIST=yzlib.o
fi

#------------------------------------------------------------------------
# find png header and library
cat >cfg.c <<EOF
#include "png.h"
int main(int argc, char *argv[])
{
  png_structp p = png_create_read_struct_2(PNG_LIBPNG_VER_STRING,
      0, 0, 0, 0, 0, 0);
  png_infop pi = png_create_info_struct(p);
  png_destroy_read_struct(&p, &pi, 0);
  return 0;
}
EOF

# unless PNG_INC or PNG_LIB environment variables set, they will be blank
if test -n "$png_path"; then
  PNG_INC=-I$png_path
  if test $use_a = "yes" -a -r "$png_path/libpng.a"; then
    PNG_LIB="$png_path/libpng.a"
  else
    PNG_LIB="-L$png_path -lpng"
  fi
else
  PNG_LIB=-lpng
fi

libs="$PNG_LIB $ZLIB_LIB -lm"
found="no"
if $CC $CFLAGS $PNG_INC $ZLIB_INC0 -o cfg cfg.c $libs >cfg.2 2>&1; then
  found="yes"
else
  if test -n "$png_path"; then
    echo "WARNING: --png=$png_path DID NOT WORK, IS IT BUILT?"
  fi
  for p in $plist; do
    PNG_INC=-I$p/include
    PNG_LIB="-L$p/lib -lpng"
    libs="$PNG_LIB $ZLIB_LIB -lm"
    if $CC $CFLAGS $PNG_INC $ZLIB_INC0 -o cfg cfg.c $libs >cfg.3 2>&1; then
      found="yes"
      break
    fi
  done
fi
if test $found = no; then
  has_png=no
  echo "png: not found"
  PNG_INC=
  PNG_LIB=
else
  has_png=yes
  need_lm=yes
  echo "png: found"
  if test "$PNG_INC" != "$ZLIB_INC0"; then
    PNG_INC="$PNG_INC $ZLIB_INC0"
  fi
  echo "  PNG_INC=$PNG_INC"
  echo "  PNG_LIB=$PNG_LIB"
  ILIST="png.i $ILIST"
  OLIST="ypng.o spng.o $OLIST"
fi

#------------------------------------------------------------------------
# find jpeg header and library
cat >cfg.c <<EOF
#include <stdio.h>
#include "jpeglib.h"
int main(int argc, char *argv[])
{
  struct jpeg_decompress_struct jpeg;
  jpeg_create_decompress(&jpeg);
  jpeg_stdio_src(&jpeg, 0);
  jpeg_destroy_decompress(&jpeg);
  return 0;
}
EOF

# unless JPEG_INC or JPEG_LIB environment variables set, they will be blank
if test -n "$jpeg_path"; then
  JPEG_INC=-I$jpeg_path
  if test $use_a = "yes" -a -r "$jpeg_path/libjpeg.a"; then
    JPEG_LIB="$jpeg_path/libjpeg.a"
  else
    JPEG_LIB="-L$jpeg_path -ljpeg"
  fi
else
  JPEG_LIB=-ljpeg
fi

libs="$JPEG_LIB"
found="no"
if $CC $CFLAGS $JPEG_INC -o cfg cfg.c $libs >cfg.4 2>&1; then
  found="yes"
else
  if test -n "$jpeg_path"; then
    echo "WARNING: --jpeg=$jpeg_path DID NOT WORK, IS IT BUILT?"
  fi
  for p in $plist; do
    JPEG_INC=-I$p/include
    JPEG_LIB="-L$p/lib -ljpeg"
    libs="$JPEG_LIB"
    if $CC $CFLAGS $JPEG_INC -o cfg cfg.c $libs >cfg.5 2>&1; then
      found="yes"
      break
    fi
  done
fi
if test $found = no; then
  has_jpeg=no
  echo "jpeg: not found"
  JPEG_INC=
  JPEG_LIB=
else
  has_jpeg=yes
  echo "jpeg: found"
  echo "  JPEG_INC=$JPEG_INC"
  echo "  JPEG_LIB=$JPEG_LIB"
  ILIST="jpeg.i $ILIST"
  OLIST="yjpeg.o $OLIST"
fi

#------------------------------------------------------------------------
if test $av_dlopen != skip; then

# find avcodec header and library
cat >cfg.c <<EOF
#include "avcodec.h"
int main(int argc, char *argv[])
{
  AVCodec *codec;
  AVCodecContext *c;
  avcodec_init();
  register_avcodec(&mpeg1video_encoder);
  codec = avcodec_find_encoder(CODEC_ID_MPEG1VIDEO);
  c = avcodec_alloc_context();
  avcodec_close(c);
  return 0;
}
EOF

# unless AVCODEC_INC or AVCODEC_LIB env variables set, they will be blank
if test -n "$av_path"; then
  AVCODEC_INC=-I$av_path
  if test $use_a = "yes" -a -r "$av_path/libavcodec.a"; then
    AVCODEC_LIB="$av_path/libavcodec.a"
  else
    AVCODEC_LIB="-L$av_path -lavcodec"
  fi
  av_dlopen=no
elif test -z "$AVCODEC_LIB"; then
  AVCODEC_LIB=-lavcodec
fi

libs="$AVCODEC_LIB -lm"
found="no"
if $CC $CFLAGS $AVCODEC_INC -o cfg cfg.c $libs >cfg.6 2>&1; then
  found="yes"
else
  if test -n "$av_path"; then
    echo "WARNING: --avcodec=$av_path DID NOT WORK, IS IT BUILT?"
  fi
  for p in $plist; do
    AVCODEC_INC=-I$p/include
    AVCODEC_LIB="-L$p/lib -lavcodec"
    libs="$AVCODEC_LIB -lm"
    if $CC $CFLAGS $AVCODEC_INC -o cfg cfg.c $libs >cfg.7 2>&1; then
      found="yes"
      break
    fi
  done
fi

if test $av_dlopen = yes; then
  has_avcodec=dlopen
  if test $found = no; then
    echo "avcodec: not found, will try dlopen at runtime"
  else
    echo "avcodec: found, but will try dlopen at runtime"
  fi
  AVCODEC_INC="-DYAVC_SHARED"
  AVCODEC_LIB=
  ILIST="mpeg.i $ILIST"
  OLIST="ympeg.o $OLIST"
elif test $found = no; then
  has_avcodec=no
  echo "avcodec: not found"
  AVCODEC_INC=
  AVCODEC_LIB=
else
  has_avcodec=yes
  need_lm=yes
  echo "avcodec: found"
  echo "  AVCODEC_INC=$AVCODEC_INC"
  echo "  AVCODEC_LIB=$AVCODEC_LIB"
  ILIST="mpeg.i $ILIST"
  OLIST="ympeg.o $OLIST"
fi

else
has_avcodec=no
fi
#----------------------------------------------------------------------

rm -f yorz.i
cat >yorz.i <<EOF
/*
 * yorz.i - generated by yorick-z configure script
 * autoloads for yorick-z package
 */

EOF

if test $has_zlib = yes; then
  cat >>yorz.i <<EOF
autoload, "zlib.i", z_deflate, z_inflate, z_flush, z_setdict, z_crc32;
EOF
fi

if test $has_png = yes; then
  DEPLIBS="$PNG_LIB $ZLIB_LIB"
  cat >>yorz.i <<EOF
autoload, "png.i", png2, png_read, png_write, png_scale, png_map, png_pcal;
EOF
elif test $has_zlib = yes; then
  DEPLIBS="$ZLIB_LIB"
else
  DEPLIBS=""
fi
if test $has_jpeg = yes; then
  DEPLIBS="$JPEG_LIB $DEPLIBS"
  cat >>yorz.i <<EOF
autoload, "jpeg.i", jpeg2, jpeg_read, jpeg_write;
EOF
fi
if test $has_avcodec = yes; then
  DEPLIBS="$AVCODEC_LIB $DEPLIBS"
  cat >>yorz.i <<EOF
autoload, "mpeg.i", mpeg_create, mpeg_write, mpeg_close, mpeg_movie;
EOF
fi
#if test $need_lm = yes; then
#  DEPLIBS="$DEPLIBS -lm"
#fi

cat >Makeyorz <<EOF
# Makeyorz configure results for yorick-z
# generated by yorick-z configure script on $curdate
# $cursystem

PKG_I=$ILIST
OBJS=$OLIST
PKG_DEPLIBS=$DEPLIBS
PKG_I_START=yorz.i

ZLIB_INC=$ZLIB_INC
PNG_INC=$PNG_INC
JPEG_INC=$JPEG_INC
AVCODEC_INC=$AVCODEC_INC

EOF

#----------------------------------------------------------------------
# clean up, issue warning if compiler gave fishy output
rm -f cfg cfg.c cfg.o cfg.i
if test $debug = yes; then
  for f in cfg.[0-9]; do
    if grep ... $f >/dev/null 2>&1; then   # or use test -s $f ?
      echo "WARNING - check compiler message in $f"
    else # remove empty files
      rm -f $f
    fi
  done
else
  rm -f cfg.[0-9]
fi

echo ""
echo "================ yorick-z configuration completed ================"
exit $fatality