-
Notifications
You must be signed in to change notification settings - Fork 2
/
configure
executable file
·171 lines (157 loc) · 5.65 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
#!/bin/bash
#
# vim: ts=4:ft=sh
#
# Copyright (C) 2020-2022
#
# Øystein Schønning-Johansen <[email protected]>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
#
# 3. The names of the authors may not be used to endorse or promote
# products derived from this software without specific prior
# written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
# IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
projectname=npy_array
library=true
# Default values
prefix=/usr/local
debugsym=true
profilesym=false
shared=true
use_npz=true
for arg in "$@"; do
case "$arg" in
--prefix=*)
prefix=`echo ${arg%/} | sed 's/--prefix=//'`
;;
--enable-debug)
debugsym=true;;
--disable-debug)
debugsym=false;;
--enable-profile)
profilesym=true;;
--disable-profile)
profilesym=false;;
--enable-shared)
shared=true;;
--disable-shared)
shared=false;;
--enable-npz)
use_npz=true;;
--disable-npz)
use_npz=false;;
--help)
echo 'usage: ./configure [options]'
echo 'options:'
echo ' --prefix=<path>: installation prefix'
echo ' --enable-debug: include debug symbols (default on)'
echo ' --disable-debug: do not include debug symbols'
echo ' --enable-profile: include profile symbols (default off)'
echo ' --disable-profile: do not include profile symbols'
echo ' --enable-shared: build dynamic linked library. (default on)'
echo ' --disable-shared: build static linked library'
echo ' --enable-npz: build system with .npz features. (default on)'
echo ' --disable-npz: build system without .npz features.'
echo 'all invalid options are silently ignored'
exit 0
;;
esac
done
printf "Prefix set to ... %s\n" $prefix
printf "Looking for pkg-config... "
if command -v pkg-config &> /dev/null
then
printf "Yes, we have pkg-config!\n"
have_libzip=`pkg-config --exists libzip && echo "true" || echo "false"`
have_pkg_config=true
libzip_libs=`pkg-config --libs libzip`
libzip_cflags=`pkg-config --cflags libzip`
else
printf "No, we do not have pkg-config!\n"
# FIXME: There are some issues here: this requires gcc and an unix-like environment. What about icc, clang etc.? :-(
have_libzip=`echo "#include <zip.h>" | gcc -c -o /dev/null -Werror -xc - > /dev/null 2>/dev/null && echo "true" || echo "false"`
libzip_libs='-lzip'
fi
printf "Looking for libzip....... "
if ! $have_libzip; then
printf "No\n"
echo "WARNING: libzip library not found!"
echo "libzip is highly recommended and was not found on this system. Please install the libzip packet(s) for your system."
use_npz=false
else
printf "Yes, found libzip. "
if ! $use_npz; then
printf "But it will not be used!"
fi
printf "\n"
fi
#### Logic for finding pkg-config directory ####
if $have_pkg_config; then
pc_path=none
pc_paths=`pkg-config --variable pc_path pkg-config`
directories=$(echo $pc_paths | tr ":" "\n")
for d in $directories; do
if [ -d $d ]; then
pc_path=$d
break
fi
done;
if [ -z "${PKG_CONFIG_PATH}" ]; then
printf "Install path for pkg-config .pc files: %s\n" $pc_path
else
pc_path=${PKG_CONFIG_PATH}
printf "Install path for pkg-config .pc files: %s (PKG_CONFIG_PATH)\n" $pc_path
fi
fi
if [ ! -d $prefix ]; then
echo "WARNING: PREFIX directory ($prefix) not found. Make sure you really want"
echo "to install in $prefix, or rerun configure with --prefix option."
fi
#### Create the makefile ####
echo 'generating Makefile ...'
echo "target_lib = lib${projectname}" >Makefile
echo "PREFIX = $prefix" >>Makefile
if $debugsym; then
echo 'dbg = -g' >>Makefile
fi
if $profilesym; then
echo 'profile = -pg' >>Makefile
fi
echo "shared = $shared" >>Makefile
echo "use_npz = $use_npz" >>Makefile
if $use_npz; then
echo 'src = $(wildcard *.c)' >>Makefile
echo "LIBS = $libzip_libs" >>Makefile
echo "INCLUDE = $libzip_cflags" >>Makefile
else
echo 'src = npy_array.c' >>Makefile
fi
echo 'header_files = $(wildcard *.h)' >>Makefile
if $have_pkg_config; then
echo 'pkg_conf_pc = npy_array.pc' >>Makefile
echo "pkg_config_path = ${pc_path}" >>Makefile
fi
echo "include Makefile.in" >>Makefile
echo "configure done, type 'make' to build."