From de54a267f3670cbb83391c83efc9afcaa514d1bb Mon Sep 17 00:00:00 2001 From: Jonathan Moore Liles Date: Sun, 8 Jun 2008 17:55:38 -0500 Subject: [PATCH] configure: Pull enhancements over from Non-DAW. --- Makefile | 53 ++++++------- configure | 6 +- scripts/config-funcs | 162 +++++++++++++++++++++++++++++++-------- scripts/percent-complete | 20 +++++ 4 files changed, 177 insertions(+), 64 deletions(-) create mode 100755 scripts/percent-complete diff --git a/Makefile b/Makefile index ac4fa0c..d431533 100644 --- a/Makefile +++ b/Makefile @@ -9,19 +9,24 @@ VERSION := 1.9.2 -all: make.conf non-sequencer +all: .config non-sequencer -make.conf: configure +.config: configure @ ./configure config: @ ./configure --include make.conf +-include .config SYSTEM_PATH=$(prefix)/share/non-sequencer/ DOCUMENT_PATH=$(prefix)/share/doc/non-sequencer/ +# a bit of a hack to make sure this runs before any rules +ifneq ($(CALCULATING),yes) +TOTAL := $(shell $(MAKE) CALCULATING=yes -n 2>/dev/null | sed -n 's/^.*Compiling: \([^"]\+\)"/\1/p' > .files ) +endif + ifeq ($(USE_DEBUG),yes) CXXFLAGS := -pipe -ggdb -Wall -Wextra -Wnon-virtual-dtor -Wno-missing-field-initializers -O0 -fno-rtti -fno-exceptions else @@ -44,31 +49,11 @@ endif # uncomment this line to print each playback event to the console (not RT safe) # CXXFLAGS+= -DDEBUG_EVENTS -SRCS= \ - canvas.C \ - debug.C \ - event.C \ - event_list.C \ - grid.C \ - gui/draw.C \ - gui/event_edit.C \ - gui/input.C \ - gui/ui.C \ - gui/widgets.C \ - instrument.C \ - jack.C \ - lash.C \ - main.C \ - mapping.C \ - midievent.C \ - pattern.C \ - phrase.C \ - scale.C \ - sequence.C \ - smf.C \ - transport.C +SRCS:=$(wildcard *.C gui/*.fl gui/*.C) -OBJS=$(SRCS:.C=.o) +SRCS:=$(SRCS:.fl=.C) +SRCS:=$(sort $(SRCS)) +OBJS:=$(SRCS:.C=.o) .PHONEY: all clean install dist valgrind config @@ -81,14 +66,20 @@ valgrind: include scripts/colors +ifneq ($(CALCULATING),yes) + COMPILING="$(BOLD)$(BLACK)[$(SGR0)$(CYAN)`scripts/percent-complete .files "$<"`$(SGR0)$(BOLD)$(BLACK)]$(SGR0) Compiling: $(BOLD)$(YELLOW)$<$(SGR0)" +else + COMPILING="Compiling: $<" +endif + .C.o: - @ echo "Compiling: $(BOLD)$(YELLOW)$<$(SGR0)" + @ echo $(COMPILING) @ $(CXX) $(CXXFLAGS) -c $< -o $@ %.C : %.fl @ cd `dirname $<` && fluid -c ../$< -$(OBJS): make.conf +$(OBJS): .config DONE:=$(BOLD)$(GREEN)done$(SGR0) @@ -118,8 +109,8 @@ dist: TAGS: $(SRCS) etags $(SRCS) -makedepend: make.conf $(SRCS) +.deps: .config $(SRCS) @ echo -n Calculating dependencies... - @ makedepend -f- -- $(CXXFLAGS) -- $(SRCS) > makedepend 2>/dev/null && echo "$(DONE)" + @ makedepend -f- -- $(CXXFLAGS) $(INCLUDES) -- $(SRCS) > makedepend 2>/dev/null && echo $(DONE) -include makedepend diff --git a/configure b/configure index 182b9d4..c7ba855 100755 --- a/configure +++ b/configure @@ -9,9 +9,9 @@ begin begin_options -ask "Install prefix?" prefix /usr/local -ask "Require LASH?" USE_LASH yes -ask "Build for debugging?" USE_DEBUG no +ask "Installation prefix" prefix /usr/local +ask "Use the LASH Audio Session Handler" USE_LASH yes +ask "Build for debugging" USE_DEBUG no begin_tests diff --git a/scripts/config-funcs b/scripts/config-funcs index 1b11a04..07c4586 100644 --- a/scripts/config-funcs +++ b/scripts/config-funcs @@ -7,47 +7,116 @@ # support functions for 'configure' scripts. - fatal () { echo "$BOLD$RED$*$SGR0" > /dev/stderr exit 255 } -[ $# -gt 0 ] && fatal "This is not an autoconf script. Run it without any options and you will be prompted." +UPDATE=no +HELP=no + +split () +{ + while [ $# -gt 0 ] + do + echo $1 + shift 1 + done +} + +if [ $# -gt 0 ] +then + case "$1" in + --update) + UPDATE=yes + shift 1 + ;; + --help) + HELP=yes + shift 1 + ;; + *) +# fatal "This is not an autoconf script. Run it without any options and you will be prompted." + ;; + esac + + if [ $# -gt 0 ] + then + echo "## options" > .config + + split "$@" | sed ' +s/--\(enable\|disable\)-\([^ =]\+\)/--\1-\U\2/g; +s/--enable-\([^ =]\+\)=\(.*\)/USE_\1=\2/g; +s/--enable-\([^ =]\+\)/USE_\1=yes/g; +s/--disable-\([^ =]\+\)/USE_\1=no/g; +s/--\([^ =]\+\)/\1/g; +' | sed -n '/^[^ =]\+=./p' >> .config + UPDATE=yes; + fi +fi + +if [ $HELP != yes ] && [ $UPDATE != yes ] +then + if ! ( [ -t 0 ] && [ -t 1 ] ) + then + fatal "not a terminal!" + fi +fi ask () { - local A D + local A D O - D="`eval echo \\$$2`" - D=${D:-$3} + D="`eval echo \\$$2`" + D=${D:-$3} - echo -n "$BLACK$BOLD::$SGR0 $1 [$BOLD${D}$SGR0] " - read A - A=${A:-$D} + if [ $HELP = yes ] + then + if [ "$3" = yes ] || [ "$3" = no ] + then + O=`echo -n "$2" | sed s/^USE_/--enable-/ | tr '[[:upper:]]' '[[:lower:]]'` + else + O=`echo -n "--$2" | tr '[[:upper:]]' '[[:lower:]]'` + fi - if [ "$3" = yes ] || [ "$3" = no ] - then - case "$A" in - no | n | N) A=no ;; - yes | y | Y) A=yes ;; - * ) fatal "Invalid response. Must be 'yes' or 'no'" ;; - esac - fi + printf " ${BOLD}${GREEN}%-15s${SGR0}\t%-40s (currently: ${BOLD}%s${SGR0})\n" "$O" "$1" "$D" - append "${2}=${A:-$D}" + return + fi + + echo -n "$BLACK$BOLD::$SGR0 ${1}? [$BOLD${D}$SGR0] " + + if [ $UPDATE = yes ] + then + A="$D" + echo + else + read A + A=${A:-$D} + fi + + if [ "$3" = yes ] || [ "$3" = no ] + then + case "$A" in + no | n | N) A=no ;; + yes | y | Y) A=yes ;; + * ) fatal "Invalid response. Must be 'yes' or 'no'" ;; + esac + fi + + append "${2}=${A:-$D}" } ok () { - echo "$BOLD${GREEN}ok${SGR0}" + echo -e '\r'`tput cuf 30`"$BOLD${GREEN}ok${SGR0} ${*:+${BOLD}${BLACK}($*)${SGR0}}" } failed () { echo "$BOLD${RED}failed!${SGR0}" > /dev/stderr - rm -f make.conf + rm -f .config } using () @@ -66,7 +135,7 @@ extract_options () { local line name value - if [ -f make.conf ] + if [ -f .config ] then { while read line @@ -85,7 +154,7 @@ extract_options () eval "$name='$value'" fi done - } < make.conf + } < .config fi } @@ -93,36 +162,69 @@ begin () { echo -n "Checking sanity..." require_command pkg-config pkg-config > /dev/null + require_command sed sed > /dev/null ok } +warn () +{ + echo " ${BOLD}${YELLOW}* ${SGR0}$*" +} + +info () +{ + echo "${BOLD}${CYAN}--- ${SGR0}$*" +} + begin_options () { # get the old values extract_options - echo > make.conf - append "# This file was automatically generated on `date`. Any changes may be lost!" - append "## options" + if [ $HELP = yes ] + then + echo + warn "This is a ${BOLD}non-configure${SGR0} script. Run without any arguments and you will be prompted" + warn "with configuration choices. Alternatively, you may use the following autoconf style" + warn "arguments for non-interactive configuration." + echo + echo " Available options:" + echo + else + echo > .config + append "# This file was automatically generated on `date`. Any changes may be lost!" + append "## options" - echo "--- Configuration required ---" + if [ $UPDATE = yes ] + then + info "Updating configuration" + else + info "Configuration required" + fi + fi } begin_tests () { + if [ $HELP = yes ] + then + echo + exit 0; + fi + append "## libs" extract_options } append () { - echo "$1" >> make.conf + echo "$1" >> .config } end () { - echo "--- Configuration complete ---" - touch make.conf + info "Configuration complete" + touch .config } require_command () @@ -157,7 +259,7 @@ require_package () append "${name}_LIBS=`pkg-config --libs $3`" append "${name}_CFLAGS=-DHAVE_${1} `pkg-config --cflags $3`" - ok + ok `pkg-config --modversion "$3"` return 0 } @@ -197,7 +299,7 @@ require_FLTK () failed fatal "The installed FLTK version ($FLTK_VERSION) is too old." else - ok + ok $FLTK_VERSION fi use= diff --git a/scripts/percent-complete b/scripts/percent-complete new file mode 100755 index 0000000..31b2c6c --- /dev/null +++ b/scripts/percent-complete @@ -0,0 +1,20 @@ +#!/bin/sh + +# May 2008 Jonathan Moore Liles +# +# Given the name of a file containing a list of files and a filename +# from that list, return the percentage of the distance from the +# beginning of the list. + +[ $# -ne 2 ] && exit + +MATCH="`grep -nFx \"$2\" \"$1\"`" +MATCH=${MATCH%%:*} +TOTAL="`cat \"$1\" | wc -l`" + +if [ -z "$MATCH" ] +then + echo "0%" +else + printf "%3s%%" $(( $MATCH * 100 / $TOTAL )) +fi \ No newline at end of file