aboutsummaryrefslogtreecommitdiff
path: root/skribe/etc/bigloo/configure
blob: 9215911073461ec9b07fce37159fba12e6023c6f (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
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
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
#!/bin/sh
#*=====================================================================*/
#*    serrano/prgm/project/skribe/etc/bigloo/configure                 */
#*    -------------------------------------------------------------    */
#*    Author      :  Manuel Serrano                                    */
#*    Creation    :  Tue Jan 25 16:05:10 1994                          */
#*    Last change :  Tue Aug 24 10:31:53 2004 (serrano)                */
#*    Copyright   :  1994-2004 Manuel Serrano, see LICENSE file        */
#*    -------------------------------------------------------------    */
#*    The skribe configuration file                                    */
#*=====================================================================*/

# the name of the current bigloo compiler
bigloo=bigloo
target=c

# bigloo compilation flags
bcommonflags="-no-hello -fno-reflection"
blinkflags="-no-hello -ld-relative -O3"
boptflags="$bcommonflags -O3"
bsafeflags="$bcommonflags -g"
bflags="$boptflags"
bheapflags="-unsafe -q -mkaddheap -mkaddlib"
bcflags="-copt \"$""(CPICFLAGS)\""
bjvmflags="-jvm -jvm-purify -saw -jvm-env SKRIBEPATH"
prcs=/usr/bin/prcs

# the afile, jfile and btags binaries
afile=afile
jfile=
btags=btags
bdepend=bdepend

# C compilation (left blank for automatic configuration (from Bigloo setup))
cc=
cflags=
ldopt=

# path (left blank for automatic configuration (from Bigloo setup))
bgllibdir=
bglbindir=
bgllddir=
bgldocdir=
skribebindir=
skribelibdir=
skribefildir=
skribeskrdir=
skribeextdir=
skribedocdir=
skribemandir=

# mask of Skribe intalled files
smask=755

#*---------------------------------------------------------------------*/
#*               !!! DON'T EDIT AFTER THIS COMMENT !!!                 */
#*---------------------------------------------------------------------*/
if [ "x$DISTRIBDIR" = "x" ]; then
  distribdir=$HOME/prgm/distrib
else
  distribdir=$DISTRIBDIR
fi

if [ "x$SKRIBERELEASE" = "x" ]; then
  echo "*** ERROR:configure:release. Aborting"
  echo "Variable \"SKRIBERELEASE\" is unset."
  exit 1;
else
  release=$SKRIBERELEASE
fi

if [ "x$SKRIBEBETARELEASE" = "x" ]; then
  if [ -f $prcs ]; then
     beta=`$prcs info skribe 2>&1 /dev/null | tail --lines=1 | awk '{ print $2 }' | sed 's/[0-9]*[.][0-9]*[a-z]*/&-beta/'`
  elif [ -f /usr/local/bin/prcs ]; then
     beta=`/usr/local/bin/prcs info skribe 2>&1 /dev/null | tail --lines=1 | awk '{ print $2 }' | sed 's/[0-9]*[.][0-9]*[a-z]*/&-beta/'`
  else
     beta=no
  fi
else
  beta=$SKRIBEBETARELEASE
fi

if [ "x$SKRIBEURL" = "x" ]; then
  skribeurl="http://www.inria.fr/mimosa/fp/Skribe"
else
  skribeurl=$SKRIBEURL
fi

requiredbigloo=2.6c

action=all
makefile_config=Makefile.skb
skribe_config=../../src/common/configure.scm
summary=yes

http="www-sop.inria.fr/mimosa/fp"
autoconfdir=`dirname $0 2> /dev/null`/autoconf
bootconfig=false;

if [ $? != "0" ]; then
   autoconfdir="autoconf"
fi

# Argument parsing
while : ; do
  case $1 in
    "")
      break;;

    -c)
      target=c;;

    -j|--jvm)
      target=jvm;;

    -|--dotnet)
      target=dotnet;;

    --skribe_config=*)
      action="skribe_config";
      skribe_config="`echo $1 | sed 's/^[-a-z_.]*=//'`";;

    --makefile.skb=*)
      action="makefile.skb";
      makefile_config="`echo $1 | sed 's/^[-Da-z.]*=//'`";;

    --bglbindir=*)
      bglbindir="`echo $1 | sed 's/^[-a-z]*=//'`";;

    --bgllibdir=*)
      bgllibdir="`echo $1 | sed 's/^[-a-z]*=//'`";;

    --bgllddir=*)
      bgllddir="`echo $1 | sed 's/^[-a-z]*=//'`";;

    --bgldocdir=*)
      bgldocdir="`echo $1 | sed 's/^[-a-z]*=//'`";;

    --bindir=*)
      skribebindir="`echo $1 | sed 's/^[-a-z]*=//'`";;

    --libdir=*)
      skribelibdir="`echo $1 | sed 's/^[-a-z]*=//'`";;

    --fildir=*)
      skribefildir="`echo $1 | sed 's/^[-a-z]*=//'`";;

    --skrdir=*)
      skribeskrdir="`echo $1 | sed 's/^[-a-z]*=//'`";;

    --extdir=*)
      skribeextdir="`echo $1 | sed 's/^[-a-z]*=//'`";;

    --docdir=*)
      skribedocdir="`echo $1 | sed 's/^[-a-z]*=//'`";;

    --mandir=*)
      skribemandir="`echo $1 | sed 's/^[-a-z]*=//'`";;

    --bigloo=*)
      bigloo="`echo $1 | sed 's/^[-a-z]*=//'`";;

    --afile=*)
      afile="`echo $1 | sed 's/^[-a-z]*=//'`";;

    --jfile=*)
      jfile="`echo $1 | sed 's/^[-a-z]*=//'`";;

    --btags=*)
      btags="`echo $1 | sed 's/^[-a-z]*=//'`";;

    --mask=*)
      smask="`echo $1 | sed 's/^[-a-z]*=//'`";;

    --cc=*)
      cc="`echo $1 | sed 's/^[-a-z]*=//'`";;

    --cflags=*)
      cflags="`echo $1 | sed 's/^[-a-z]*=//'`";;

    --ldopt=*)
      ldopt="`echo $1 | sed 's/^[-a-z]*=//'`";;

    --backends=*)
      backends="`echo $1 | sed 's/^[-a-z]*=//'`";;

    --no-summary)
      summary=no;;

    --debug)
      bflags="-g -cg $bsafeflags";;

    --debug2)
      bflags="-g2 -cg $bsafeflags";;

    --debug3)
      bflags="-g3 -cg $bsafeflags";;

    --optimize)
      bflags=$boptflags;;

    --bjvmflags=*)
      bjvmflags="`echo $1 | sed 's/^[-a-z]*=//'`";;

    --bcflags=*)
      bcflags="`echo $1 | sed 's/^[-a-z]*=//'`";;

    --prefix=*)
      prefix="`echo $1 | sed 's/^[^=]*=//'`";
      skribebindir=$prefix/bin;
      skribeskrdir=$prefix/share/skribe/$release/skr;
      skribeextdir=$prefix/share/skribe/extensions;
      skribelibdir=$prefix/lib
      skribefildir=$skribelibdir/skribe/$release;
      skribemandir=$prefix/man/man1;
      skribedocdir=$prefix/doc/skribe-$release;;

    --bootconfig)
      bootconfig=true;;

    -*)
      echo "*** Configure error, unknown option $1" >&2;
      echo >&2;
      echo "Usage: configure --with-bigloo [options]" >&2;
      echo "   -c.................... uses the Bigloo C back-end" >&2;
      echo "   -j|--jvm.............. uses the Bigloo JVM back-end" >&2;
      echo "   -d|--dotnet........... uses the Bigloo .NET back-end" >&2;
      echo "   --skribe_config=file.. sets the name of the skribe-config file" >&2;
      echo "   --makefile.skb=file... sets the name of the Makefile.skb file" >&2;
      echo "   --prefix=dir.......... prefix to Skribe install" >&2;
      echo "   --bindir=file......... alternative Skribe bin directory" >&2;
      echo "   --libdir=file......... alternative Skribe lib directory" >&2;
      echo "   --fildir=file......... alternative Skribe file directory" >&2;
      echo "   --skrdir=file......... Skribe skr directory" >&2;
      echo "   --bglbindir=file...... Bigloo bin directory" >&2;
      echo "   --bgllibdir=file...... Bigloo lib directory" >&2;
      echo "   --bglfildir=file...... Bigloo file directory" >&2;
      echo "   --bgldocdir=file...... Bigloo doc directory" >&2;
      echo "   --docdir=file......... Documentation directory" >&2;
      echo "   --mandir=file......... Manual pages directory" >&2;
      echo "   --bigloo=comp......... The Bigloo compiler" >&2;
      echo "   --afile=afile......... The Bigloo afile tool" >&2;
      echo "   --jfile=jfile......... The Bigloo jfile tool" >&2;
      echo "   --btags=btags......... The Bigloo btags tool" >&2;
      echo "   --cc=comp............. The C compiler (for C back-end)" >&2;
      echo "   --cflags=args......... The C compilation options" >&2;
      echo "   --ldopt=args.......... The C link options" >&2;
      echo "   --smask=mask.......... The installation mask" >&2;
      echo "   --no-summary.......... Private option" >&2;
      echo "   --debug............... Enables Bigloo debug mode" >&2;
      echo "   --optimize............ Enables Bigloo optimization mode (default)" >&2;
      echo "   --bootconfig.......... Private option" >&2;
      exit -1;
  esac
  shift
done

#*---------------------------------------------------------------------*/
#*    First check if bigloo exists and if it is recent enough          */
#*---------------------------------------------------------------------*/
if [ ! -f $bigloo ]; then
   which $bigloo > /dev/null 2> /dev/null
   if [ "$?" != "0" ]; then
      echo "*** ERROR:configure:bigloo. Aborting"
      echo "Can't find bigloo."
      exit 1;
   fi
fi

installedbigloo=`$autoconfdir/bversion --bigloo=$bigloo --version=$requiredbigloo`

if [ $? != "0" ]; then
  echo "*** ERROR:configure:bigloo. Aborting"
  echo "Your version ($installedbigloo) of Bigloo is too old."
  echo "Release $requiredbigloo or more recent is required."
  echo "Bigloo may be downloaded from $http"
  exit 1;
fi

#*---------------------------------------------------------------------*/
#*    The binary directory                                             */
#*---------------------------------------------------------------------*/
if [ "$bglbindir " = " " ]; then
   if [ "$bigloo " = " " ]; then
      bgl=`which bigloo`;
   else
      bgl=`which $bigloo`;
   fi
   bglbindir=`dirname $bgl`
fi
if [ "$skribebindir " = " " ]; then
   skribebindir=$prefix/bin;
fi

#*---------------------------------------------------------------------*/
#*    The Bigloo library directory                                     */
#*---------------------------------------------------------------------*/
if [ "$bgllibdir " = " " ]; then
   bgllibdir=`$autoconfdir/blibdir --bigloo="$bigloo"`
fi
if [ "$bglfildir " = " " ]; then
   bglfildir=`$autoconfdir/bfildir --bigloo="$bigloo"`
fi

#*---------------------------------------------------------------------*/
#*    We check the installed Bigloo Makefile.config file               */
#*---------------------------------------------------------------------*/
if [ ! -f $bglfildir/Makefile.config ]; then
   echo "*** ERROR:configure:Can't find Makefile.config file"
   echo "Should be $bglfildir/Makefile.config."
   exit 1;
fi

#*---------------------------------------------------------------------*/
#*    jfile                                                            */
#*---------------------------------------------------------------------*/
if [ "$jfile " = " " ]; then
   if [ ! -f $bigloo ]; then
      which jfile > /dev/null 2> /dev/null
      if [ "$?" != "0" ]; then
         jfile=true;
      else
         jfile=jfile;
      fi
   fi
fi

#*---------------------------------------------------------------------*/
#*    We are now able to set the correct value for cc since we know    */
#*    what Bigloo is.                                                  */
#*---------------------------------------------------------------------*/
if [ "$cc " = " " ]; then
  cc=`$bigloo -eval '(begin (print *cc*) (exit 0))'`
fi

if [ "$cflags " = " " ]; then
  cflags=`grep '^CFLAGS=' $bglfildir/Makefile.config | sed 's/^[A-Z]*=//'`
fi

ldflags=`grep '^EXTRALIBS=' $bglfildir/Makefile.config | sed 's/^[A-Z]*=//'`
cpicflags=`grep '^CPICFLAGS=' $bglfildir/Makefile.config | sed 's/^[A-Z]*=//'`

#*---------------------------------------------------------------------*/
#*    Completing dirs                                                  */
#*---------------------------------------------------------------------*/
if [ "$skribelibdir " = " " ]; then
   skribelibdir=$prefix/lib;
fi
if [ "$skribefildir " = " " ]; then
   skribefildir=$skribelibdir/skribe/$release;
fi
if [ "$skribeskrdir " = " " ]; then
   skribeskrdir=$prefix/share/skribe/$release/skr;
fi
if [ "$skribeextdir " = " " ]; then
   skribeextdir=$prefix/share/skribe/extensions;
fi
if [ "$bgldocdir " = " " ]; then
   bgldocdir=`grep '^DOCDIR=' $bglfildir/Makefile.config | sed 's/^[A-Z]*=//' | sed 's/[$][(][^)]*[)]//'`
fi
if [ "$skribedocdir " = " " ]; then
   skribedocdir=`dirname $bgldocdir`/skribe-$release
fi
if [ "$skribemandir " = " " ]; then
   skribemandir=`grep '^MANDIR=' $bglfildir/Makefile.config | sed 's/^[A-Z]*=//'`
fi
if [ "$skribeemacsdir " = " " ]; then
   skribeemacsdir=`grep '^EMACSDIR=' $bglfildir/Makefile.config | sed 's/^[A-Z]*=//'`
fi

#*---------------------------------------------------------------------*/
#*    emacs/skribe.el                                                  */
#*---------------------------------------------------------------------*/
cat ../../emacs/skribe.el \
    | sed "s|@SKRIBE_EMACSDIR@|$skribeemacsdir|" \
    | sed "s|@SKRIBE_HOSTSCHEMEDOCDIR@|$bgldocdir|" \
    > ../../emacs/skribe.el.aux \
    && mv ../../emacs/skribe.el.aux ../../emacs/skribe.el

#*---------------------------------------------------------------------*/
#*    etc/skribe-config                                                */
#*---------------------------------------------------------------------*/
cat ../skribe-config \
    | sed "s|@SKRIBE_EMACS_DIR@|$skribeemacsdir|" \
    > ../skribe-config.aux \
    && mv ../skribe-config.aux ../skribe-config

#*---------------------------------------------------------------------*/
#*    makefile.skb                                                     */
#*    -------------------------------------------------------------    */
#*    This part of the configure script produces the file              */
#*    makefile.skb. This file contains machine dependant               */
#*    informations and location where Bigloo is to be installed.       */
#*---------------------------------------------------------------------*/
if [ $action = "all" -o $action = "makefile.skb" ]; then

  # We create an unexisting temporary file name
  name=foo
  while( test -f "$name.c" -o -f "$name.o" ); do 
    name="$name"x;
  done

  # We check the C compiler
  cat > $name.c <<EOF
     int foobar( int x ) {
        return x;
  }
EOF

  if $cc $cflags -c $name.c >/dev/null 2>&1
  then
     true 
  else
     echo "***ERROR:configure:$cc:Can't compile c file -- $cc $cflags -c $name.c";
     /bin/rm -f $name.c $name.o $name.a; 
     exit 1
  fi
  /bin/rm -f $name.c $name.o $name.a; 

  # We first cleanup the general Makefile config
  rm -f ../Makefile.config 2> /dev/null
  echo "## Skribe ($release) configure" > ../Makefile.config
  echo "## Don't edit, file generated by etc/bigloo/configure" >> ../Makefile.config
  echo "SKRIBERELEASE=$release" >> ../Makefile.config
  echo "SKRIBEBETARELEASE=$beta" >> ../Makefile.config
  echo >> ../Makefile.config
  echo "SYSTEM=bigloo" >> ../Makefile.config
  case $target in
     jvm)
       echo 'SKRIBE=java -classpath $(BINDIR)/skribe.zip:$(ZIPDIR)/bigloo_s.zip:$(LIBDIR)/bigloo_s.zip bigloo.skribe.main' >> ../Makefile.config;
       echo 'SKRIBEINFO=java -classpath $(BINDIR)/skribeinfo.zip:$(ZIPDIR)/bigloo_s.zip:$(LIBDIR)/bigloo_s.zip bigloo.skribe.skribeinfo.main' >> ../Makefile.config;
       echo 'SKRIBEBIBTEX=java -classpath $(BINDIR)/skribebibtex.zip:$(ZIPDIR)/bigloo_s.zip:$(LIBDIR)/bigloo_s.zip bigloo.skribe.skribebibtex.main' >> ../Makefile.config;;
     *)
       echo 'SKRIBE=$'"(BINDIR)/skribe.bigloo" >> ../Makefile.config;
       echo 'SKRIBEINFO=$'"(BINDIR)/skribeinfo.bigloo" >> ../Makefile.config;
       echo 'SKRIBEBIBTEX=$'"(BINDIR)/skribebibtex.bigloo" >> ../Makefile.config;;
  esac

  # We first cleanup the file
  rm -f $makefile_config 2> /dev/null
  touch $makefile_config
  echo "## Skribe ($release) configure" >> $makefile_config
  echo "## Don't edit, file generated by etc/bigloo/configure" >> $makefile_config
  echo >> $makefile_config

  # The Bigloo target (c, jvm, dotnet)
  echo "TARGET=$target" >> $makefile_config
  echo >> $makefile_config

  # The boot directories
  echo "SKRIBEDIR=`pwd`/../.." >> $makefile_config
  echo 'SKRIBEBINDIR=$'"(SKRIBEDIR)/bin" >> $makefile_config;
  echo 'SKRIBELIBDIR=$'"(SKRIBEDIR)/lib" >> $makefile_config;
  echo 'SKRIBEFILDIR=$'"(SKRIBEDIR)/lib" >> $makefile_config;
  echo >> $makefile_config

  # The distribution directory
  echo "DISTRIBDIR=$distribdir" >> $makefile_config
  echo >> $makefile_config

  # The installation directories
  echo "INSTALL_BINDIR=$skribebindir" >> $makefile_config
  echo "INSTALL_LIBDIR=$skribelibdir" >> $makefile_config
  echo "INSTALL_FILDIR=$skribefildir" >> $makefile_config
  echo "INSTALL_SKRDIR=$skribeskrdir" >> $makefile_config
  echo "INSTALL_EXTDIR=$skribeextdir" >> $makefile_config
  if [ ! "$skribedocdir " = " " ]; then
    echo "INSTALL_DOCDIR=$skribedocdir" >> $makefile_config;
  fi
  if [ ! "$skribemandir " = " " ]; then
    echo "INSTALL_MANDIR=$skribemandir" >> $makefile_config;
  fi
  echo "INSTALL_HOSTHTTP=$skribehttphost" >> $makefile_config
  echo "INSTALL_MASK=$smask" >> $makefile_config
  echo >> $makefile_config
 
  # The bigloo configuration
  cat $bglfildir/Makefile.config >> $makefile_config
  echo >> $makefile_config

  # The bigloo compiler
  echo "BIGLOO=$bigloo" >> $makefile_config
  echo "BIGLOO_FILDIR=$bglfildir" >> $makefile_config
  echo "BIGLOO_LIBDIR=$bgllibdir" >> $makefile_config
  echo >> $makefile_config

  # The bigloo compiler options
  echo "BLINKFLAGS=$blinkflags -ldopt '$ldopt'" >> $makefile_config
  echo "BSAFEFLAGS=$bsafeflags" >> $makefile_config
  echo "BHEAPFLAGS=$bheapflags" >> $makefile_config
  echo "BCOMMONFLAGS=$bflags" >> $makefile_config
  echo "BCFLAGS=$bcflags" >> $makefile_config
  echo "BJVMFLAGS=$bjvmflags" >> $makefile_config
  echo >> $makefile_config

  # Bigloo bde
  echo "AFILE=$afile" >> $makefile_config
  echo "JFILE=$jfile" >> $makefile_config
  echo "BTAGS=$btags" >> $makefile_config
  echo "BDEPEND=$bdepend" >> $makefile_config
  echo "SKRIBEINDENT=bpp" >> $makefile_config
  echo >> $makefile_config

  # Misc
  echo "RM=/bin/rm" >> $makefile_config
  echo >> $makefile_config
fi

#*---------------------------------------------------------------------*/
#*    Ok, we are done now                                              */
#*---------------------------------------------------------------------*/
if [ "$summary" = "yes" ]; then
  echo 
  echo 
  echo "** Configuration summary **"
  echo 
  echo "Release number:"
  echo "  Skribe release number................. $release"
  echo "  Skribe beta number.................... $beta"
  echo "  Minimum Bigloo version required....... $requiredbigloo"
  echo "  Installed Bigloo version.............. $installedbigloo"
  echo
  echo "Compilers:"
  echo "  Bigloo................................ $bigloo"
  echo "  Bigloo link flags..................... $blinkflags"
  echo "  Bigloo compilation flags.............. $bflags"
  echo "  Bigloo heap flags..................... $bheapflags"
  echo "  afile................................. $afile"
  echo "  jfile................................. $jfile"
  echo "  btags................................. $btags"
  echo "  cc.................................... $cc"
  echo "  cc compilation flags.................. $cflags"
  echo "  link options.......................... $ldopt"
  echo 
  echo "Path:"
  echo "  Binary directory...................... $skribebindir"
  echo "  Skr directory......................... $skribeskrdir"
  echo "  Extensions directory.................. $skribeextdir"
  echo "  File directory........................ $skribefildir"
  echo "  Library directory..................... $skribelibdir"
  echo "  Documentation directory............... $skribedocdir"
  echo "  Man pages directory................... $skribemandir"
  echo "  Home page............................. $skribeurl"
  echo 
  echo "Misc configuration:"
  echo "  mask for installed files.............. $smask"
  echo 
  echo "Emacs:"
  echo "  Emacs Lisp files directory............ $skribeemacsdir"
  echo
fi