~ibmcharmers/charms/xenial/ibm-db2/trunk

« back to all changes in this revision

Viewing changes to .tox/py35/lib/python3.5/config-3.5m-x86_64-linux-gnu/makesetup

  • Committer: Rajith Venkata
  • Date: 2017-02-22 09:37:48 UTC
  • Revision ID: rajith.pv@in.ibm.com-20170222093748-fibtdsahuug31ra5
2ndcheckin for IBM-DB2 charm

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#! /bin/sh
 
2
 
 
3
# Convert templates into Makefile and config.c, based on the module
 
4
# definitions found in the file Setup.
 
5
#
 
6
# Usage: makesetup [-s dir] [-c file] [-m file] [Setup] ... [-n [Setup] ...]
 
7
#
 
8
# Options:
 
9
# -s directory: alternative source directory (default .)
 
10
# -l directory: library source directory (default derived from $0)
 
11
# -c file:      alternative config.c template (default $libdir/config.c.in)
 
12
# -c -:         don't write config.c
 
13
# -m file:      alternative Makefile template (default ./Makefile.pre)
 
14
# -m -:         don't write Makefile
 
15
#
 
16
# Remaining arguments are one or more Setup files (default ./Setup).
 
17
# Setup files after a -n option are used for their variables, modules
 
18
# and libraries but not for their .o files.
 
19
#
 
20
# See Setup.dist for a description of the format of the Setup file.
 
21
#
 
22
# The following edits are made:
 
23
#
 
24
# Copying config.c.in to config.c:
 
25
# - insert an identifying comment at the start
 
26
# - for each <module> mentioned in Setup before *noconfig*:
 
27
#   + insert 'extern PyObject* PyInit_<module>(void);' before MARKER 1
 
28
#   + insert '{"<module>", PyInit_<module>},' before MARKER 2
 
29
#
 
30
# Copying Makefile.pre to Makefile:
 
31
# - insert an identifying comment at the start
 
32
# - replace _MODOBJS_ by the list of objects from Setup (except for
 
33
#   Setup files after a -n option)
 
34
# - replace _MODLIBS_ by the list of libraries from Setup
 
35
# - for each object file mentioned in Setup, append a rule
 
36
#   '<file>.o: <file>.c; <build commands>' to the end of the Makefile
 
37
# - for each module mentioned in Setup, append a rule
 
38
#   which creates a shared library version to the end of the Makefile
 
39
# - for each variable definition found in Setup, insert the definition
 
40
#   before the comment 'Definitions added by makesetup'
 
41
 
 
42
# Loop over command line options
 
43
usage='
 
44
usage: makesetup [-s srcdir] [-l libdir] [-c config.c.in] [-m Makefile.pre]
 
45
                 [Setup] ... [-n [Setup] ...]'
 
46
srcdir='.'
 
47
libdir=''
 
48
config=''
 
49
makepre=''
 
50
noobjects=''
 
51
doconfig=yes
 
52
while :
 
53
do
 
54
        case $1 in
 
55
        -s)     shift; srcdir=$1; shift;;
 
56
        -l)     shift; libdir=$1; shift;;
 
57
        -c)     shift; config=$1; shift;;
 
58
        -m)     shift; makepre=$1; shift;;
 
59
        --)     shift; break;;
 
60
        -n)     noobjects=yes;;
 
61
        -*)     echo "$usage" 1>&2; exit 2;;
 
62
        *)      break;;
 
63
        esac
 
64
done
 
65
 
 
66
# Set default libdir and config if not set by command line
 
67
# (Not all systems have dirname)
 
68
case $libdir in
 
69
'')     case $0 in
 
70
        */*)    libdir=`echo $0 | sed 's,/[^/]*$,,'`;;
 
71
        *)      libdir=.;;
 
72
        esac;;
 
73
esac
 
74
case $config in
 
75
'')     config=$libdir/config.c.in;;
 
76
esac
 
77
case $makepre in
 
78
'')     makepre=Makefile.pre;;
 
79
esac
 
80
 
 
81
# Newline for sed i and a commands
 
82
NL='\
 
83
'
 
84
 
 
85
# Setup to link with extra libraries when makeing shared extensions.
 
86
# Currently, only Cygwin needs this baggage.
 
87
case `uname -s` in
 
88
CYGWIN*) if test $libdir = .
 
89
         then
 
90
                ExtraLibDir=.
 
91
         else
 
92
                ExtraLibDir='$(LIBPL)'
 
93
         fi
 
94
         ExtraLibs="-L$ExtraLibDir -lpython\$(VERSION)";;
 
95
esac
 
96
 
 
97
# Main loop
 
98
for i in ${*-Setup}
 
99
do
 
100
        case $i in
 
101
        -n)     echo '*noobjects*';;
 
102
        *)      echo '*doconfig*'; cat "$i";;
 
103
        esac
 
104
done |
 
105
sed -e 's/[     ]*#.*//' -e '/^[        ]*$/d' |
 
106
(
 
107
        rulesf="@rules.$$"
 
108
        trap 'rm -f $rulesf' 0 1 2 3
 
109
        echo "
 
110
# Rules appended by makedepend
 
111
" >$rulesf
 
112
        DEFS=
 
113
        MODS=
 
114
        SHAREDMODS=
 
115
        OBJS=
 
116
        LIBS=
 
117
        LOCALLIBS=
 
118
        BASELIBS=
 
119
        while read line
 
120
        do
 
121
                # to handle backslashes for sh's that don't automatically
 
122
                # continue a read when the last char is a backslash
 
123
                while echo $line | grep '\\$' > /dev/null
 
124
                do
 
125
                        read extraline
 
126
                        line=`echo $line| sed s/.$//`$extraline
 
127
                done
 
128
 
 
129
                # Output DEFS in reverse order so first definition overrides
 
130
                case $line in
 
131
                *=*)    DEFS="$line$NL$DEFS"; continue;;
 
132
                'include '*)    DEFS="$line$NL$DEFS"; continue;;
 
133
                '*noobjects*')
 
134
                        case $noobjects in
 
135
                        yes)    ;;
 
136
                        *)      LOCALLIBS=$LIBS; LIBS=;;
 
137
                        esac
 
138
                        noobjects=yes;
 
139
                        continue;;
 
140
                '*doconfig*')   doconfig=yes; continue;;
 
141
                '*static*')     doconfig=yes; continue;;
 
142
                '*noconfig*')   doconfig=no; continue;;
 
143
                '*shared*')     doconfig=no; continue;;
 
144
                esac
 
145
                srcs=
 
146
                cpps=
 
147
                libs=
 
148
                mods=
 
149
                skip=
 
150
                for arg in $line
 
151
                do
 
152
                        case $skip in
 
153
                        libs)   libs="$libs $arg"; skip=; continue;;
 
154
                        cpps)   cpps="$cpps $arg"; skip=; continue;;
 
155
                        srcs)   srcs="$srcs $arg"; skip=; continue;;
 
156
                        esac
 
157
                        case $arg in
 
158
                        -framework)     libs="$libs $arg"; skip=libs;
 
159
                                        # OSX/OSXS/Darwin framework link cmd
 
160
                                        ;;
 
161
                        -[IDUCfF]*)     cpps="$cpps $arg";;
 
162
                        -Xcompiler)     skip=cpps;;
 
163
                        -Xlinker)       libs="$libs $arg"; skip=libs;;
 
164
                        -rpath)         libs="$libs $arg"; skip=libs;;
 
165
                        --rpath)        libs="$libs $arg"; skip=libs;;
 
166
                        -[A-Zl]*)       libs="$libs $arg";;
 
167
                        *.a)            libs="$libs $arg";;
 
168
                        *.so)           libs="$libs $arg";;
 
169
                        *.sl)           libs="$libs $arg";;
 
170
                        /*.o)           libs="$libs $arg";;
 
171
                        *.def)          libs="$libs $arg";;
 
172
                        *.o)            srcs="$srcs `basename $arg .o`.c";;
 
173
                        *.[cC])         srcs="$srcs $arg";;
 
174
                        *.m)            srcs="$srcs $arg";; # Objective-C src
 
175
                        *.cc)           srcs="$srcs $arg";;
 
176
                        *.c++)          srcs="$srcs $arg";;
 
177
                        *.cxx)          srcs="$srcs $arg";;
 
178
                        *.cpp)          srcs="$srcs $arg";;
 
179
                        \$*)            libs="$libs $arg"
 
180
                                        cpps="$cpps $arg";;
 
181
                        *.*)            echo 1>&2 "bad word $arg in $line"
 
182
                                        exit 1;;
 
183
                        -u)             skip=libs; libs="$libs -u";;
 
184
                        [a-zA-Z_]*)     mods="$mods $arg";;
 
185
                        *)              echo 1>&2 "bad word $arg in $line"
 
186
                                        exit 1;;
 
187
                        esac
 
188
                done
 
189
                case $doconfig in
 
190
                yes)
 
191
                        LIBS="$LIBS $libs"
 
192
                        MODS="$MODS $mods"
 
193
                        ;;
 
194
                esac
 
195
                case $noobjects in
 
196
                yes)    continue;;
 
197
                esac
 
198
                objs=''
 
199
                for src in $srcs
 
200
                do
 
201
                        case $src in
 
202
                        *.c)   obj=`basename $src .c`.o; cc='$(CC)';;
 
203
                        *.cc)  obj=`basename $src .cc`.o; cc='$(CXX)';;
 
204
                        *.c++) obj=`basename $src .c++`.o; cc='$(CXX)';;
 
205
                        *.C)   obj=`basename $src .C`.o; cc='$(CXX)';;
 
206
                        *.cxx) obj=`basename $src .cxx`.o; cc='$(CXX)';;
 
207
                        *.cpp) obj=`basename $src .cpp`.o; cc='$(CXX)';;
 
208
                        *.m)   obj=`basename $src .m`.o; cc='$(CC)';; # Obj-C
 
209
                        *)     continue;;
 
210
                        esac
 
211
                        obj="$srcdir/$obj"
 
212
                        objs="$objs $obj"
 
213
                        case $src in
 
214
                        glmodule.c) ;;
 
215
                        /*) ;;
 
216
                        \$*) ;;
 
217
                        *) src='$(srcdir)/'"$srcdir/$src";;
 
218
                        esac
 
219
                        case $doconfig in
 
220
                        no)     cc="$cc \$(CCSHARED) \$(PY_CFLAGS) \$(PY_CPPFLAGS)";;
 
221
                        *)
 
222
                                cc="$cc \$(PY_CORE_CFLAGS)";;
 
223
                        esac
 
224
                        rule="$obj: $src; $cc $cpps -c $src -o $obj"
 
225
                        echo "$rule" >>$rulesf
 
226
                done
 
227
                case $doconfig in
 
228
                yes)    OBJS="$OBJS $objs";;
 
229
                esac
 
230
                for mod in $mods
 
231
                do
 
232
                        file="$srcdir/$mod\$(EXT_SUFFIX)"
 
233
                        case $doconfig in
 
234
                        no)     SHAREDMODS="$SHAREDMODS $file";;
 
235
                        esac
 
236
                        rule="$file: $objs"
 
237
                        rule="$rule; \$(BLDSHARED) $objs $libs $ExtraLibs -o $file"
 
238
                        echo "$rule" >>$rulesf
 
239
                done
 
240
        done
 
241
 
 
242
        case $SHAREDMODS in
 
243
        '')     ;;
 
244
        *)      DEFS="SHAREDMODS=$SHAREDMODS$NL$DEFS";;
 
245
        esac
 
246
 
 
247
        case $noobjects in
 
248
        yes)    BASELIBS=$LIBS;;
 
249
        *)      LOCALLIBS=$LIBS;;
 
250
        esac
 
251
        LIBS='$(LOCALMODLIBS) $(BASEMODLIBS)'
 
252
        DEFS="BASEMODLIBS=$BASELIBS$NL$DEFS"
 
253
        DEFS="LOCALMODLIBS=$LOCALLIBS$NL$DEFS"
 
254
 
 
255
        EXTDECLS=
 
256
        INITBITS=
 
257
        for mod in $MODS
 
258
        do
 
259
                EXTDECLS="${EXTDECLS}extern PyObject* PyInit_$mod(void);$NL"
 
260
                INITBITS="${INITBITS}   {\"$mod\", PyInit_$mod},$NL"
 
261
        done
 
262
 
 
263
 
 
264
        case $config in
 
265
        -)  ;;
 
266
        *)  sed -e "
 
267
                1i$NL/* Generated automatically from $config by makesetup. */
 
268
                /MARKER 1/i$NL$EXTDECLS
 
269
 
 
270
                /MARKER 2/i$NL$INITBITS
 
271
 
 
272
                " $config >config.c
 
273
            ;;
 
274
        esac
 
275
 
 
276
        case $makepre in
 
277
        -)      ;;
 
278
        *)      sedf="@sed.in.$$"
 
279
                trap 'rm -f $sedf' 0 1 2 3
 
280
                printf "1i\\" >$sedf
 
281
                str="# Generated automatically from $makepre by makesetup."
 
282
                echo "$str" >>$sedf
 
283
                echo "s%_MODOBJS_%$OBJS%" >>$sedf
 
284
                echo "s%_MODLIBS_%$LIBS%" >>$sedf
 
285
                echo "/Definitions added by makesetup/a$NL$NL$DEFS" >>$sedf
 
286
                sed -f $sedf $makepre >Makefile
 
287
                cat $rulesf >>Makefile
 
288
                rm -f $sedf
 
289
            ;;
 
290
        esac
 
291
 
 
292
        rm -f $rulesf
 
293
)