-
Notifications
You must be signed in to change notification settings - Fork 37
/
dest-install.sh
executable file
·106 lines (92 loc) · 3.19 KB
/
dest-install.sh
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
#!/bin/sh
#
# (C) Copyright 2016-2024 Diomidis Spinellis
#
# This file is part of CScout.
#
# CScout 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 of the License, or
# (at your option) any later version.
#
# CScout 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 CScout. If not, see <http://www.gnu.org/licenses/>.
#
# Install the files required for CScout to the destination directory
#
# The following definition files are created:
#stdc-defs: for compiling Standard C files, with CScout-provided headers
#host-defs: for compiling host-specific C files through CScout project files
#csmake-defs: for compiling arbitrary C files through csmake
#
# These are the files' contents:
# STDC defs GCC fixes CScout defs compiler defs
#stdc-defs * *
#host-defs * * *
#csmake-defs * *
PREFIX="${1-/usr/local}"
TMPFILE="/tmp/$0-$$"
INC=../include
INCLUDE_DIR="$PREFIX/include/cscout"
# Permissions for header files
HMODE=644
# Workarounds for all compilers
WORKAROUNDS_PRE="$INC/template/gcc-defs.h $INC/template/llvm-defs.h $INC/template/cscout-defs.h"
WORKAROUNDS_POST="$INC/template/llvm-undefs.h"
# Create required directories
install -d "$INCLUDE_DIR/stdc" "$PREFIX/bin"
# Generic C definitions
install -m $HMODE $INC/stdc/*.h "$INCLUDE_DIR/stdc/"
cat $INC/template/cscout-defs.h $INC/template/stdc-defs.h >$TMPFILE
install -m $HMODE $TMPFILE "$INCLUDE_DIR/stdc-defs.h"
# Generic C include path specification
cat <<EOF >$TMPFILE
#pragma includepath "$INCLUDE_DIR/stdc"
/* Avoid unused include file warnings */
static void _cscout_dummy2(void) { _cscout_dummy2(); }
EOF
install -m $HMODE $TMPFILE "$INCLUDE_DIR/stdc-incs.h"
# Host's C definitions
{
cat $WORKAROUNDS_PRE
echo "/* Definitions derived from cpp -O -dM on $(date) */"
cpp -O -dM /dev/null | sort
cat $WORKAROUNDS_POST
} >$TMPFILE
install -m $HMODE $TMPFILE "$INCLUDE_DIR/host-defs.h"
# Only CScout and compiler workarounds for csmake-generated projects
cat $WORKAROUNDS_PRE >$TMPFILE
install -m $HMODE $TMPFILE "$INCLUDE_DIR/csmake-pre-defs.h"
cat $WORKAROUNDS_POST >$TMPFILE
install -m $HMODE $TMPFILE "$INCLUDE_DIR/csmake-post-defs.h"
# Host's C include path specification
cpp -Wp,-v </dev/null 2>&1 |
sed -n -e '
1a\
/* Avoid unused include file warnings */
1a\
static void _cscout_dummy2(void) { _cscout_dummy2(); }
1a\
/^#include <\.\.\.> search starts here:/,/^End of search list\./ {
/^ /!d
s/ /#pragma includepath "/
s/$/"/
p
}' >$TMPFILE
install -m $HMODE $TMPFILE "$INCLUDE_DIR/host-incs.h"
# Perl scripts (keep csmake.pl in the end)
for f in cswc.pl csmake.pl ; do
sed "s|INSTALL_INCLUDE|$INCLUDE_DIR|g" $f >$TMPFILE
install $TMPFILE "$PREFIX/bin/$(basename $f .pl)"
done
# Install as cscc
install $TMPFILE "$PREFIX/bin/cscc"
install cscut.sh "$PREFIX/bin/cscut"
install cssplit.awk "$PREFIX/bin/cssplit"
install csreconst.sh "$PREFIX/bin/csreconst"
rm -f $TMPFILE