Move helper functions out of 'configure' script.

pull/3/head
Jonathan Moore Liles 2008-05-17 21:44:47 -05:00
parent 60132b8595
commit 117d7cf9f7
5 changed files with 155 additions and 106 deletions

View File

@ -22,7 +22,7 @@ else
CXXFLAGS := -pipe -O3 -fno-rtti -fno-exceptions -DNDEBUG
endif
CXXFLAGS += $(LASH_CFLAGS) $(FLTK_CFLAGS) -DINSTALL_PREFIX=\"$(prefix)\" -DVERSION=\"$(VERSION)\"
CXXFLAGS += $(libsndfile_CFLAGS) $(LASH_CFLAGS) $(FLTK_CFLAGS) -DINSTALL_PREFIX=\"$(prefix)\" -DVERSION=\"$(VERSION)\"
include scripts/colors

View File

@ -32,7 +32,7 @@ LASH_Client::~LASH_Client ( )
/* TODO: anything? */
}
#ifdef USE_LASH
#ifdef HAVE_LASH
#include <lash/lash.h>

View File

@ -43,7 +43,7 @@ Timeline_OBJS:=$(Timeline_SRCS:.C=.o)
# $(Timeline_OBJS): Makefile
# $(Timeline_OBJS): make.conf
Timeline_LIBS := $(FLTK_LIBS) $(JACK_LIBS) $(SNDFILE_LIBS) $(LASH_LIBS)
Timeline_LIBS := $(FLTK_LIBS) $(JACK_LIBS) $(libsndfile_LIBS) $(LASH_LIBS)
Timeline/timeline: $(Timeline_OBJS) FL
@ echo -n Linking timeline...

114
configure vendored
View File

@ -1,119 +1,27 @@
#!/bin/sh
#
# Copyright (C) 2008 Jonathan Moore Liles
#
# This file is licensed under version 2 of the GPL.
. scripts/colors
fatal ()
{
echo "$BOLD$RED$*$SGR0"
exit 255
}
ask ()
{
echo -n "$1 [$BOLD$3$SGR0] "
read R
echo "${2}=${R:-$3}" >> make.conf
}
ok ()
{
echo "$BOLD${GREEN}ok${SGR0}."
}
failed ()
{
echo "$BOLD${RED}failed!${SGR0}"
rm -f make.conf
}
. scripts/config-funcs
[ $# -gt 0 ] && fatal "This is not an autoconf script. Run it without any options and you will be prompted."
echo "-- Configuration:"
begin
# get the old values
if [ -f make.conf ]
then
OIFS="$IFS"
IFS=''
eval "`sed -n '/^## options/{ : i; /^## libs/{ q }; p; n; b i }' make.conf`"
IFS="$OIFS"
fi
echo "# This is a generated file. Any changes may be lost!" > make.conf
echo "## options" >> make.conf
begin_options
ask "Install prefix?" prefix ${prefix:-/usr/local}
ask "Use LASH?" USE_LASH ${USE_LASH:-yes}
ask "Build for debugging?" MAINTAINER_MODE ${MAINTAINER_MODE:-no}
echo "## libs/flags" >> make.conf
begin_tests
# tests
require_FLTK 1 1 7
require_command FLUID fluid
require_package JACK 0.103.0 jack
require_package libsndfile 1.0.17 sndfile
echo -n "Checking for ${BOLD}FLTK${SGR0}..."
[ $USE_LASH = yes ] && require_package LASH 0.5.4 lash-1.0
FLTK_VERSION=`fltk-config --version`
FLTK_VERSION_MAJOR=`echo $FLTK_VERSION | cut -d'.' -f1`
FLTK_VERSION_MINOR=`echo $FLTK_VERSION | cut -d'.' -f2`
FLTK_VERSION_PATCH=`echo $FLTK_VERSION | cut -d'.' -f3`
if ! ( [ $FLTK_VERSION_MAJOR -ge 1 ] && [ $FLTK_VERSION_MINOR -ge 1 ] && [ $FLTK_VERSION_PATCH -ge 7 ] )
then
failed
fatal "The installed FLTK version ($FLTK_VERSION) is too old."
else
ok
fi
echo "FLTK_LIBS=`fltk-config --use-images --ldflags`" >> make.conf
echo "FLTK_CFLAGS=`fltk-config --cflags`" >> make.conf
check_command ()
{
echo -n "Checking for ${BOLD}$1${SGR0}..."
if ! [ -x "`which $2`" ]
then
failed
fatal "Command $1 not found."
else
ok
fi
}
check_command FLUID fluid
#
check ()
{
echo -n "Checking for $BOLD$1$SGR0..."
if ! pkg-config --exists $3
then
failed
fatal "Required package $1 doesn't appear to be installed."
elif ! pkg-config --atleast-version $2 $3
then
failed
fatal "The installed version of $1 (`pkg-config --mod-version $3`) is too old."
fi
ok
return 0
}
check JACK 0.103.0 jack && echo "JACK_LIBS=`pkg-config --libs jack`" >> make.conf
check libSNDFILE 1.0.17 sndfile && echo "SNDFILE_LIBS=`pkg-config --libs sndfile`" >> make.conf
grep -q 'USE_LASH=yes' make.conf &&
check LASH 0.5.4 lash-1.0 &&
( echo "LASH_LIBS=`pkg-config --libs lash-1.0`" >> make.conf
echo "LASH_CFLAGS=-DUSE_LASH `pkg-config --cflags lash-1.0`" >> make.conf )
echo "-- Configuration complete."
end

141
scripts/config-funcs Normal file
View File

@ -0,0 +1,141 @@
#!/bin/sh
#
# Copyright (C) 2008 Jonathan Moore Liles
# This file is licensed under version 2 of the GPL.
. scripts/colors
# support functions for 'configure' scripts.
fatal ()
{
echo "$BOLD$RED$*$SGR0" > /dev/stderr
exit 255
}
ask ()
{
local answer default
default="`eval echo \\$$2`"
default=${default:-$3}
echo -n "$BLACK$BOLD::$SGR0 $1 [$BOLD$3$SGR0] "
read answer
echo "${2}=${answer:-$default}" >> make.conf
}
ok ()
{
echo "$BOLD${GREEN}ok${SGR0}."
}
failed ()
{
echo "$BOLD${RED}failed!${SGR0}" > /dev/stderr
rm -f make.conf
}
extract_options ()
{
local OIFS
if [ -f make.conf ]
then
OIFS="$IFS"
IFS=''
eval "`sed -n '/^## options/{ : i; /^## libs/{ q }; p; n; b i }' make.conf`"
IFS="$OIFS"
fi
}
begin ()
{
echo -n "Checking sanity..."
require_command pkg-config pkg-config > /dev/null
require_command sed sed > /dev/null
ok
}
begin_options ()
{
# get the old values
extract_options
echo "# This is a generated file. Any changes may be lost!" > make.conf
echo "## options" >> make.conf
echo "--- Configuration required ---"
}
begin_tests ()
{
echo "## libs/flags" >> make.conf
extract_options
}
append ()
{
echo "$1" >> make.conf
}
end ()
{
echo "--- Configuration complete ---"
}
require_command ()
{
echo -n "Checking for ${BOLD}$1${SGR0}..."
if ! [ -x "`which $2`" ]
then
failed
fatal "Command $1 not found."
else
ok
fi
}
require_package ()
{
echo -n "Checking for $BOLD$1$SGR0..."
if ! pkg-config --exists $3
then
failed
fatal "Required package $1 doesn't appear to be installed."
elif ! pkg-config --atleast-version $2 $3
then
failed
fatal "The installed version of $1 (`pkg-config --mod-version $3`) is too old."
fi
append "${1}_LIBS=`pkg-config --libs $3`"
append "${1}_CFLAGS=-DHAVE_${1} `pkg-config --cflags $3`"
ok
return 0
}
require_FLTK ()
{
echo -n "Checking for ${BOLD}FLTK${SGR0}..."
FLTK_VERSION=`fltk-config --version`
FLTK_VERSION_MAJOR=`echo $FLTK_VERSION | cut -d'.' -f1`
FLTK_VERSION_MINOR=`echo $FLTK_VERSION | cut -d'.' -f2`
FLTK_VERSION_PATCH=`echo $FLTK_VERSION | cut -d'.' -f3`
if ! ( [ $FLTK_VERSION_MAJOR -ge $1 ] && [ $FLTK_VERSION_MINOR -ge $2 ] && [ $FLTK_VERSION_PATCH -ge $3 ] )
then
failed
fatal "The installed FLTK version ($FLTK_VERSION) is too old."
else
ok
fi
append "FLTK_LIBS=`fltk-config --use-images --ldflags`"
append "FLTK_CFLAGS=`fltk-config --cflags`"
}