#!/bin/sh # # p7c.in for Parenthetcl # # Copyright (c) 2004-2006 Henry Strickland # # Permission is hereby granted, free of charge, to any person obtaining a # copy of this software and associated documentation files (the "Software"), # to deal in the Software without restriction, including without limitation # the rights to use, copy, modify, merge, publish, distribute, sublicense, # and/or sell copies of the Software, and to permit persons to whom the # Software is furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included # in all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR # OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, # ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR # OTHER DEALINGS IN THE SOFTWARE. # # (* http://www.opensource.org/licenses/mit-license.php *) P7ROOT=${P7ROOT:-@PREFIX@} P7LIB=${P7LIB:-$P7ROOT/lib} P7INCLUDE=${P7INCLUDE:-$P7ROOT/include} P7TCLROOT=${TCLSH:-@TCLROOT@} P7TCLSH=${TCLSH:-@TCLSH@} P7CC=${CC:-@CC@} TIMEFORMAT=${TIMEFORMAT:- %R seconds} Usage ( ) { echo "Usage: $0 [-g] sourcefile.p7 [-g] [-O2] [other_cc_options...]" >&2 exit 1 } case $# in 0 ) Usage ;; esac # as an alternative to initial -g, you can also have P7DEBUG=1 in your environment: case "$1" in -g ) P7DEBUG=1 shift ;; -* ) Usage ;; esac # first argument (after optional -g) must be source *.p7 filename case "$1" in *.p7 ) SRC="$1" shift ;; * ) Usage ;; esac # remaining arguments are passed directly to C compiler (as "$@") B=`basename $SRC .p7` if [ ! -z "$P7DEBUG" ] then # debug version echo "+ $P7TCLSH $P7LIB/p7translate.tcl -g $SRC > ___${B}_g.c" >&2 time $P7TCLSH $P7LIB/p7translate.tcl -g $SRC > ___${B}_g.c || { E=$? ; echo Translation Failed >&2 ; exit $E ; } echo "+ $P7CC -shared -g -D'DEBUG' "$@" -I $P7TCLROOT/include -I $P7INCLUDE $P7EXTRACFLAGS -o ${B}_g.so ___${B}_g.c $P7LIB/libp7tcl_g.a" >&2 time $P7CC -shared -g -D'DEBUG' "$@" -I $P7TCLROOT/include -I $P7INCLUDE $P7EXTRACFLAGS -o ${B}_g.so ___${B}_g.c $P7LIB/libp7tcl_g.a || { E=$? ; echo Compilation Failed >&2 ; exit $E ; } else # normal version echo "+ $P7TCLSH $P7LIB/p7translate.tcl $SRC > ___$B.c" >&2 time $P7TCLSH $P7LIB/p7translate.tcl $SRC > ___$B.c || { E=$? ; echo Translation Failed >&2 ; exit $E ; } echo "+ $P7CC -shared "$@" -I $P7TCLROOT/include -I $P7INCLUDE $P7EXTRACFLAGS -o $B.so ___$B.c $P7LIB/libp7tcl.a" >&2 time $P7CC -shared "$@" -I $P7TCLROOT/include -I $P7INCLUDE $P7EXTRACFLAGS -o $B.so ___$B.c $P7LIB/libp7tcl.a || { E=$? ; echo Compilation Failed >&2 ; exit $E ; } fi