Skip to content
This repository
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

executable file 525 lines (477 sloc) 18.996 kb
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
#!/bin/sh
### Copyright 1997 A. Kind & University of Bath
### Copyright 2010-2011 Henry G. Weller
###-----------------------------------------------------------------------------
## This file is part of
### --- EuLisp System 'Youtoo'
###-----------------------------------------------------------------------------
##
## Youtoo is free software: you can redistribute it and/or modify it under the
## terms of the GNU General Public License version 2 as published by the Free
## Software Foundation.
##
## Youtoo is distributed in the hope that it will be useful, but WITHOUT ANY
## WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
## FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
## details.
##
## You should have received a copy of the GNU General Public License along with
## this program. If not, see <http://www.gnu.org/licenses/>.
##
###-----------------------------------------------------------------------------
### Options:
## The system archicecture may be specified as an argument
## which overrides the default
### Description:
## To use a pre-installed version of the Boehm memory management system
## for Youtoo set U2_GC_DIR to the appropriate directory.
##
## Give an empty gabage collector directory if you don't want to use the
## garbage collector at all. This is not recommended as you will have
## performace drawbacks.
##
## Set CC if you prefer a particular C compiler.
##
## See the relevant section in this file for information about using an
## external thread library (e.g. Solaris threads).
###-----------------------------------------------------------------------------

###-----------------------------------------------------------------------------
### Set platform and architecture
###-----------------------------------------------------------------------------
OSTYPE=`uname -s`

# Check for the command-line architecture option
if [ $# = 1 ]
then
ARCH=$1
else
ARCH=`uname -m`
fi

###-----------------------------------------------------------------------------
### Set version, default current installation, bootstrapping installation
## and GC installation directories
###-----------------------------------------------------------------------------
EUL_VERSION=pre-0.991

EUL_DIR=`pwd`
EUL_BOOT_DIR=${EUL_DIR}.boot

###-----------------------------------------------------------------------------
### Set GC installation directory for Youtoo
###-----------------------------------------------------------------------------
U2_GC_DIR=/usr/local

###-----------------------------------------------------------------------------
### C compiler
## leave blank to selected automatically
###-----------------------------------------------------------------------------
CC=

###-----------------------------------------------------------------------------
### Emacs org-mode used to generate README.html files.
##
## Any version including org-mode will work but newer is better.
## eemacs is the version used here which includes a more recent
## org-mode than released with emacs.
###-----------------------------------------------------------------------------
EMACS=eemacs

###-----------------------------------------------------------------------------
### Specify the default shell and where to find mv and rm
###-----------------------------------------------------------------------------
EUL_SHELL=/bin/sh

###-----------------------------------------------------------------------------
### Foreign thread library
## If you want to base the EuLisp multi-threading support on a foreign
## thread library (e.g. PPCR threads, UI alias Solaris threads or POSIX MIT
## threads), set THRTYPE to one of:
##
## UI (UNIX International alias Solaris Threads)
## PPCR (POSIX Portable Common Runtime)
## MIT (MIT Pthread Library)
###-----------------------------------------------------------------------------
THRTYPE=DEFAULT
#THRTYPE=UI
#THRTYPE=PPCR
#THRTYPE=MIT
#EUL_MIT_THR_DIR=

###-----------------------------------------------------------------------------
### Set paths for binaries, scripts and libraries
###-----------------------------------------------------------------------------
EUL_BIN_DIR=$EUL_DIR/Bin.$ARCH
EUL_LIB_DIR=$EUL_DIR/Lib.$ARCH

###-----------------------------------------------------------------------------
### Set paths to the bootstrapping installation
## EUL_BOOT_DIR can be set to EUL_DIR which will use the current local build
## and over-write it during the build
###-----------------------------------------------------------------------------
EUL_BOOT_BIN_DIR=$EUL_BOOT_DIR/Bin.$ARCH

###-----------------------------------------------------------------------------
### Set path for Youtoo and Youtoo specefic build files
###-----------------------------------------------------------------------------
U2_DIR=$EUL_DIR/Youtoo
U2_C_DIR=u2

###-----------------------------------------------------------------------------
### Verify the some settings
###-----------------------------------------------------------------------------
FOO=$EUL_VERSION
touch ./$FOO
if [ ! -f ${EUL_DIR}/${FOO} ]
then
echo "*** ERROR [configure]: bad EUL_DIR directory: " ${EUL_DIR}
    rm ./$FOO
    exit
fi
rm ./$FOO

if [ ! -z "$U2_GC_DIR" ]
then
if [ ! -d $U2_GC_DIR ]
    then
echo "*** ERROR [configure]: bad U2_GC_DIR directory: " $U2_GC_DIR
    fi
fi

U2_GC_INCLUDE="-I${U2_GC_DIR} -I${U2_GC_DIR}/include"

###-----------------------------------------------------------------------------
### Set CC if currently unset
###-----------------------------------------------------------------------------
if [ -z "$CC" ]
then
gcc_path=`which gcc 2>/dev/null`
    gcc=`basename "${gcc_path}"`

    if [ "$gcc" = gcc ]
    then
CC=gcc
        U2_CFLAGS="-std=gnu99 -Wall -Wno-sequence-point -fPIC -O2 -fno-strict-aliasing"
        EUXL_CFLAGS="-std=gnu99 -Wall -O2 -fpic -Wl,--export-dynamic"
    else
CC=cc
        U2_CFLAGS=
    fi
fi

###-----------------------------------------------------------------------------
### Set basic flags and libraries
###-----------------------------------------------------------------------------
U2_CFLAGS="$U2_CFLAGS -I${U2_DIR}/include -I${U2_DIR}/Vm"
U2_LIBS="-lmain -leval -lmath -llevel-0 -llevel-1 -leval -ltelos -lboot -leulvm -lm"
EUXL_LIBS="-ldl -lm"

###-----------------------------------------------------------------------------
### Readline library (optional)
###-----------------------------------------------------------------------------
U2_CFLAGS="$U2_CFLAGS -DREADLINE"
U2_LIBS="$U2_LIBS -lreadline"
EUXL_CFLAGS="$EUXL_CFLAGS -DREADLINE"
EUXL_LIBS="$EUXL_LIBS -lreadline"

###-----------------------------------------------------------------------------
### Tcl/Tk libraries
###-----------------------------------------------------------------------------
EUL_TK_VERSION=8.5
EUL_TK_FLAGS=

###-----------------------------------------------------------------------------
### System-specific settings
###-----------------------------------------------------------------------------

###-----------------------------------------------------------------------------
### Linux
###-----------------------------------------------------------------------------
case $OSTYPE in
Linux)
    if [ $ARCH = x86_64 ]
    then
WORD_LENGTH=64
    elif [ $ARCH = i686 ]
    then
WORD_LENGTH=32
    else
echo "*** ERROR [configure]: unknown $OSTYPE system type $ARCH" >&2
        exit
fi

CC="gcc"
    AR="ar cruv"
    RANLIB="ranlib"
    U2_CFLAGS="$U2_CFLAGS -m$WORD_LENGTH"
    EUXL_CFLAGS="$EUXL_CFLAGS -m$WORD_LENGTH"

    if [ $THRTYPE = PPCR ]
    then
U2_CFLAGS="$U2_CFLAGS -DWITH_PCR_TREADS -I${U2_GC_DIR}/posix -I${U2_GC_DIR} -I${U2_GC_DIR}/include -I${U2_GC_DIR}/gc"
    else
U2_CFLAGS="$U2_CFLAGS ${U2_GC_INCLUDE}"
        U2_LIBS="$U2_LIBS -lpthread"
    fi
    ;;

###-----------------------------------------------------------------------------
### FreeBSD
###-----------------------------------------------------------------------------
FreeBSD)
    if [ $ARCH = x86_64 ]
    then
WORD_LENGTH=64
    elif [ $ARCH = i686 ]
    then
WORD_LENGTH=32
    else
echo "*** ERROR [configure]: unknown $OSTYPE system type $ARCH" >&2
        exit
fi

CC="gcc"
    AR="ar cruv"
    RANLIB="ranlib"
    U2_CFLAGS="$U2_CFLAGS -m$WORD_LENGTH"

    if [ $THRTYPE = PPCR ]
    then
U2_CFLAGS="$U2_CFLAGS -DWITH_PCR_TREADS -I${U2_GC_DIR}/posix -I${U2_GC_DIR} -I${U2_GC_DIR}/gc"
    else
U2_CFLAGS="$U2_CFLAGS ${U2_GC_INCLUDE}"
    fi
    ;;

###-----------------------------------------------------------------------------
### SunOS (Solaris)
###-----------------------------------------------------------------------------
SunOS)
    WORD_LENGTH=64
    if [ $THRTYPE = UI ]
    then
CC="cc"
        U2_CFLAGS="$U2_CFLAGS -DWITH_STRERROR -DWITH_UI_THREADS ${U2_GC_INCLUDE}"
        U2_LIBS="$U2_LIBS -lnls -lnsl -lsocket -ldl -lthread"
        AR="ar crsuv"
        RANLIB="echo No ranlib "
    elif [ $CC = gcc ]
    then
U2_CFLAGS="$U2_CFLAGS -fPIC -DWITH_STRERROR ${U2_GC_INCLUDE}"
        U2_LIBS="$U2_LIBS -lnls -lnsl -lsocket"
        AR="ar crsuv"
        RANLIB="echo No ranlib "
    else
U2_CFLAGS="$U2_CFLAGS -DWITH_STRERROR ${U2_GC_INCLUDE}"
        U2_LIBS="$U2_LIBS -lnls -lnsl -lsocket"
        AR="ar crsuv"
        RANLIB="echo No ranlib "
    fi
    ;;

###-----------------------------------------------------------------------------
### IRIX
###-----------------------------------------------------------------------------
IRIX)
    WORD_LENGTH=64
    if [ $THRTYPE = PPCR ]
    then
CC="cc"
        U2_CFLAGS="$U2_CFLAGS -Olimit 4000 -common -DWITH_PCR_THREADS -I${U2_GC_DIR}/posix -I${U2_GC_DIR}/gc"
        AR="ar crsuv"
        RANLIB="echo No ranlib "
    elif [ $THRTYPE = MIT ]
    then
CC="gcc"
        U2_CFLAGS="$U2_CFLAGS -DMIT_PTHREADS -I${U2_GC_DIR} -I${U2_GC_DIR}/include -I${EUL_MIT_THR_DIR}/include -L${EUL_MIT_THR_DIR}/obj"
        U2_LIBS="-lpthread $U2_LIBS -lgcc -lpthread"
        AR="ar crsuv"
        RANLIB="echo No ranlib "
    elif [ $CC = gcc ]
    then
U2_CFLAGS="$U2_CFLAGS ${U2_GC_INCLUDE}"
        AR="ar crsuv"
        RANLIB="echo No ranlib "
    else
U2_CFLAGS="$U2_CFLAGS -Olimit 4000 -common ${U2_GC_INCLUDE}"
        AR="ar crsuv"
        RANLIB="echo No ranlib "
    fi
    ;;

###-----------------------------------------------------------------------------
### IBM AIX
###-----------------------------------------------------------------------------
AIX)
    WORD_LENGTH=64
    U2_CFLAGS="$U2_CFLAGS ${U2_GC_INCLUDE} -DWITH_STRERROR"
    AR="ar cruv"
    RANLIB="ranlib"
    EUXL_CFLAGS="-D_ALL_SOURCE -DSOCK"
    EUXL_LIBS="-lm"
    ;;

###-----------------------------------------------------------------------------
### Unknown
###-----------------------------------------------------------------------------
*) # an unsupported operating system
    echo "*** ERROR [configure]: unknown system type $OSTYPE" >&2
    exit
    ;;
esac

###-----------------------------------------------------------------------------
### Youtoo directory and architecture CFLAGS
###-----------------------------------------------------------------------------
EUL_DIR_OP=-DEUL_DIR='\"'$EUL_DIR'\"'
EUL_ARCH_OP=-DEUL_ARCH='\"'$ARCH'\"'

###-----------------------------------------------------------------------------
### Set word-length option
###-----------------------------------------------------------------------------
WORD_LEN_OP=-DWORD_LENGTH=$WORD_LENGTH

###-----------------------------------------------------------------------------
### Make scripts executable
###-----------------------------------------------------------------------------
chmod ug+x ${U2_DIR}/Tools/make*.*

###-----------------------------------------------------------------------------
### Printing configuration of Youtoo
###-----------------------------------------------------------------------------
echo "CONFIGURING Youtoo ..."
echo " Dir: $EUL_DIR/Youtoo"
echo " Architecture: $ARCH"
echo " System: $OSTYPE"
echo " Compiler: $CC"
echo " Compiler flags: $U2_CFLAGS"
echo " Libraries: $U2_LIBS"
echo " Archive: $AR"
echo " Ranlib: $RANLIB"
echo " Threads: $THRTYPE"

###-----------------------------------------------------------------------------
### Printing configuration of EuXLisp
###-----------------------------------------------------------------------------
echo "CONFIGURING EuXLisp ..."
echo " Dir: $EUL_DIR/EuXLisp"
echo " Architecture: $ARCH"
echo " System: $OSTYPE"
echo " Compiler: $CC"
echo " Compiler flags: $EUXL_CFLAGS"
echo " Libraries: $EUXL_LIBS"

###-----------------------------------------------------------------------------
### Create Lib and Bin directory
###-----------------------------------------------------------------------------
if [ ! -d $EUL_LIB_DIR ]
then
mkdir $EUL_LIB_DIR
fi

if [ ! -d $EUL_BIN_DIR ]
then
mkdir $EUL_BIN_DIR
fi

###-----------------------------------------------------------------------------
### Create resource file
###-----------------------------------------------------------------------------
name_rc=${EUL_DIR}/.eulrc.${ARCH}
echo "WRITING CONFIGURATION ..."
echo " Creating ${EUL_DIR}/.eulrc.${ARCH} ..."
echo ";;; Copyright 1997 A. Kind & University of Bath" > $name_rc
echo ";;; Copyright 2010 Henry G. Weller" >> $name_rc
echo ";;;-----------------------------------------------------------------------------" >> $name_rc
echo ";; This file is part of" >> $name_rc
echo ";;; --- EuLisp System 'Youtoo'" >> $name_rc
echo ";;;-----------------------------------------------------------------------------" >> $name_rc
echo >> $name_rc
echo \( >> $name_rc
echo \(CC \. \"${CC}\"\) >> $name_rc
echo \(CFLAGS \. \"${WORD_LEN_OP} ${U2_CFLAGS} \"\) >> $name_rc
echo \(CLIBS \. \"${U2_LIBS}\"\) >> $name_rc
echo \(AR \. \"${AR}\"\) >> $name_rc
echo \(RANLIB \. \"${RANLIB}\"\) >> $name_rc
echo \(ARCH \. \"${ARCH}\"\) >> $name_rc
echo \(U2_C_DIR \. \"${U2_C_DIR}\"\) >> $name_rc
echo \(OSTYPE \. \"${OSTYPE}\"\) >> $name_rc
echo \(VERSION \. \"${EUL_VERSION}\"\) >> $name_rc
echo \) >> $name_rc

###-----------------------------------------------------------------------------
### Create Makefile header
###-----------------------------------------------------------------------------
name=${EUL_LIB_DIR}/Makefile
echo " Creating ${EUL_LIB_DIR}/Makefile ..."
echo "### Copyright 1997 A. Kind & University of Bath" > $name
echo "### Copyright 2010 Henry G. Weller" >> $name
echo "###-----------------------------------------------------------------------------" >> $name
echo "## This file is part of" >> $name
echo "### --- EuLisp System 'Youtoo'" >> $name
echo "###-----------------------------------------------------------------------------" >> $name
echo >> $name
echo CC = ${CC} >> $name
echo "CFLAGS = ${U2_CFLAGS} ${WORD_LEN_OP} ${EUL_DIR_OP} ${EUL_ARCH_OP}" >> $name
echo "EUXL_CFLAGS = ${EUXL_CFLAGS} ${WORD_LEN_OP}" >> $name
echo 'ARCH_DIR = platforms/$(ARCH)' >> $name
echo '.PRECIOUS: %/.' >> $name
echo '%/.:' >> $name
echo ' mkdir -p $(@)' >> $name
echo '# Reset the default goal.' >> $name
echo '.DEFAULT_GOAL :=' >> $name
echo '$(ARCH_DIR)/%.o : %.c | $(ARCH_DIR)/.' >> $name
echo ' mkdir -p $(@D)' >> $name
echo ' $(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@' >> $name
echo U2_LIBS = ${U2_LIBS} >> $name
echo "EUXL_LIBS = ${EUXL_LIBS}" >> $name
echo AR = ${AR} >> $name
echo RANLIB = ${RANLIB} >> $name
echo ARCH = ${ARCH} >> $name
echo OSTYPE = ${OSTYPE} >> $name
echo WORD_LENGTH = ${WORD_LENGTH} >> $name
echo EUL_VERSION = ${EUL_VERSION} >> $name
echo EUL_DIR = ${EUL_DIR} >> $name
echo EUL_BOOT_DIR = ${EUL_BOOT_DIR} >> $name
echo EUL_BIN_DIR = ${EUL_BIN_DIR} >> $name
echo EUL_LIB_DIR = ${EUL_LIB_DIR} >> $name
echo U2_DIR = ${EUL_DIR}/Youtoo >> $name
echo U2 = ${EUL_BIN_DIR}/youtoo >> $name
echo U2_BOOT = ${EUL_BOOT_BIN_DIR}/youtoo.sh >> $name
echo U2_C_DIR = ${U2_C_DIR} >> $name
echo U2_GC_DIR = ${U2_GC_DIR} >> $name
echo U2_GC_CFLAGS = ${U2_GC_CFLAGS} >> $name
echo EUL_TK_VERSION = ${EUL_TK_VERSION} >> $name
echo EUL_TK_FLAGS = ${EUL_TK_FLAGS} >> $name
echo >> $name
echo '.SUFFIXES: .org .html' >> $name
echo '.org.html:' >> $name
echo ' '${EMACS}' $< --batch --eval "(org-export-as-html t)"' >> $name
echo >> $name
echo "###---------------------------------------------------------------------" >> $name
echo "### Functions" >> $name
echo "###---------------------------------------------------------------------" >> $name
echo >> $name
echo 'makeAll = +$(foreach dir, $(1), $(MAKE) -C $(dir) $(2);)' >> $name
echo >> $name

###-----------------------------------------------------------------------------
### Create link to GC library (if available)
###-----------------------------------------------------------------------------
if [ -f $EUL_LIB_DIR/libgc.a ]
then
rm -f $EUL_LIB_DIR/libgc.a
fi
if [ -f $EUL_LIB_DIR/libgc.so ]
then
rm -f $EUL_LIB_DIR/libgc.so
fi
if [ -f Vm/gc.h ]
then
rm -f Vm/gc.h
fi

if [ ! -z "${U2_GC_DIR}" ]
then
if [ $THRTYPE = PPCR ]
    then
ln -s ${U2_GC_DIR}/base/libpcr.a $EUL_LIB_DIR/libgc.a
    elif [ -f ${U2_GC_DIR}/gc.a ]
    then
ln -s ${U2_GC_DIR}/gc.a $EUL_LIB_DIR/libgc.a
    fi
else
touch Vm/gc.h
    echo "No GC."
fi

###-----------------------------------------------------------------------------
### Create youtoo scheme and check scripts
###-----------------------------------------------------------------------------
create_script(){
    name=${EUL_BIN_DIR}/$1.sh
    echo " Creating $name ..."
    echo "#!$EUL_SHELL" > $name
    echo "###---------------------------------------------------------------------" >> $name
    echo "### EuLisp System 'youtoo'" >> $name
    echo "###---------------------------------------------------------------------" >> $name
    echo "### Description: shell script to run the system" >> $name
    echo "###---------------------------------------------------------------------" >> $name
    echo >> $name
    echo export EUL_DIR=${EUL_DIR} >> $name
    echo export EUL_ARCH=${ARCH} >> $name
    echo >> $name
    cat ${U2_DIR}/Tools/$1.skl >> $name
    chmod ug+x $name
}

create_script youtoo
create_script you2tk

###-----------------------------------------------------------------------------
### Create script to set LD_LIBRARY_PATH
###-----------------------------------------------------------------------------
name=${EUL_BIN_DIR}/makeso.Path
echo " Creating makeso.Path ..."
echo > $name
echo "LD_LIBRARY_PATH=$EUL_LIB_DIR:\${LD_LIBRARY_PATH}" >> $name
echo "export LD_LIBRARY_PATH" >> $name
chmod ug+x $name

echo "DONE"

###-----------------------------------------------------------------------------
Something went wrong with that request. Please try again.