#! /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:" 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 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 datf=`tempfile -p bdat` pwd echo melt_cc= $melt_cc melt_cflags= $melt_cflags melt_headerdir= $melt_headerdir csource= $csource nakedynstuff= $nakedynstuff datf= $datf if [ -z "$datf" ]; then datf=/tmp/bdat$$ fi # generate the temporary timestamp & md5s file md5src=`md5sum $csource` trap "rm -f $datf.*" EXIT date "+const char basilys_compiled_timestamp[]=\"$csource %c\";" > $datf.c echo "const char basilys_md5[]=\"$md5src\";" >> $datf.c case `uname` in Linux|SunOS|Solaris) $melt_cc -fPIC -shared $melt_cflags -I "$melt_headerdir" $csource $datf.c -o $nakedynstuff.so;; *) libtool --mode=compile -prefer-pic $melt_cc $csource -I "$melt_headerdir" -o $nakedynstuff.lo; libtool --mode=compile -prefer-pic $melt_cc $datf.c -o $datf.lo libtool --mode=link -module $melt_cc $makedynstuff.lo $datf.lo -o $nakedynstuff.la rm -f $datf.* ;; esac