blob: 7110bd0b6d867c84bef8f182d14e03f34b27c38c [file] [log] [blame]
w.dengc6bcc0a2025-08-13 17:39:36 +08001#!/bin/bash
2
3# Wrapper around cmake to emulate useful options
4# from the previous autoconf-based configure script.
5
6RUNDIR=$(dirname "$0")
7RUNDIR=$(cd "$RUNDIR" && pwd)
8CURDIR=$(pwd)
9
10FLAGS=()
11
12usage()
13{
14 exitval="$1"
15 errmsg="$2"
16
17 if [ $exitval -ne 0 ] ; then
18 exec 1>&2
19 fi
20 if [ ! -z "$errmsg" ] ; then
21 echo "ERROR: $errmsg" 1>&2
22 fi
23 cat <<EOF
24$0 [<configure_options>] [-- [<cmake options>]]
25 --prefix=PREFIX install architecture-independent files in PREFIX
26 --enable-threading Enable code to support partly multi-threaded use
27 --enable-rdrand Enable RDRAND Hardware RNG Hash Seed generation on
28 supported x86/x64 platforms.
29 --enable-shared build shared libraries [default=yes]
30 --enable-static build static libraries [default=yes]
31 --disable-Bsymbolic Avoid linking with -Bsymbolic-function
32 --disable-werror Avoid treating compiler warnings as fatal errors
33 --disable-extra-libs Avoid linking against extra libraries, such as libbsd
34
35EOF
36 exit
37}
38
39if [ "$CURDIR" = "$RUNDIR" ] ; then
40 usage 1 "Please mkdir some other build directory, and run this script from there."
41fi
42
43if ! cmake --version ; then
44 usage 1 "Unable to find a working cmake, please be sure you have it installed and on your PATH"
45fi
46
47while [ $# -gt 0 ] ; do
48 case "$1" in
49 -h|--help)
50 usage 0
51 ;;
52 --prefix)
53 FLAGS+=(-DCMAKE_INSTALL_PREFIX="$2")
54 shift
55 ;;
56 --prefix=*)
57 FLAGS+=(-DCMAKE_INSTALL_PREFIX="${1##--prefix=}")
58 ;;
59 --enable-threading)
60 FLAGS+=(-DENABLE_THREADING=ON)
61 ;;
62 --enable-rdrand)
63 FLAGS+=(-DENABLE_RDRAND=ON)
64 ;;
65 --enable-shared)
66 FLAGS+=(-DBUILD_SHARED_LIBS=ON)
67 ;;
68 --disable-shared)
69 FLAGS+=(-DBUILD_SHARED_LIBS=OFF)
70 ;;
71 --enable-static)
72 FLAGS+=(-DBUILD_STATIC_LIBS=ON)
73 ;;
74 --disable-static)
75 FLAGS+=(-DBUILD_STATIC_LIBS=OFF)
76 ;;
77 --disable-Bsymbolic)
78 FLAGS+=(-DDISABLE_BSYMBOLIC=ON)
79 ;;
80 --disable-werror)
81 FLAGS+=(-DDISABLE_WERROR=ON)
82 ;;
83 --disable-extra-libs)
84 FLAGS+=(-DDISABLE_EXTRA_LIBS=ON)
85 ;;
86 --)
87 shift
88 break
89 ;;
90 -*)
91 usage 1 "Unknown arguments: $*"
92 ;;
93 *)
94 break
95 ;;
96 esac
97 shift
98done
99
100exec cmake "${FLAGS[@]}" "$@" "${RUNDIR}"