summaryrefslogtreecommitdiff
path: root/gcc/melt-cc-script.proto
blob: a143824a0b6ebfc00ef41c68f071cf5217bfc108 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#! /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 <basile@starynkevitch.net>
# 
# 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
# <http://www.gnu.org/licenses/>. 

#:! :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:"

## 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
nakedynstuff=$2
datf=`tempfile  -p bdat`
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 $makedynstuff.so;;
*) 
	libtool --mode=compile -prefer-pic $melt_cc $csource  -I "$melt_headerdir" -o $makedynstuff.lo;
	libtool --mode=compile -prefer-pic $melt_cc $datf.c -o $datf.lo
	libtool --mode=link -module $melt_cc  $makedynstuff.lo $datf.lo -o  $makedynstuff.la
	rm -f $datf.*
	;;
esac