#! /bin/sh #:! line starting with #:! are removed from this melt-cc-script.proto #:! -*- bash -*- # Copyright (C) 2008 Free Software Foundation, Inc. # Contributed by Basile Starynkevitch # # This file :MELT_SCRIPT: is part of GCC. # # GCC is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3, or (at your option) # any later version. # # GCC 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 GCC; see the file COPYING3. If not see # . #:! :MELT_CC: & :MELT_CFLAGS: &:MELT_HEADERDIR: are substituted in the first 30 lines melt_cc=":MELT_CC:" melt_cflags=":MELT_CFLAGS:" melt_headerdir=":MELT_HEADERDIR:" if [ -n "$MELT_CC" ]; then melt_cc=$MELT_CC fi if [ -n "$MELT_EXTRACFLAGS" ]; then melt_cflags="$melt_cflags $MELT_EXTRACFLAGS" fi #set -x ## script invoked by cc1 with two arguments : the generated C source to compile ## and the naked (without suffix) dynamically-loadable stuff to generate ## for commodity, we pass -D -U -I to gcc, and -F to set the cflags, ## -C to set the compiler, and -x & -v for debugging and -n to omit ## line info, -d for dynamic object structures while getopts "D:I:U:F:C:xvnd" flag ; do : the $flag case "$flag" in D) melt_cflags="$melt_cflags -D$OPTARG";; U) melt_cflags="$melt_cflags -U$OPTARG";; I) melt_cflags="$melt_cflags -U$OPTARG";; F) melt_cflags="$melt_cflags $OPTARG";; C) melt_cc="$OPTARG";; n) melt_cflags="$melt_cflags -DMELTGCC_NOLINENUMBERING";; d) melt_cflags="$melt_cflags -DMELTGCC_DYNAMIC_OBJSTRUCT";; x) set -x;; v) set -v;; *) echo unrecognized flag $flag;; esac done shift `expr $OPTIND - 1` csource=$1 dynstuff=$2 case $dynstuff in *.so) nakedynstuff=`basename $dynstuff .so`;; *.sl) nakedynstuff=`basename $dynstuff .sl`;; *.la) nakedynstuff=`basename $dynstuff .la`;; *.lo) nakedynstuff=`basename $dynstuff .lo`;; *.shlib) nakedynstuff=`basename $dynstuff .shlib`;; *.dylib) nakedynstuff=`basename $dynstuff .dylib`;; *) nakedynstuff=`echo $dynstuff | sed 's/\.[a-z]*$//'`;; esac : ${TMPDIR=/tmp} if which tempfile > /dev/null; then datf=`tempfile -p bdat` elif which mktemp > /dev/null; then datf=`mktemp -t bdat.XXXXXXXX` else datf=$TMPDIR/bdat$$-$RANDOM fi rm -f $datf $datf.c $datf.* pwd echo melt_cc= $melt_cc melt_cflags= $melt_cflags melt_headerdir= $melt_headerdir csource= $csource nakedynstuff= $nakedynstuff datf= $datf # generate the temporary timestamp & md5s file md5src=`md5sum $csource` trap "rm -f $datf.* $datf" EXIT date "+const char basilys_compiled_timestamp[]=\"%c $csource\";" > $datf.c echo "const char basilys_md5[]=\"$md5src\";" >> $datf.c head $datf.c case `uname` in Linux|SunOS|Solaris) # we have temporarily a build of foo-n.so from foo.c without linenumbering # echo Compiling $csource without line numbering # time $melt_cc -Wall -fPIC -shared $melt_cflags -DMELTGCC_NOLINENUMBERING -I "$melt_headerdir" $csource $datf.c -o $nakedynstuff-n.so # echo echo echo Compiling $csource with $melt_cflags time $melt_cc -Wall -fPIC -shared $melt_cflags -I "$melt_headerdir" $csource $datf.c -o $nakedynstuff.so echo echo ls -lt $nakedynstuff.so $csource ;; *) libtool --mode=compile -prefer-pic $melt_cc $melt_cflags $csource -I "$melt_headerdir" -o $nakedynstuff.lo; libtool --mode=compile -prefer-pic $melt_cc $melt_cflags $datf.c -o $datf.lo libtool --mode=link -module $melt_cc $makedynstuff.lo $datf.lo -o $nakedynstuff.la rm -f $datf.* ;; esac echo done $0 $* '@@@@' echo