#! /bin/sh # @configure_input@ #---------------------------------------------------------------------------# # Copyright (C) 1995-1999 The University of Melbourne. # This file may only be copied under the terms of the GNU General # Public License - see the file COPYING in the Mercury distribution. #---------------------------------------------------------------------------# # # IMPORTANT: the manpage is produced automatically from this help # message, so if you change the help message, don't forget to check # that the manpage still looks OK. Help="\ Name: mgnuc - Mercury front-end to GNU C Usage: mgnuc [] [-- ] files... Options: -v, --verbose Echo gcc command before executing it. --no-ansi Don't pass \`-ansi' to gcc. --no-check Don't enable any of gcc's warnings. -s , --grade --asm-labels --gcc-non-local-gotos --gcc-global-registers --gc {conservative, accurate, none} -p, --profiling --profile-calls --profile-time --profile-memory --debug --low-level-debug -g, --c-debug --no-c-optimize --use-trail --pic-reg --inline-alloc --split-c-files See the documentation in the \"Invocation\" section of the Mercury User's Guide. Description: This runs gcc with the appropriate options for compiling Mercury programs. Normally it invokes gcc in ANSI mode with almost all warnings enabled, but this can be changed using the \`--no-ansi' or \`--no-check' options. Environment variables: MERCURY_C_INCL_DIR, MERCURY_ALL_C_INCL_DIRS, MERCURY_DEFAULT_GRADE. " # ************************************************************************* # *** IMPORTANT NOTE: any changes to this file may also require similar *** # *** changes to compiler/mercury_compile.m *** # ************************************************************************* FULLARCH=@FULLARCH@ NONSHARED_LIB_DIR=${MERCURY_NONSHARED_LIB_DIR=@NONSHARED_LIB_DIR@} MERC_C_INCL_DIR=${MERCURY_C_INCL_DIR=@LIBDIR@/inc} MERC_ALL_C_INCL_DIRS=${MERCURY_ALL_C_INCL_DIRS=-I$MERC_C_INCL_DIR} LOCAL_C_INCL_DIR=${MERCURY_LOCAL_C_INCL_DIR=/usr/local/include} ALL_LOCAL_C_INCL_DIRS=${MERCURY_ALL_LOCAL_C_INCL_DIRS=-I$LOCAL_C_INCL_DIR} DEFAULT_GRADE=${MERCURY_DEFAULT_GRADE=@DEFAULT_GRADE@} CC=${MERCURY_C_COMPILER="@CC@"} CFLAGS_FOR_REGS="@CFLAGS_FOR_REGS@" CFLAGS_FOR_GOTOS="@CFLAGS_FOR_GOTOS@" AS="@AS@" case "$CC" in *gcc*) ANSI_OPTS="-ansi" CHECK_OPTS=" -Wall -Wwrite-strings -Wpointer-arith -Wtraditional -Wshadow -Wstrict-prototypes -Wmissing-prototypes -Wno-unused" # Note: we do not enable the following gcc warnings: # -Wredundant-decls causes too many complaints in system header files # -Wconversion really only intended to help people using \`unprotoize' # -Waggregate-return not useful, IMHO # -Wcast-qual causes LOTS of redundant warnings # -Wcast-align causes redundant warnings in memory.c # -pedantic causes unsuppressable warnings about LVALUE_CAST() # -Wnested-externs causes unsuppressable warnings about callentry() # -Wid-clash-31 causes warnings about entry_mercury__xxx ... # -Wenum-clash is for C++ only # -Wunused causes various spurious warnings OPT_OPTS="-O2 -fomit-frame-pointer" COMPILER=gcc ;; *lcc*) ANSI_OPTS= CHECK_OPTS="-w" # turn off all warnings due to spurious warnings. OPT_OPTS="" COMPILER=lcc ;; *) ANSI_OPTS= CHECK_OPTS= OPT_OPTS="-O" COMPILER=unknown ;; esac AS_OPTS="" SPLIT_OPTS="" INLINE_ALLOC_OPTS="" verbose=false assemble=false c_debug=false c_optimize=true # include the file `init_grade_options.sh-subr' @INIT_GRADE_OPTIONS@ while : ; do case "$1" in -h|--help|"-?") echo "$Help" exit 0 ;; -v|--verbose) verbose=true ;; -v-|--no-verbose) verbose=false ;; --assemble) assemble=true ;; --no-ansi) ANSI_OPTS= DEFINE_OPTS="$DEFINE_OPTS -D__EXTENSIONS__" ;; --no-check) CHECK_OPTS= ;; --split-c-files) SPLIT_OPTS=-DSPLIT_C_FILES ;; --no-split-c-files) SPLIT_OPTS= ;; --inline-alloc) INLINE_ALLOC_OPTS="-DINLINE_ALLOC -DSILENT" ;; --no-inline-alloc) INLINE_ALLOC_OPTS="" ;; -g|--c-debug) c_debug=true ;; -g-|--no-c-debug) c_debug=false ;; --c-optimize) c_optimize=true ;; --no-c-optimize) c_optimize=false ;; --low-level-debug) low_level_debug=true ;; --no-low-level-debug) low_level_debug=false ;; # include the file `parse_grade_options.sh-subr' @PARSE_GRADE_OPTIONS@ --) shift break ;; *) break ;; esac shift done # include the file `final_grade_options.sh-subr' @FINAL_GRADE_OPTIONS@ # # convert mgnuc options into gcc options # # IMPORTANT: any changes here will require similar changes to # compiler/mercury_compile.m. # case $asm_labels in true) ASM_OPTS="-DUSE_ASM_LABELS" ;; false) ASM_OPTS="" ;; esac case $non_local_gotos in true) GOTO_OPTS="-DUSE_GCC_NONLOCAL_GOTOS" ;; false) GOTO_OPTS="" ;; esac case $global_regs in true) REG_OPTS="-DUSE_GCC_GLOBAL_REGISTERS" ;; false) REG_OPTS="" ;; esac case $stack_trace in true) STACK_TRACE_OPTS="-DMR_STACK_TRACE" ;; false) STACK_TRACE_OPTS="" ;; esac case $require_tracing in true) TRACE_OPTS="-DMR_REQUIRE_TRACING" ;; false) TRACE_OPTS="" ;; esac case $c_debug in true) C_DEBUG_OPTS="-g" ;; false) C_DEBUG_OPTS="" ;; esac case $c_optimize in true) ;; false) OPT_OPTS="" ;; esac case $low_level_debug in true) LLDEBUG_OPTS="-DMR_LOWLEVEL_DEBUG" ;; false) LLDEBUG_OPTS="" ;; esac case $gc_method in accurate) GC_OPTS="-DNATIVE_GC" ;; conservative) GC_OPTS="-DCONSERVATIVE_GC" ;; none) GC_OPTS="" ;; esac case $profile_time in true) PROF_TIME_OPTS="-DPROFILE_TIME" ;; false) PROF_TIME_OPTS="-DNO_SIGNALS" ;; esac case $profile_calls in true) PROF_CALLS_OPTS="-DPROFILE_CALLS" ;; false) PROF_CALLS_OPTS="" ;; esac case $profile_memory in true) PROF_MEMORY_OPTS="-DPROFILE_MEMORY" ;; false) PROF_MEMORY_OPTS="" ;; esac case $use_trail in true) TRAIL_OPTS="-DMR_USE_TRAIL" ;; false) TRAIL_OPTS="" ;; esac case $use_minimal_model in true) MINIMAL_MODEL_OPTS="-DMR_USE_MINIMAL_MODEL" ;; false) MINIMAL_MODEL_OPTS="" ;; esac case $thread_safe in true) case $FULLARCH in *solaris*) THREAD_OPTS="-DMR_THREAD_SAFE -DSOLARIS_THREADS \ -D_SOLARIS_PTHREADS -D_REENTRANT";; *linux*) THREAD_OPTS="-DMR_THREAD_SAFE -DLINUX_THREADS \ -D_THREAD_SAFE -D_REENTRANT";; *) THREAD_OPTS="" ;; esac ;; false) THREAD_OPTS="" ;; esac case $pic_reg in true) PICREG_OPTS="-DPIC_REG" ;; false) PICREG_OPTS="" ;; esac GRADE_OPTS="$ASM_OPTS $GOTO_OPTS $REG_OPTS" # check that special grades are only used with gcc case $COMPILER in gcc) ;; *) case "$GRADE_OPTS" in *USE_GCC*) echo "$0: For compilers other than GNU C, the only" 1>&2 echo "$0: base grade allowed is \`none'" 1>&2 ;; esac esac # if we're using global registers, add CFLAGS_FOR_REGS case $global_regs in true) GRADE_OPTS="$GRADE_OPTS $CFLAGS_FOR_REGS" ;; false) ;; esac # if we're using non-local gotos, add CFLAGS_FOR_GOTOS case $non_local_gotos in true) GRADE_OPTS="$GRADE_OPTS $CFLAGS_FOR_GOTOS" ;; false) ;; esac # # Special case hacks for particular architectures # Any code here needs to be duplicated in ../configure.in. # ARCH_OPTS="" case "$FULLARCH" in mips-sgi-irix5.*) # nonlocal gotos don't work with PIC, which is the # default for Irix 5, so if nonlocal gotos are enabled # we need to disable the use of shared libraries. case $non_local_gotos in true) LIBRARY_PATH="$NONSHARED_LIB_DIR:/usr/lib/nonshared:$LIBRARY_PATH" export LIBRARY_PATH AS_OPTS="-non_shared" ;; esac ;; i?86-*) # the use of stack_pointer in the ASM_JUMP macro # defined in runtime/goto.h causes lots of warnings # about using possibly uninitialized variables; # there's no easy way to supress them except by # disabling the warning. CHECK_OPTS="$CHECK_OPTS -Wno-uninitialized" ;; *-solaris*|*-sunos*) # The solaris headers for pthreads are not ANSI :-( case $thread_safe in true) ANSI_OPTS="" ;; esac ;; esac # # Kludge for gcc-2.6.3 bug on mips: if you use gcc global registers and -O2, # gcc 2.6.3 gets an internal error compiling library/int.c and # compiler/bytecode.c. As a work-around, we compile those file with -O1. # Similarly library/bag.c needs to be compiled with -O0. # Similarly for gcc-2.6.3 on alpha with compiler/modules.c. # Similarly for egcs-1.1 on sparc with library/lexer.c, library/string.c, # and compiler/{deforest,dupelim,mercury_to_mercury,modules}.c. # case $COMPILER in gcc) case "$FULLARCH" in mips*) case "$*" in *" int.c "*|*" int.dir/int_"*".c "*) case "`$CC --version 2>/dev/null`" in 2.6.*) ARCH_OPTS="$ARCH_OPTS -O1" ;; esac;; *" bytecode.c "*|*" bytecode.dir/bytecode_"*".c "*) case "`$CC --version 2>/dev/null`" in 2.6.*) ARCH_OPTS="$ARCH_OPTS -O1" ;; esac;; *" bag.c "*) case "`$CC --version 2>/dev/null`" in 2.6.*) ARCH_OPTS="$ARCH_OPTS -O0" ;; esac;; esac ;; alpha*) case "$*" in *" modules.c "*|*" modules.dir/modules_"*".c "*) case "`$CC --version 2>/dev/null`" in 2.6.*) ARCH_OPTS="$ARCH_OPTS -O1" ;; esac esac ;; i?86*) case "$*" in *" call_gen.c "*|*" modules.dir/call_gen"*".c "*) ARCH_OPTS="$ARCH_OPTS -O0" ;; esac ;; sparc*) case "$*" in *" lexer.c "*|*" modules.dir/lexer"*".c "*) ARCH_OPTS="$ARCH_OPTS -O1" ;; *" string.c "*|*" modules.dir/string"*".c "*) ARCH_OPTS="$ARCH_OPTS -O1" ;; *" deforest.c "*|*" modules.dir/deforest"*".c "*) ARCH_OPTS="$ARCH_OPTS -O1" ;; *" dupelim.c "*|*" modules.dir/dupelim"*".c "*) ARCH_OPTS="$ARCH_OPTS -O1" ;; *" mercury_to_mercury.c "*|*" modules.dir/mercury_to_mercury"*".c "*) ARCH_OPTS="$ARCH_OPTS -O1" ;; *" modules.c "*|*" modules.dir/modules"*".c "*) ARCH_OPTS="$ARCH_OPTS -O1" ;; esac esac ;; esac # # On sparc-sun-solaris2, we need to use -fPIC rather than -fpic if we're # using grade `none', because otherwise the Mercury standard library # overflows the fixed limit on the number of "small pic" references. # case "$FULLARCH" in sparc-sun-solaris2*) case "$grade" in none) case "$*" in *-fpic*) echo "mgnuc: using -fPIC rather than -fpic" OVERRIDE_OPTS="$OVERRIDE_OPTS -fPIC" ;; esac ;; esac ;; esac case $assemble in true) case $verbose in true) echo $AS $AS_OPTS "$@" ;; esac exec $AS $AS_OPTS "$@" ;; esac ALL_CC_OPTS="$MERC_ALL_C_INCL_DIRS $ANSI_OPTS $CHECK_OPTS $OPT_OPTS \ $GRADE_OPTS $GC_OPTS $DEFINE_OPTS \ $TRACE_OPTS $STACK_TRACE_OPTS $LLDEBUG_OPTS $C_DEBUG_OPTS \ $PROF_TIME_OPTS $PROF_CALLS_OPTS $PROF_MEMORY_OPTS \ $INLINE_ALLOC_OPTS $TRAIL_OPTS $MINIMAL_MODEL_OPTS \ $SPLIT_OPTS $THREAD_OPTS $PICREG_OPTS $ARCH_OPTS $ARG_OPTS" case $verbose in true) echo $CC $ALL_CC_OPTS "$@" $OVERRIDE_OPTS $ALL_LOCAL_C_INCL_DIRS;; esac case $# in 0) exec $CC $ALL_CC_OPTS $OVERRIDE_OPTS ;; *) exec $CC $ALL_CC_OPTS "$@" $OVERRIDE_OPTS $ALL_LOCAL_C_INCL_DIRS;; esac