-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathconfigure
executable file
·126 lines (115 loc) · 2.77 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
#! /usr/bin/env bash
#
# Create an includable Makefile containing the paths to the tree-sitter
# installation.
#
set -eu
default_prefix="$(pwd)"/tree-sitter
output_file_mk=tree-sitter-config.mk
output_file_sh=tree-sitter-config.sh
usage() {
cat <<EOF
Create an includable makefile and an includable shell script
containing variables giving the location of tree-sitter in the
system. Setting these values correctly is important if tree-sitter was
not installed in a standard location.
Output files: $output_file_mk, $output_file_sh
Default locations:
prefix: $default_prefix
bindir: \$prefix/bin
incdir: \$prefix/include
libdir: \$prefix/lib
Usage: ./configure [options]
Options:
--bindir DIR
Absolute path to the folder containing the 'tree-sitter' executable.
--help
Show this help message and exit.
--incdir DIR
Absolute path to the folder containing the C headers for the
tree-sitter library.
--libdir DIR
Absolute path to the folder containing the compiled tree-sitter
runtime library.
--prefix DIR
Set bindir, incdir, and libdir all at once, relative to this root
folder, which must be an absolute path.
EOF
}
update_derived_variables() {
bindir="$prefix"/bin
incdir="$prefix"/include
libdir="$prefix"/lib
}
prefix="$default_prefix"
update_derived_variables
while [[ $# -gt 0 ]]; do
case "$1" in
--bindir)
bindir="$2"
shift
;;
--help)
usage
exit 0
;;
--incdir)
incdir="$2"
shift
;;
--libdir)
libdir="$2"
shift
;;
--prefix)
prefix="$2"
update_derived_variables
shift
;;
*)
echo "Invalid argument to configure script: $1" >&2
echo "Try '--help'."
exit 1
esac
shift
done
cat > "$output_file_mk" <<EOF
# Generated by ./configure
#
# Absolute paths to the tree-sitter installation folders.
# This file is meant to be included in makefiles.
#
TREESITTER_BINDIR := $bindir
TREESITTER_INCDIR := $incdir
TREESITTER_LIBDIR := $libdir
PATH := \$(TREESITTER_BINDIR):\$(PATH)
PKG_CONFIG_PATH := \$(TREESITTER_LIBDIR)/pkgconfig:\$(PKG_CONFIG_PATH)
export TREESITTER_BINDIR
export TREESITTER_INCDIR
export TREESITTER_LIBDIR
export PATH
export PKG_CONFIG_PATH
EOF
cat > "$output_file_sh" <<EOF
# Generated by ./configure
#
# Absolute paths to the tree-sitter installation folders.
# This file is meant to be sourced in shell scripts as follows:
#
# source ./$output_file_sh
#
# or equivalently:
#
# . ./$output_file_sh
#
TREESITTER_BINDIR="$bindir"
TREESITTER_INCDIR="$incdir"
TREESITTER_LIBDIR="$libdir"
PATH=\$TREESITTER_BINDIR:\$PATH
PKG_CONFIG_PATH=\$TREESITTER_LIBDIR/pkgconfig:\$PKG_CONFIG_PATH
export TREESITTER_BINDIR
export TREESITTER_INCDIR
export TREESITTER_LIBDIR
export PATH
export PKG_CONFIG_PATH
EOF