1#!/bin/bash
2
3# Builds lame for MMX/SSE testing
4
5# Copyright (C) 2003-2006 IBM
6#
7# This program is free software; you can redistribute it and/or
8# modify it under the terms of the GNU General Public License as
9# published by the Free Software Foundation; either version 2 of the
10# License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful, but
13# WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15# General Public License for more details.
16#
17# You should have received a copy of the GNU General Public License
18# along with this program; if not, write to the Free Software
19# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
20# 02111-1307, USA.
21
22source "$POUNDER_HOME/libpounder.sh"
23
24# Is it already installed?
25PROG=`which lame`
26if [ ! -z "$PROG" ]; then
27	exit 0
28fi
29
30# If we can't find nasm...
31NASM=`which nasm`
32if [ -z "$NASM" ]; then
33	# Build it so we can test MMX/SSE.
34	NASM_PKG=nasm-0.98.38
35	NASM_TAR="$NASM_PKG.tar.gz"
36
37	# Retrieve tarball
38	cd "$POUNDER_OPTDIR"
39	if [ ! -f "$NASM_TAR" ]; then
40        	if [ $USE_CACHE -eq 1 ]; then
41                	wget "${POUNDER_CACHE}${NASM_TAR}"
42        	fi
43        	if [ ! -f "$NASM_TAR" ]; then
44                	get_from_sourceforge nasm $NASM_TAR
45        	fi
46	fi
47
48	# Unpack if necessary
49	if [ ! -d "NASM_PKG" ]; then
50        	tar -xzf "$NASM_TAR"
51	fi
52
53	# Build
54	cd "$NASM_PKG"
55	./configure
56	make $*
57
58	export PATH=`/bin/ls -d $POUNDER_OPTDIR/nasm*/`:$PATH
59
60fi
61
62# Retrieve binary for lame, if necessary
63PKGNAME=lame-3.96.1
64TARNAME="$PKGNAME.tar.gz"
65PROGNAME=lame
66
67cd "$POUNDER_OPTDIR"
68if [ ! -f "$TARNAME" ]; then
69	if [ $USE_CACHE -eq 1 ]; then
70		wget "${POUNDER_CACHE}${TARNAME}"
71	fi
72	if [ ! -f "$TARNAME" ]; then
73		get_from_sourceforge $PROGNAME $TARNAME
74	fi
75fi
76
77# Unpack if necessary
78if [ ! -d "PKGNAME" ]; then
79	tar -xzf "$TARNAME"
80fi
81
82# Build with MMX/SSE/3dnow/whatever support
83cd "$PKGNAME"
84./configure --enable-nasm
85make $*
86
87# Now build schedutils for CPU affinity assignments
88_PKGNAME=schedutils-1.4.0
89S_TARNAME="$S_PKGNAME.tar.gz"
90S_PROGNAME=taskset
91
92# Is it already installed?
93S_PROG=`which $S_PROGNAME`
94if [ ! -z "$S_PROG" ]; then
95        exit 0
96fi
97
98# Does this OS support taskset?
99grep sched_setaffinity /usr/include/sched.h > /dev/null 2>&1
100if [ $? -ne 0 ]; then
101        # Can't find the sched_setaffinity syscall; abort.
102        # Probably we want to remove the schedutils dir in case
103        # this install was leftover from another distro.
104        cd "$POUNDER_OPTDIR"
105        rm -rf "$S_PKGNAME"
106        exit 0
107fi
108
109# Retrieve tarball, if necessary
110cd "$POUNDER_OPTDIR"
111if [ ! -f "$S_TARNAME" ]; then
112        if [ $USE_CACHE -eq 1 ]; then
113                wget "${POUNDER_CACHE}${S_TARNAME}"
114        fi
115        if [ ! -f "$S_TARNAME" ]; then
116                wget "http://tech9.net/rml/schedutils/packages/$VERSION/$S_TARNAME"
117        fi
118fi
119
120# Unpack if necessary
121if [ ! -d "S_PKGNAME" ]; then
122        tar -xzf "$S_TARNAME"
123fi
124
125# Build
126cd "$S_PKGNAME"
127make $*
128