aboutsummaryrefslogtreecommitdiff
path: root/contrib/make-melt-plugin-source-tar.sh
blob: 76fe400a475a6e5a57ee21f8b95a407673972e43 (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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
#! /bin/bash
## file contrib/make-melt-source-tar.sh of the MELT branch of GCC
## building the plugin source distribution
## first argument is GCC MELT source tree
## second argument is the basename of the tar ball
## following optional arguments are gengtype -r gengtype.state ...
##
##    Middle End Lisp Translator = MELT
##
##    Copyright (C)  2010 - 2013 Free Software Foundation, Inc.
##    Contributed by Basile Starynkevitch <basile@starynkevitch.net>
## 
## This file 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/>.


## if the first argument is -l, we are using symlinks instead of copying

if [ "$1" = "-l" ]; then
    gccmelt_copy="ln -svf"
    shift
else
    gccmelt_copy="cp -av"
fi


## if the first argument is -s we are making a snapshot
if [ "$1" = "-s" ]; then
    gccmelt_snapshot=snapshot
    shift
fi

## the first argument of this script is the source tree of the GCC
## MELT branch from which is extracted the MELT plugin source, for
## instance /usr/src/Lang/gcc-melt
gccmelt_source_tree=$1

## the second argument of this script is a temporary directory
## basename for the plugin source, for instance /tmp/gcc-melt-plugin
## and this script will then make a directory /tmp/gcc-melt-plugin and
## a bzipped tar archive /tmp/gcc-melt-plugin.tar.bz2
gccmelt_tarbase=$2

if [ -z "$gccmelt_tarbase" ]; then
    echo usage: $0 "[-l|-s]" "<meltbranch-sourcetree> <output-tarbase>" >&2
    echo " " use " -l" for symlinks or " -s" for snapshots or nothing for release  >&2
    echo " " "<meltbranch-sourcetree> could be e.g. /usr/src/gcc-melt-branch" >&2
    echo " " "<output-tarbase> could be e.g. /tmp/melt-plugin" >&2
    exit 1
fi

shift 2
## the optional other arguments are used to invoke gengtype, for instance
## $(gcc-4.6 -print-file-name=gengtype) -v -r $(gcc-4.6 -print-file-name=gtype.state)
gengtype_prog=$1

if [ -n "$gengtype_prog" ]; then
    case $gengtype_prog in
	*gengtype*) 
	    shift 1; 
	    gengtype_args="$@";;
	*) 
	    echo $0: Bad optional gengtype $gengtype_prog >&2
	    exit 1
    esac
fi

if [ ! -f $gccmelt_source_tree/gcc/melt-runtime.h ]; then
    echo $0: Bad first argument for GCC MELT source tree $gccmelt_source_tree >&2
    exit 1
fi

if [ -z $gccmelt_tarbase ]; then
    echo $0 Bad second argument for GCC MELT tar ball base $gccmelt_tarbase >&2
    exit 1
fi

gccmelt_svnrev=$(svn info $gccmelt_source_tree | awk '/^Revision:/{print $2}')

if [ -n "$gccmelt_snapshot" ]; then
    case $gccmelt_svnrev in
	[1-9][0-9]*) gccmelt_snapshot="snap-svnrev-$gccmelt_svnrev";;
	*);;
    esac
fi

rm -rf $gccmelt_tarbase

mkdir -p $gccmelt_tarbase/melt/generated

date +"source tar timestamp %c %Z" > $gccmelt_tarbase/GCCMELT-SOURCE-DATE
if [ -n "$gccmelt_svnrev" ]; then
    echo "from $gccmelt_svnrev" >> $gccmelt_tarbase/GCCMELT-SOURCE-DATE
fi

copymelt() {
    if [ -f $gccmelt_source_tree/$1 ]; then
	$gccmelt_copy $gccmelt_source_tree/$1 $gccmelt_tarbase/$2
    fi
}

## just a reminder
echo $0: You should have recently run in gcc/ of build tree: make upgrade-warmelt 

mkdir $gccmelt_tarbase/testmelt

mkdir $gccmelt_tarbase/obsolete-melt

copymelt COPYING3
copymelt move-if-change
copymelt gcc/DATESTAMP GCCMELT-DATESTAMP
copymelt gcc/REVISION GCCMELT-REVISION

copymelt gcc/doc/include/fdl.texi 
copymelt gcc/doc/include/funding.texi 
copymelt gcc/doc/gnu.texi 
copymelt gcc/doc/include/gpl.texi 
copymelt gcc/doc/include/gpl_v3.texi 
copymelt gcc/doc/include/texinfo.tex
copymelt gcc/emit-libmelt-treecode.inc

for f in gcc/testsuite/melt/* ; do
   copymelt $f testmelt/
done

for f in gcc/obsolete-melt/* ; do
   copymelt $f obsolete-melt/
done

copymelt gcc/doc/melt.texi

copymelt contrib/melt-mv-if-changed.c 
copymelt contrib/meltplugin.texi 
copymelt contrib/meltpluginapi.texi

copymelt contrib/MELT-Plugin-Makefile
(cd $gccmelt_tarbase/; ln -s MELT-Plugin-Makefile Makefile)


copymelt gcc/make-melt-predefh.awk make-melt-predefh.awk
copymelt gcc/make-warmelt-predef.awk make-warmelt-predef.awk
copymelt gcc/melt-build-script.tpl
copymelt gcc/melt-build-script.def 
copymelt gcc/melt-build-script.sh
copymelt gcc/melt-runtime.cc
copymelt gcc/melt-runtime.h

for mf in $gccmelt_source_tree/gcc/melt/*.melt ; do 
    $gccmelt_copy $mf  $gccmelt_tarbase/melt/
done

for mf in $gccmelt_source_tree/gcc/melt/generated/*.{c,cc,h} ; do 
    $gccmelt_copy $mf  $gccmelt_tarbase/melt/generated/
done


for mf in $gccmelt_source_tree/gcc/*melt*  ; do
    case $mf in
	*~) ;;
	*) copymelt gcc/$(basename $mf) ;;
    esac
done


for cf in  $gccmelt_source_tree/contrib/*melt*.sh $gccmelt_source_tree/contrib/pygmentize-melt ; do
    copymelt contrib/$(basename $cf) 
    chmod a+x $gccmelt_tarbase/$(basename $cf)
done

for cf in   $gccmelt_source_tree/contrib/simplemelt-gtkmm-probe.cc $gccmelt_source_tree/contrib/simplemelt-pyqt4-probe.py ; do
    copymelt contrib/$(basename $cf) 
done

copymelt INSTALL/README-MELT-PLUGIN
copymelt libmeltopengpu/meltopengpu-runtime.c

if [ -n "$gccmelt_snapshot" ]; then
    gccmelt_origpat='#define *MELT_VERSION_STRING *"\([a-zA-Z0-9.-]*\)" *'
    gccmelt_replac="#define MELT_VERSION_STRING \"\\1-$gccmelt_snapshot\""
    sed -i "s/$gccmelt_origpat/$gccmelt_replac/" $gccmelt_tarbase/melt-runtime.h
    grep "define *MELT_VERSION_STRING"  $gccmelt_tarbase/melt-runtime.h
fi


if [ -n "$gengtype_prog" ]; then
    gengtype_version=$($gengtype_prog -V | head -1 | awk '{print $NF}' 2>/dev/null)
    $gengtype_prog $gengtype_args -P $gccmelt_tarbase/gt-melt-runtime-$gengtype_version-plugin.h $gccmelt_tarbase/melt-runtime.h  $gccmelt_tarbase/melt/generated/meltrunsup.h
fi

tar -cvf $gccmelt_tarbase-tmp.tar \
   --exclude-backups --exclude='*~' --exclude='*%' \
   -C $(dirname $gccmelt_tarbase) $(basename $gccmelt_tarbase)

## we use tardy http://tardy.sourceforge.net/ to remove our name and
## group.. and make a tarball owned by melt/gcc

tardy -User_NAme melt -Group_NAme gcc $gccmelt_tarbase-tmp.tar $gccmelt_tarbase.tar 

rm -f $gccmelt_tarbase-tmp.tar 
bzip2 -v9 $gccmelt_tarbase.tar
#eof make-melt-plugin-source-tar.sh