summaryrefslogtreecommitdiff
path: root/acprep
blob: f6e8bf89d9d72951dc1004ad51cc5746fa1a1135 (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
133
134
135
136
137
138
139
140
141
142
143
144
#!/bin/sh

# acprep, version 3.0
#
# This script configures my ledger source tree on my Mac OS/X machine.
# This is not necessary, however, since I keep all the files necessary
# for building checked in to the source tree.  Users can just type
# './configure && make'.  This script simply sets up the compiler and
# linker flags for all the various build permutations I use for testing
# and profiling.

export AUTOCONF_VERSION=2.61
export AUTOMAKE_VERSION=1.9

touch AUTHORS COPYING

cmd=$(which glibtoolize 2>&1)
if [ -x "$cmd" ]; then
    export LIBTOOLIZE="$cmd"
fi

cat configure.tmpl | sed "s/%VERSION%/$(git describe)/" > configure.in

autoreconf --force --install

INCDIRS="-I/sw/include -I/opt/local/include"
INCDIRS="$INCDIRS -I/usr/local/include"
INCDIRS="$INCDIRS -I/usr/local/include/boost-1_35"

LIBDIRS="-L/sw/lib -L/opt/local/lib"
LIBDIRS="$LIBDIRS -L/usr/local/lib"

PYTHON_HOME="/usr"


SYSTEM=`uname -s`

if [ $SYSTEM = Linux ]; then
    CXXFLAGS="-pthread"
elif [ $SYSTEM = Solaris ]; then
    CXXFLAGS="-pthreads"
elif [ $SYSTEM = Darwin ]; then
    #CXXFLAGS="-arch i386 -arch ppc -isysroot /Developer/SDKs/MacOSX10.4u.sdk"
    CXXFLAGS="$CXXFLAGS -Wno-long-double"
    #LIBDIRS="$LIBDIRS -arch i386 -arch ppc -isysroot /Developer/SDKs/MacOSX10.4u.sdk"
else
    CXXFLAGS=""
fi

# Building the command-line tool as a shared library is a luxury,
# since there are no clients except a GUI tool which might use it (and
# that is built again anyway by Xcode).
SWITCHES=""
CPPFLAGS="$INCDIRS"
CXXFLAGS="-pipe"
LDFLAGS="$LIBDIRS"
LOCAL=false

# Warning flags
CXXFLAGS="$CXXFLAGS -Wall -ansi -Winvalid-pch"
#CXXFLAGS="$CXXFLAGS -Wextra"
#CXXFLAGS="$CXXFLAGS -Weffc++"
#CXXFLAGS="$CXXFLAGS -Wcast-align"
#CXXFLAGS="$CXXFLAGS -Wcast-qual"
#CXXFLAGS="$CXXFLAGS -Wconversion"
#CXXFLAGS="$CXXFLAGS -Wfloat-equal"
#CXXFLAGS="$CXXFLAGS -Wmissing-field-initializers"
#CXXFLAGS="$CXXFLAGS -Wno-endif-labels"
#CXXFLAGS="$CXXFLAGS -Wold-style-cast"
#CXXFLAGS="$CXXFLAGS -Woverloaded-virtual"
#CXXFLAGS="$CXXFLAGS -Wshorten-64-to-32"
#CXXFLAGS="$CXXFLAGS -Wsign-compare"
#CXXFLAGS="$CXXFLAGS -Wsign-promo"
#CXXFLAGS="$CXXFLAGS -Wstrict-null-sentinel"
#CXXFLAGS="$CXXFLAGS -Wwrite-strings"


while [ -n "$1" ]; do
  case "$1" in
    --devel)
	#SWITCHES="$SWITCHES --disable-shared --enable-pch"
	SWITCHES="$SWITCHES --disable-shared"
	CPPFLAGS="$CPPFLAGS -DBOOST_MULTI_INDEX_ENABLE_INVARIANT_CHECKING=1"
	CPPFLAGS="$CPPFLAGS -DBOOST_MULTI_INDEX_ENABLE_SAFE_MODE=1"
	;;

    --debug)
	SWITCHES="$SWITCHES --enable-debug"
	#CPPFLAGS="$CPPFLAGS -D_GLIBCXX_DEBUG=1"
	CXXFLAGS="$CXXFLAGS -g" ;;

    --boost)
	shift 1
	SWITCHES="$SWITCHES --with-boost-suffix=$1"
	;;

    --gcov)
	CXXFLAGS="$CXXFLAGS -fprofile-arcs -ftest-coverage" ;;

    --gprof)
        CXXFLAGS="$CXXFLAGS -g -pg" ;;

    --python)
	if [ -d "$PYTHON_HOME" ]; then
	    SWITCHES="$SWITCHES --enable-python"
	    CPPFLAGS="$CPPFLAGS -I$PYTHON_HOME/include/python2.5"
	    LDFLAGS="$LDFLAGS -L$PYTHON_HOME/lib/python2.5/config"
	fi ;;

    --pic)
	CXXFLAGS="$CXXFLAGS -fPIC" ;;

    --opt)
	CXXFLAGS="$CXXFLAGS -fomit-frame-pointer -O3" ;;

    --local)
	LOCAL=true ;;

    *)
	break ;;
  esac
  shift 1
done


HERE="$PWD"

if [ "$LOCAL" = "false" -a -d "$HOME/Products" ]; then
    version=""
    if [ -x version ]; then
	version="-$(./version)"
    fi
    projdir="$HOME/Products/$(basename $HERE)"
    rm -fr ${projdir}*
    projdir="$projdir$version"
    if [ ! -d "$projdir" ]; then
	mkdir -p "$projdir"
    fi
    cd "$projdir" || (echo "Cannot change to $projdir"; exit 1)
fi

"$HERE/configure" --srcdir="$HERE" CXX="$CXX" \
    CPPFLAGS="$CPPFLAGS" CXXFLAGS="$CXXFLAGS $local_cxxflags" \
    LDFLAGS="$LDFLAGS" LIBS="$LIBS" $SWITCHES "$@"