Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100755 79 lines (67 sloc) 2.258 kb
bedbc05 @tuncer add rebar support (Tuncer Ayaz and Steve Vinoski)
tuncer authored
1 #!/bin/sh
2
3 YAWS_DIR=`pwd`
59a8cc1 @vinoski make sed commands for version substitution more robust
vinoski authored
4 DEFAULT_YAWS_VSN=`sed -ne '1,/^YAWS_VSN=/s/^YAWS_VSN=//p' $YAWS_DIR/vsn.mk 2>/dev/null`
bedbc05 @tuncer add rebar support (Tuncer Ayaz and Steve Vinoski)
tuncer authored
5 YAWS_VSN=${VSN-$DEFAULT_YAWS_VSN}
6 YAWS_VARDIR=${VARDIR-$YAWS_DIR/var}
7 YAWS_ETCDIR=${ETCDIR-$YAWS_DIR/etc}
8 ERL_BIN=`which erl`
9 ERL_BIN_DIR=${ERL_BIN%/erl}
10 YAWS_ERLBINDIR=${ERLBINDIR-$ERL_BIN_DIR}
11 ERL_BIN=$YAWS_ERLBINDIR/erl
12 WERL_BIN=$YAWS_ERLBINDIR/werl
13
61a1116 @vinoski more build avoidance for rebar build
vinoski authored
14 script=`basename $0`
15
bedbc05 @tuncer add rebar support (Tuncer Ayaz and Steve Vinoski)
tuncer authored
16 # Use a function for error exit instead of set -e so we can conditionally
17 # remove files before exiting. If this were bash we could trap ERR but
18 # Bourne shell doesn't support that portably.
19 fail() {
20 [ -n "$@" ] && rm -f "$@"
21 exit 1
22 }
23
61a1116 @vinoski more build avoidance for rebar build
vinoski authored
24 keep_or_replace() {
25 if [ -f "$1" ] && cmp -s "$1" "$2"; then
26 rm -f "$2"
27 return 0
28 else
29 mv "$2" "$1" || fail "$2"
30 return 1
31 fi
32 }
33
bedbc05 @tuncer add rebar support (Tuncer Ayaz and Steve Vinoski)
tuncer authored
34 cd src || fail
35
36 if [ "$1" = clean ]; then
89a64ef Make the mime types mappings configurable
Christopher Faulet authored
37 rm -f mime_types.erl ../priv/charset.def yaws_configure.hrl yaws_generated.erl
bedbc05 @tuncer add rebar support (Tuncer Ayaz and Steve Vinoski)
tuncer authored
38 exit 0
39 fi
40
41 CHARSET=${DEFAULT_CHARSET-""}
42 need_mime=yes
43 if [ -f mime_types.erl ]; then
44 need_mime=`find mime_type_c.erl -newer mime_types.erl -print`
45 fi
46 if [ -n "$need_mime" ]; then
89a64ef Make the mime types mappings configurable
Christopher Faulet authored
47 echo ${CHARSET} > ../priv/charset.def || fail
48 erlc -o ../ebin mime_type_c.erl || fail ../priv/charset.def
49 erl -pa ../ebin -noshell -s mime_type_c generate || \
50 fail ../priv/charset.def mime_types.erl
bedbc05 @tuncer add rebar support (Tuncer Ayaz and Steve Vinoski)
tuncer authored
51 fi
52
53 if [ ! -f yaws_configure.hrl ]; then
2150708 @tuncer Use file:sendfile/5 if available
tuncer authored
54 echo '%% rebar sets HAVE_YAWS_SENDFILE in erlc command line' \
55 > yaws_configure.hrl
bedbc05 @tuncer add rebar support (Tuncer Ayaz and Steve Vinoski)
tuncer authored
56 [ $? -eq 0 ] || fail
57 fi
61a1116 @vinoski more build avoidance for rebar build
vinoski authored
58 tmpgen=`mktemp /tmp/${script}.XXXXXX` || fail
bedbc05 @tuncer add rebar support (Tuncer Ayaz and Steve Vinoski)
tuncer authored
59 YAWS_VSN=$YAWS_VSN VARDIR="$YAWS_VARDIR" ETCDIR="$YAWS_ETCDIR" \
1f8b315 @vinoski make "rebar compile" install under the build dir
vinoski authored
60 ../scripts/gen-yaws-generated true >$tmpgen || fail
61a1116 @vinoski more build avoidance for rebar build
vinoski authored
61 keep_or_replace yaws_generated.erl $tmpgen
bedbc05 @tuncer add rebar support (Tuncer Ayaz and Steve Vinoski)
tuncer authored
62 [ -d "$YAWS_VARDIR" ] || mkdir "$YAWS_VARDIR" || fail
63 [ -d "$YAWS_ETCDIR" ] || mkdir "$YAWS_ETCDIR" || fail
64
65 cd ../scripts
66
1f8b315 @vinoski make "rebar compile" install under the build dir
vinoski authored
67 tmpgen=`mktemp /tmp/${script}.XXXXXX` || fail
68 VARDIR="${YAWS_VARDIR}" ERLBINDIR="${YAWS_ERLBINDIR}" \
69 ERL="${ERL_BIN}" WERL="${WERL_BIN}" ./gen-yaws > $tmpgen || fail
70 keep_or_replace ../bin/yaws $tmpgen
71 if [ $? -eq 0 ]; then
72 VARDIR="${YAWS_VARDIR}" ./local-install false "${YAWS_DIR}" || fail
73 else
74 chmod +x ../bin/yaws || fail
75 VARDIR="${YAWS_VARDIR}" ./local-install true "${YAWS_DIR}" || fail
76 fi
bedbc05 @tuncer add rebar support (Tuncer Ayaz and Steve Vinoski)
tuncer authored
77
78 exit 0
Something went wrong with that request. Please try again.