#! /bin/sh -e # # COPYRIGHT # The gcobc program is in public domain. # If it breaks then you get to keep both pieces. # # This file emulates the GnuCOBOL cobc compiler to a limited degree. # For options that can be "mapped" (see migration-guide.1), it accepts # cobc options, changing them to the gcobol equivalents. Options not # recognized by the script are passed verbatim to gcobol, which will # reject them unless of course they are gcobol options. # # User-defined variables, and their defaults: # # Variable Default Effect # echo none If defined, echo the gcobol command # gcobcx none Produce verbose messages # gcobol ./gcobol Name of the gcobol binary # GCOBCUDF PREFIX/share/cobol/udf/ Location of UDFs to be prepended to input # # By default, this script includes all files in $GCOBCUDF. To defeat # that behavior, use GCOBCUDF=none. # # A list of supported options is produced with "gcobc -HELP". # ## Maintainer note. In modifying this file, the following may make ## your life easier: ## ## - To force the script to exit, either set exit_status to 1, or call ## the error function. ## - As handled options are added, add them to the HELP here-doc. ## - The compiler can produce only one kind of output. In this ## script, that's known by $mode. Options that affect the type of ## output set the mode variable. Everything else is appended to the ## opts variable. ## if [ "$COBCPY" ] then copydir="-I$COBCPY" fi if [ "$COB_COPY_DIR" ] then copydir="-I$COB_COPY_DIR" fi # TODO: this file likely needs to query gcobol for its shared path instead udf_default="${0%/*}/../share/gcobol/udf" if [ ! -d "$udfdir" ] then # the one above is the installed one from the packages this one was previously used udf_default="${0%/*}/../share/cobol/udf" fi udfdir="${GCOBCUDF:-$udf_default}" if [ -d "$udfdir" ] then for F in "$udfdir"/* do if [ -f "$F" ] then includes="$includes -include $F " fi done else if [ "${GCOBCUDF:-none}" != "none" ] then echo warning: no such directory: "'$GCOBCUDF'" fi fi exit_status=0 skip_arg= opts="$copydir ${dialect:--dialect mf} $includes" mode=-shared incomparable="has no comparable gcobol option" if [ "${gcobcx:-0}" -gt 1 ] then set -x fi error() { echo "error: $1" >&2 exit_status=1 } warn() { echo "warning: $1 ignored" >&2 } ignore_arg() { warn "$1" skip_arg="$1" } no_warn() { :; } # silence is golden help() { cat<