-
Notifications
You must be signed in to change notification settings - Fork 15
/
configure
179 lines (156 loc) · 5.05 KB
/
configure
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
#!/bin/bash
# Copyright (C) 2003-2005 Daniel Muller, dan at verliba dot cz
# Copyright (C) 2006-2024 Verlihub Team, info at verlihub dot net
#
# Verlihub is free software; You can redistribute it
# and modify it under the terms of the GNU General
# Public License as published by the Free Software
# Foundation, either version 3 of the license, or at
# your option any later version.
#
# Verlihub is distributed in the hope that it will be
# useful, but without any warranty, without even the
# implied warranty of merchantability or fitness for
# a particular purpose. See the GNU General Public
# License for more details.
#
# Please see http://www.gnu.org/licenses/ for a copy
# of the GNU General Public License.
DEFAULT_PREFIX="/usr/local"
PREFIX=$DEFAULT_PREFIX
BUILD_TYPE="release"
BUILD_DIR="build"
LIB_DIR="lib"
PLUGIN_DIR=""
DEBUG=0
cd `dirname $0`
SRC_DIR="$PWD"
function print_help
{
echo "configure script for package VerliHub
Usage: ./configure [OPTION]
This is an emulation script of GNU ./configure to give compiling of
VerliHub a more familiar usage. Experienced users are free to use cmake
instead. This configure script should provide everything you need though.
Options:
-h, --help Display this help message and exit
Installation directories:
--prefix=PREFIX Install files in PREFIX. Default: $DEFAULT_PREFIX
--libdir=LIBDIR Install libs in PREFIX/LIBDIR. Default: $LIB_DIR
--plugindir=PLUGINDIR Install plugins in PREFIX/PLUGINDIR. Default equal to LIBDIR
Optional features:
--enable-debug-output Enable debugging output. Default to no
--build-dir=PATH Path to store the build files. Default: ./$BUILD_DIR
--build-type=TYPE Define the build configuration to use. Available values are:
release - standard release
relwithdebinfo - release with debug info
minsizerel - minimum size release
debug - debug build
debugfull - full debug build
After running ./configure, you can type 'make' to build this project."
exit
}
function run_cmake
{
# Check build type
case "$BUILD_TYPE" in
debugfull) DEBUG=1 ;;
release|relwithdebinfo|minsizerel|debug) ;;
*)
echo "$0: Invalid build type: $BUILD_TYPE" >&2
exit 1
;;
esac
# Make the directory
test -e "$BUILD_DIR" || mkdir "$BUILD_DIR" || exit 1
cd "$BUILD_DIR"
REAL_BUILD_DIR=`pwd`
# finally start cmake
cmake -D CMAKE_INSTALL_PREFIX=$PREFIX \
-D LIB_INSTALL_DIR=$LIB_DIR \
-D PLUGIN_INSTALL_DIR=$PLUGIN_DIR \
-D CMAKE_BUILD_TYPE=$BUILD_TYPE \
-D VERBOSE=$DEBUG \
"$SRC_DIR" \
&& cmake_ok || cmake_error
}
function cmake_error
{
echo "-- cmake failed
Please fix the problems mentioned above, and run ./configure again."
}
function cmake_ok
{
# create a makefile to redirect all calls to the build directory
makefile=$SRC_DIR/Makefile
targets=`grep '^[A-Za-z_\/\-]\+:' Makefile | cut -f 1 -d ':'`
echo "# Generated by ./configure: NO NOT EDIT!
# Build features:
#
# Install prefix: $PREFIX
# Debugging messages: $HAS_DEBUG
# Build type: $BUILD_TYPE
# Build directory: $BUILD_DIR
#
#
# cmake command:
#
# cd \"$REAL_BUILD_DIR\"
# cmake -D CMAKE_INSTALL_PREFIX=$PREFIX \\
# -D CMAKE_BUILD_TYPE=$BUILD_TYPE \\
# -D KMESS_DEBUG_OUTPUT=$DEBUG \\
# \"$SRC_DIR\"
#
" > $makefile
for target in $targets; do
echo "$target:" >> $makefile
echo -en "\t" >> $makefile
echo "@\$(MAKE) --no-print-directory -C '$BUILD_DIR' $target" >> $makefile
echo "" >> $makefile
done
}
# Parse arguments
if [ -n "$*" ]; then
# check against BSD / Mac OS getopt, which is seriously lacking.
# It does not support additional options, so it will recognize everything
# after --longoptions as the $@ input.
if ! getopt --longoptions --prefix -- "" 2>/dev/null >/dev/null; then
echo "$0: Sorry, can't handle arguments at this platform.
Your getopt version does not support long arguments.
Please run cmake directly:
mkdir build
cd build
cmake ..
" >&2
exit 1
fi
# Parse the arguments
longopts="help,prefix:,build-type:,build-dir:,build-folder:,enable-debug-output"
TEMP=`getopt --name=configure \
--options h \
--longoptions "$longopts" -- "$@"`
case "$?" in
0) ;;
*) exit 1 ;;
esac
eval set -- "$TEMP"
while true ; do
case "$1" in
-h|--help) print_help; exit 0 ;;
--prefix) PREFIX=$2; shift 2 ;;
--libdir) LIB_DIR=$2 shift 2 ;;
--plugindir) PLUGIN_DIR=$2 shift 2 ;;
--enable-debug-output) DEBUG=1; shift ;;
--build-type) BUILD_TYPE="$2"; shift 2 ;;
--build-dir) BUILD_DIR="$2"; shift 2 ;;
--builddir|--build-directory|--build-folder) BUILD_DIR="$2"; shift 2 ;; # be forgiving with small errors.
--) shift ; break ;;
*) echo "$0: internal error at argument '$1'!" ; exit 1 ;;
esac
done
if [ -n "$1" ]; then
echo "$0: invalid arguments: $@"
exit 1
fi
fi
run_cmake