File: install

package info (click to toggle)
icmake 13.05.01-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 7,132 kB
  • sloc: cpp: 11,595; fortran: 883; makefile: 853; sh: 546; pascal: 342
file content (161 lines) | stat: -rwxr-xr-x 4,248 bytes parent folder | download
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
#!/bin/bash

# constructed files are all below ./tmp, in fixed locations, like
# ./tmp/usr/bin/  

# absolute (final) installation directories are specified in INSTALL.im and
# are prefixed by the path specified by this script's (optional) 2nd argument
# (not counting the optional initial 'strip' argument) for storage purposes
# only.

. ./buildscripts/try

usage()
{
    echo "
Usage: $0 [strip] all|progs|scripts|man|skel|doc|etc [storageDir]
"
    exit 1
}

# optionally strip the binaries
    if [ "$1" == "strip" ] ; then
        STRIP=strip
        shift
    fi

[ -e tmp/INSTALL.sh ] || usage  # no tmp/INSTALL.sh then probably 
                                # ./prepare wasn't called

. tmp/INSTALL.sh                # get the installation locations

. scripts/setstoragedir         # maybe set the storagedir

# the storageDir is unrelated to the root directory specified by tmp/ROOT
# but is used to store the resulting files in a separate directory like
# debian/icmake, which is used when constructing a Debian package
# show the actual root directory, and the storageDir if it differs from root

    if [ "${storageDir}" != "" ] ; then
        echo "    storageDir: ${storageDir}
"
        if [ ! -e ${storageDir} ] ; then
            mkdir -p ${storageDir}
        elif [ ! -d ${storageDir} ] ; then
            echo $storageDir must be a directory
            exit 1
        fi
    fi

tarInstall()
{
    try mkdir -p ${2}
    echo "  installing tmp/${1} in ${2}"
    (cd tmp/${1}; tar cf - .) | (cd ${2}; tar xf -)
    [ "$?" -eq "0" ] || exit 1
}

progs()
{
    # at this point the BINDIR etc. variables define absolute paths.
    # No need to prefix ${storagedir}

    echo programs:
    # maybe strip the binaries

    if [ "$STRIP" == "strip" ] ; then
        try strip tmp/usr/bin/icmake tmp/usr/bin/icmbuild \
                  tmp/usr/bin/icmodmap tmp/usr/libexec/icmake/*
        echo
    fi

    #  prepare the directories for the binaries
    try mkdir -p ${BINDIR} ${LIBDIR}

    #install the usr/bin  binaries
    tarInstall usr/bin ${BINDIR}

    # a possibly running icm-exec program must first be removed before
    # a new icm-exec program can be installed
    if [ -e ${LIBDIR}/icm-exec ] ; then
        try rm ${LIBDIR}/icm-exec 
    fi

    #install the libexec binaries
    tarInstall usr/libexec/icmake ${LIBDIR}
    echo
}

scripts()
{
    echo scripts:
    # prepare the directories used by scripts:
        try mkdir -p ${BINDIR} ${LIBDIR} ${DOCDIR} 

    # convert icmstart.sh to storageDir/usr/bin/icmstart
        try scripts/convert tmp/icmstart.sh ${BINDIR}/icmstart
        try chmod +x ${BINDIR}/icmstart

    # convert icmbuild.in to icmbuild
        try scripts/convert tmp/icmbuild.in ${LIBDIR}/icmbuild

    # convert icmstart.in to docdir/icmstart.im
    # compress the icmstart.im script in the documentation directory:
        try scripts/convert tmp/icmstart.in tmp/icmstart.im
        echo "    gzip -9cn tmp/icmstart.im > ${DOCDIR}/icmstart.im.gz"
        gzip -9cn tmp/icmstart.im > ${DOCDIR}/icmstart.im.gz || exit 1

    # compile icmstart.im to $storageDir$LIBDIR/icmstart.bim so icmstart can
    # immediately be used w/o having to compile it first.
        try tmp/usr/libexec//icmake/icm-pp tmp/icmstart.im tmp/icmstart.pim
        try tmp/usr/libexec/icmake/icm-comp tmp/icmstart.pim ${LIBDIR}/icmstart.bim

    echo
}


# argument: the directory to store, files are stored under $storageDir
#   (called below, e.g., to install the man-pages)

case $1 in
    (all)
        progs
        scripts
        echo "man, skeletons, docs, etc:"
        tarInstall usr/share/man        ${MANDIR}
        tarInstall usr/share/icmake     ${SKELDIR}
        tarInstall usr/share/doc/icmake ${DOCDIR}
        tarInstall etc/icmake           ${CONFDIR}
        echo
        echo "Done. Consider calling ./clean"
        echo
    ;;

    (progs)
        progs
    ;;

    (scripts)
        scripts
    ;;

    (man)
        tarInstall usr/share/man ${MANDIR}
    ;;

    (skel)
        tarInstall usr/share/icmake ${SKELDIR}
    ;;

    (doc)
        tarInstall usr/share/doc/icmake ${DOCDIR}
    ;;

    (etc)
        tarInstall etc/icmake ${CONFDIR}
    ;;

    (*)
        usage
    ;;
esac