File: configure

package info (click to toggle)
wap-wml-tools 0.0.4-6
  • links: PTS, VCS
  • area: non-free
  • in suites: squeeze, wheezy
  • size: 332 kB
  • ctags: 235
  • sloc: ansic: 1,108; makefile: 111; sh: 109
file content (173 lines) | stat: -rwxr-xr-x 3,569 bytes parent folder | download | duplicates (3)
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
#!/bin/sh

VERSION="0.0.4"

LD_OPS=""
CC_OPS="-I../"
CC=""
OPTIMISE_IF_GCC="y"
XML_CONFIG="xml-config"
SHARED_LINK=""

echo "wml-tools v$VERSION configuration script"

while [ $# -gt 0 ]; do
  case "$1" in
    --cc)
      shift
      CC="$1"
      echo "Setting compiler to '$CC'"
      ;;
    --cc-flags)
      shift
      CC_OPS="$CC_OPS $1"
      echo "Adding compiler flags '$1'"
      ;;
    --xml-config)
      shift
      XML_CONFIG="$1"
      echo "Setting xml-config command to '$XML_CONFIG'"
      ;;
    *)
      echo "Unknown option '$1'"
      echo ""
      echo "Known options:"
      echo ""
      echo "  --cc <cc>         : Set compiler to <cc>"
      echo "  --cc-flags <fl>   : Set standard compiler flags to <fl>"
      echo "  --xml-config <cf> : Set xml-config program to <cf>"
      echo ""
      exit 1
      ;;
  esac
  shift
done



#### Test if compiler works

CC_WORKS="n"

for CC_TEST in "$CC" gcc cc; do
  if [ "$CC_WORKS" = "n" -a "$CC_TEST" != "" ]; then
    CC="$CC_TEST"
    echo -n "Testing compiler $CC ... "
    cat >/tmp/.pwt.c << EOF
#include <stdio.h>
void main(void) { puts("CC Test"); }
EOF

    $CC -o /tmp/.pwt /tmp/.pwt.c >/dev/null 2>&1
    if [ -e "/tmp/.pwt" ]; then
      echo "Found"
      echo -n "Checking if compiler $CC works ... "
      if [ "`/tmp/.pwt`" = "CC Test" ]; then
        echo "Yes"
        CC_WORKS="y"
      else
        echo "No"
        CC_WORKS="n"
      fi
    else
      echo "Not found"
      CC_WORKS="n"
    fi
  fi
done
rm -f /tmp/.pwt /tmp/.pwt.c

if [ "$CC_WORKS" = "n" ]; then
  echo "Couldn't find a working compiler"
  exit 1
fi

if [ "$CC" = "gcc" ]; then
  if [ "$OPTIMISE_IF_GCC" = "y" ]; then
    echo "Adding optimising flags for compiler"
    CC_OPS="$CC_OPS -O2"
  fi
fi

####




##### We don't need socket code yet so miss out
#
##### Solaris check (-lsocket)
#
#echo -n "Testing for bind() in -lsocket ... "
#cat >/tmp/.pwt.c << EOF
##include <stdio.h>
##include <sys/types.h>
##include <sys/socket.h>
#void main(void) {
#struct sockaddr* mad;
#int i;
#  bind(i, (struct sockaddr*) &mad, 1);
#}
#EOF
#
#$CC -o /tmp/.pwt /tmp/.pwt.c >/dev/null 2>&1
#if [ -e "/tmp/.pwt" ]; then
#  echo "Not required"
#else
#  $CC -o /tmp/.pwt /tmp/.pwt.c -lsocket >/dev/null 2>&1
#  if [ -e "/tmp/.pwt" ]; then
#    echo "Found"
#    LD_OPS="$LD_OPS -lsocket -lnsl"
#  else
#    echo "Needed but not found"
#    rm -f /tmp/.pwt /tmp/.pwt.c
#    exit 1
#  fi
#fi
#rm -f /tmp/.pwt /tmp/.pwt.c
#
#####


#### XML config

echo -n "Getting XML compilation flags ... "
XML_CC_OPS="`$XML_CONFIG --cflags`"
XML_LD_OPS="`$XML_CONFIG --libs`"
if [ "$XML_CC_OPS" = "" -o "$XML_LD_OPS" = "" ]; then
  echo "Not found"
  echo "WARNING: Couldn't execute '$XML_CONFIG' for XML compilation flags."
  echo "WARNING: Check libxml is installed and try again."
  exit 1
else
  echo "Done"
fi

####

echo "Compilation flags :"
echo ""
echo "       CC : $CC"
echo "   CC_OPS : $CC_OPS"
echo "   LD_OPS : $LD_OPS"
echo "XML flags : Include '$XML_CC_OPS'"
echo "          : Link '$XML_LD_OPS'"
echo ""
echo "Building Makefile"

if [ -f "Makefile" ]; then
  mv -f Makefile Makefile.bak
fi

CC_USE=`echo $CC | sed 's/\\//\\\\\//g'`
CC_OPS_USE=`echo $CC_OPS | sed 's/\\//\\\\\//g'`
LD_OPS_USE=`echo $LD_OPS | sed 's/\\//\\\\\//g'`
XML_CC_OPS_USE=`echo $XML_CC_OPS | sed 's/\\//\\\\\//g'`
XML_LD_OPS_USE=`echo $XML_LD_OPS | sed 's/\\//\\\\\//g'`

sed "s/%CC%/$CC_USE/g
s/%CC_OPS%/$CC_OPS_USE/g
s/%LD_OPS%/$LD_OPS_USE/g
s/%XML_CC_OPS%/$XML_CC_OPS_USE/g
s/%XML_LD_OPS%/$XML_LD_OPS_USE/g" <Makefile.in >Makefile
echo "Done"