Ticket #7344: spkg-install

File spkg-install, 2.3 KB (added by drkirkby, 12 years ago)
Line 
1#!/usr/bin/env bash
2###########################################
3## libjpeg 7
4###########################################
5
6if [ -z "$SAGE_LOCAL" ] ; then
7   echo "SAGE_LOCAL undefined ... exiting";
8   echo "Maybe run 'sage -sh'?"
9   exit 1
10fi
11
12# Use 'set -e' to exit on any errors we don't specifically test for
13# The error message wont be very helpful, but it will stop the build
14# continuting in the case of a failure.
15
16set -e
17
18# Add a sensible default optimisation flag. Change if necessary.
19OPTIMIZATION_FLAGS="-O2"
20
21# Most packages do not need all these set
22# But it is better to do them all each time, rather than ommit
23# a flag by mistake.
24
25CFLAGS="$CFLAGS $OPTIMIZATION_FLAGS "
26
27# It may be possible at a later date to remove the lines
28# CPPFLAGS="$CPPFLAGS -I$SAGE_LOCAL/include"
29# LDFLAGS="$LDFLAGS -L$SAGE_LOCAL/lib"
30# if it considered safe to add these generally to the environment
31# with sage-env. But the version of sage-env expected in Sage 4.3.1
32# as a result of ticket #7818 does not add $SAGE_LOCAL/include to
33# CPPFLAGS or $SAGE_LOCAL/lib to LDFLAGS. If it is considered
34# 100% safe to do this on all packages, then I'll add them
35# globally and these can be removed at a later date.
36
37CPPFLAGS="$CPPFLAGS -I$SAGE_LOCAL/include"
38LDFLAGS="$LDFLAGS -L$SAGE_LOCAL/lib"
39
40# Compile for 64-bit if SAGE64 is set to 'yes'
41# This MAY not not be necessary - it will need checking. I suspect the next
42# three lines can be removed, and not bother adding -m64 (in the case)
43# of GNU tools to LDFLAGS.
44if [ "x$SAGE64" = xyes  ] ; then
45   LDFLAGS="$LDFLAGS $CFLAG64"
46fi
47
48# These are all used by GNU to specify compilers.
49echo "Using CC=$CC"
50
51
52# Flags which may be set.
53echo "The following environment variables will be exported"
54echo "Using CFLAGS=$CFLAGS"
55echo "Using LDFLAGS=$LDFLAGS"
56echo "configure scripts and/or makefiles might override these later"
57echo " "
58
59export CFLAGS
60export LDFLAGS
61
62
63cd src
64
65: ${CP=cp}; CP="$CP -f"; export CP
66: ${MV=mv}; MV="$MV -f"; export MV
67: ${RM=rm}; RM="$RM -f"; export RM
68
69set +e
70
71./configure --prefix=$SAGE_LOCAL 
72if [ $? -ne 0 ]; then
73   echo "Failed to configure libjpeg ... exiting"
74   exit 1
75fi
76
77make
78if [ $? -ne 0 ]; then
79   echo "Failed to build libjpeg ... exiting"
80   exit 1
81fi
82
83make install
84if [ $? -ne 0 ]; then
85   echo "Failed to install libjpeg ... exiting"
86   exit 1
87fi