summaryrefslogtreecommitdiff
path: root/Build/source/texk/gregorio/gregorio-src/build.sh
blob: da98af69de22194952eba4c4d8305cc7754f1444 (plain)
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
#!/usr/bin/env bash
#
# Public Domain
#
# new script to build gregorio binaries (inspired from LuaTeX's one).
# ----------
# Options:
#      --mingw     : crosscompile for mingw32 from i-386linux
#      --warn      : enables all sorts of warnings
#      --host=     : target system for mingw32 cross-compilation
#      --build=    : build system for mingw32 cross-compilation
#      --arch=     : crosscompile for ARCH on OS X
#      --jobs=     : the number of jobs to run simultaneously in the make step
#      --force=    : force autoreconf
#      {other)     : anything else is passed to configure verbatim
      
# try to find bash, in case the standard shell is not capable of
# handling the generated configure's += variable assignments
if which bash >/dev/null
then
 CONFIG_SHELL=`which bash`
 export CONFIG_SHELL
fi

# try to find gnu make; we may need it
MAKE=make
if make -v 2>&1| grep "GNU Make" >/dev/null
then
  echo "Your make is a GNU-make; I will use that"
elif gmake -v >/dev/null 2>&1
then
  MAKE=gmake
  export MAKE
  echo "You have a GNU-make installed as gmake; I will use that"
else
  echo "I can't find a GNU-make; I'll try to use make and hope that works." 
  echo "If it doesn't, please install GNU-make."
fi

WARNINGS=yes
MINGWCROSS=FALSE
CONFHOST=
CONFBUILD=
MACCROSS=FALSE
MAKEOPTS=
OTHERARGS=
FORCE_AUTORECONF=

until [ -z "$1" ]; do
  case "$1" in
    --mingw     ) MINGWCROSS=TRUE ;;
    --host=*    ) CONFHOST="$1" ;;
    --build=*   ) CONFBUILD="$1" ;;
    --arch=*    ) MACCROSS=TRUE; ARCH=`echo $1 | sed 's/--arch=\(.*\)/\1/' ` ;;
    -j*|--jobs=*) MAKEOPTS="$MAKEOPTS $1" ;;
    --force=autoreconf) FORCE_AUTORECONF=TRUE ;;
    *           ) OTHERARGS="$OTHERARGS $1" ;;
  esac
  shift
done

B=build

ARCHFLAGS=

if [ "$MINGWCROSS" = "TRUE" ]
then
  MINGWBUILD=$HOSTTYPE-$OSTYPE
  MINGWSTR=mingw32
  if [ -d /usr/mingw32 ]; then
    MINGWSTR=mingw32
  elif [ -d /usr/i386-mingw32msvc ]; then
      MINGWSTR=i386-mingw32msvc
  elif [ -d /usr/i586-mingw32msvc ]; then
        MINGWSTR=i586-mingw32msvc
  fi
  OLDPATH=$PATH
  PATH=/usr/$MINGWSTR/bin:$PATH
  CFLAGS="-mtune=pentiumpro -msse2 -g -O2 $CFLAGS"
  LDFLAGS="-Wl,--large-address-aware $CFLAGS"
  ARCHFLAGS="--target=\"$MINGWSTR\" \
    --with-gnu-ld \
    --host=$MINGWSTR \
    --build=$MINGWBUILD \
    --prefix=/usr/$MINGWSTR"
elif [ "$MACCROSS" = "TRUE" ]
then
  # make sure that architecture parameter is valid
  case $ARCH in
    i386 | x86_64 | ppc | ppc64 ) ;;
    * ) echo "ERROR: architecture $ARCH is not supported"; exit 1;;
  esac
  ARCHFLAGS="$ARCHFLAGS"
  CFLAGS="-arch $ARCH -g -O2 $CFLAGS"
  LDFLAGS="-arch $ARCH $LDFLAGS" 
fi


export CFLAGS LDFLAGS

function die {
	echo "Failed to $1."
	exit 1
}

if [ "$FORCE_AUTORECONF" = "TRUE" -o ! -e Makefile.in ]
then
  echo "Creating build files using Autotools"
  autoreconf -f -i || die "create build files"
  echo
fi

CONFIGURE_ARGS="$CONFHOST $CONFBUILD $ARCHFLAGS $OTHERARGS"
echo "Configuring build files; options: $CONFIGURE_ARGS"
./configure $CONFIGURE_ARGS || die "configure Gregorio"
echo

echo "Building Gregorio; options:$MAKEOPTS"
${MAKE} ${MAKEOPTS} all doc || die "build Gregorio"
echo

if [ "$MINGWCROSS" = "TRUE" ]
then
  PATH=$OLDPATH
fi

echo "Build complete.  Next, you may want to run ./install.sh to install."
echo
echo "Depending on installation directory, you probably need to run"
echo "./install.sh using sudo or as root."

exit 0