This repository was archived by the owner on Oct 26, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathpkg-config-deps
More file actions
executable file
·251 lines (234 loc) · 6.8 KB
/
Copy pathpkg-config-deps
File metadata and controls
executable file
·251 lines (234 loc) · 6.8 KB
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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
#!/bin/bash
# CDDL HEADER START
#
# This file and its contents are supplied under the terms of the
# Common Development and Distribution License ("CDDL"), version 1.0.
# You may only use this file in accordance with the terms of version
# 1.0 of the CDDL.
#
# A full copy of the text of the CDDL should have accompanied this
# source. A copy of the CDDL is also available via the Internet at
# http://www.illumos.org/license/CDDL.
#
# CDDL HEADER END
# Copyright 2021 Saso Kiselkov. All rights reserved.
# This file needs to be called from your makefile when using libacfutil.
# It produces the necessary cflags and libs to include all the build-time
# and link-time dependencies of libacfutils.
#
# You should invoke this script in one of the following two ways:
#
# 1) to generate CFLAGS:
# $ <path_to_libacfutils>/pkg-config-deps 'ARCH' --cflags
# 1) to generate LDFLAGS:
# $ <path_to_libacfutils>/pkg-config-deps 'ARCH' --libs
#
# Where 'ARCH' is should be one of: 'win-64', 'win-32', 'linux-64',
# 'linux-32' 'mac-64' and 'mac-32' (depending on the target being built for).
STATIC_OPENAL=0
TESSERACT=1
CAIRO=1
OPUS=1
SHAPELIB=1
GLEWMX=1
WHOLE_ARCH_ON=""
WHOLE_ARCH_OFF=""
LINK_ACFUTILS=1
OPENAL_VERSION="1.21.0"
cd "$(dirname "$0")"
ARCH="$1"
shift
if ! [ -f "openal-soft/openal-soft-$OPENAL_VERSION-$ARCH/build/install/lib/pkgconfig/openal.pc" ] &&
[ -f "openal-soft/openal-soft-1.19.1-$ARCH/build/install/lib/pkgconfig/openal.pc" ]; then
OPENAL_VERSION="1.19.1"
fi
# The order of arguments we pass to pkg-config is important. We must list
# dependencies FOLLOWING the dependents (so e.g. zlib AFTER libpng).
while [[ $# -gt 0 ]]; do
case "$1" in
--whole-archive)
if [[ "$(uname)" != Darwin ]]; then
WHOLE_ARCH_ON="-Wl,--whole-archive"
WHOLE_ARCH_OFF="-Wl,--no-whole-archive"
fi
;;
--static-openal)
if [ -f "openal-soft/openal-soft-$OPENAL_VERSION-$ARCH/build/install/lib/pkgconfig/openal.pc" ]; then
PACKAGES="$PACKAGES opusfile opus ogg openal"
STATIC_OPENAL=1
fi
;;
--glfw)
PACKAGES="$PACKAGES glfw3"
;;
--no-tesseract)
TESSERACT=0
;;
--no-cairo)
CAIRO=0
;;
--no-shapelib)
SHAPELIB=0
;;
--no-glewmx)
GLEWMX=0
;;
--no-link-acfutils)
LINK_ACFUTILS=0
;;
--openal-version=1.19.1)
OPENAL_VERSION="1.19.1"
;;
--no-libcurl)
NO_LIBCURL=1
;;
--no-openssl)
NO_OPENSSL=1
;;
--no-libxml2)
NO_LIBXML2=1
;;
--no-pcre2)
NO_PCRE2=1
;;
--no-libpng)
NO_LIBPNG=1
;;
--no-freetype)
NO_FREETYPE=1
;;
--no-libclipboard)
NO_LIBCLIPBOARD=1
;;
*)
break
;;
esac
shift
done
# Careful: the order of libraries mentioned here matters, they must be
# dependent-provider order, same as on the linker command line.
if ! [ -f .minimal-deps ]; then
if [[ "$TESSERACT" -ne 0 ]] &&
[ -f "ocr/tesseract-$ARCH/lib/pkgconfig/tesseract.pc" ]; then
PACKAGES="$PACKAGES tesseract lept"
fi
if [[ "$GLEWMX" -ne 0 ]]; then
PACKAGES="$PACKAGES glewmx"
fi
fi
if [ -f "geographiclib/geographiclib-${ARCH}/cmake/geographiclib.pc" ]; then
PACKAGES="$PACKAGES geographiclib"
fi
if [[ "$SHAPELIB" -ne 0 ]] && \
[ -f "shapelib/libshape-${ARCH}/lib/pkgconfig/shapelib.pc" ]; then
PACKAGES="$PACKAGES shapelib proj"
fi
if [[ "$CAIRO" -ne 0 ]] && [ -z "$NO_FREETYPE" ] && \
[ -f "cairo/cairo-${ARCH}/lib/pkgconfig/cairo.pc" ]; then
PACKAGES="$PACKAGES cairo pixman-1"
fi
if [ -z "$NO_LIBPNG" ] && \
[ -f "libpng/libpng-${ARCH}/lib/pkgconfig/libpng16.pc" ]; then
PACKAGES="$PACKAGES libpng16"
fi
if [ -z "$NO_FREETYPE" ] && \
[ -f "freetype/freetype-${ARCH}/lib/pkgconfig/freetype2.pc" ]; then
PACKAGES="$PACKAGES freetype2"
fi
if [ -z "$NO_OPENSSL" ]; then
if [ -z "$NO_LIBCURL" ]; then
PACKAGES="$PACKAGES libcurl"
fi
PACKAGES="$PACKAGES openssl"
fi
if [ -z "$DISABLE_LIBXML2" ]; then
PACKAGES="$PACKAGES libxml-2.0 libpcre2-8 zlib"
fi
if [ -z "$DISABLE_PCRE2" ]; then
PACKAGES="$PACKAGES libpcre2-8 zlib"
fi
PACKAGES="$PACKAGES zlib"
PKG_CONFIG_PATH="\
$(pwd)/opus/opusfile-$ARCH/lib/pkgconfig:\
$(pwd)/opus/opus-$ARCH/lib/pkgconfig:\
$(pwd)/opus/libogg-$ARCH/install/lib/pkgconfig:\
$(pwd)/freetype/freetype-$ARCH/lib/pkgconfig:\
$(pwd)/libpng/libpng-$ARCH/lib/pkgconfig:\
$(pwd)/zlib/zlib-$ARCH/lib/pkgconfig:\
$(pwd)/cairo/cairo-$ARCH/lib/pkgconfig:\
$(pwd)/cairo/pixman-$ARCH/lib/pkgconfig:\
$(pwd)/curl/libcurl-$ARCH/lib/pkgconfig:\
$(pwd)/shapelib/libproj-$ARCH/lib/pkgconfig:\
$(pwd)/shapelib/libshape-$ARCH/lib/pkgconfig:\
$(pwd)/ssl/openssl-$ARCH/lib/pkgconfig:\
$(pwd)/ssl/openssl-$ARCH/lib64/pkgconfig:\
$(pwd)/ocr/liblept-$ARCH/lib/pkgconfig:\
$(pwd)/ocr/tesseract-$ARCH/lib/pkgconfig:\
$(pwd)/libxml2/libxml2-$ARCH/lib/pkgconfig:\
$(pwd)/openal-soft/openal-soft-$OPENAL_VERSION-$ARCH/build/install/lib/pkgconfig:\
$(pwd)/pcre2/pcre2-$ARCH/lib/pkgconfig:\
$(pwd)/glfw/glfw-$ARCH/install/lib/pkgconfig:\
$(pwd)/geographiclib/geographiclib-$ARCH/cmake"
if [[ "$ARCH" == "linux-64" ]]; then
PKG_CONFIG_PATH="$PKG_CONFIG_PATH:\
$(pwd)/glew/glew-1.13.0-$ARCH/install/lib64/pkgconfig:\
$(pwd)/libclipboard/libclipboard-$ARCH/install/lib/pkgconfig"
if [ -z "$NO_LIBCLIPBOARD" ]; then
PACKAGES="$PACKAGES libclipboard"
fi
else
PKG_CONFIG_PATH="$PKG_CONFIG_PATH:\
$(pwd)/glew/glew-1.13.0-$ARCH/install/lib/pkgconfig"
fi
export PKG_CONFIG_PATH
if [[ "$1" = "--cflags" ]]; then
CGLM_EXTRA="-I$(pwd)/cglm/cglm-0.7.9/include"
PCRE2_EXTRA="-DPCRE2_CODE_UNIT_WIDTH=8"
if [[ "$ARCH" = "mac-64" ]]; then
GLEW_EXTRA="-DLACF_GLEW_USE_NATIVE_TLS=0"
fi
LIBICONV="-I$(pwd)/libiconv/libiconv-$ARCH/include"
ACFUTILS_EXTRA="-I$(pwd)/src"
elif [[ "$1" = "--libs" ]]; then
if [[ "$ARCH" = "win-64" ]]; then
# This must be appended AFTER --whole-archive, otherwise
# it produces linkage errors on Windows.
OPENSSL_EXTRA="-lcrypt32 -lws2_32 -lgdi32"
DBGEXTRA="-ldbghelp -lpsapi"
STACKPROT_EXTRA="-Wl,-Bstatic -lssp -Wl,-Bdynamic"
if [[ "$STATIC_OPENAL" = 1 ]]; then
OPENAL_EXTRA="-lole32"
fi
WINMM_EXTRA="-lwinmm"
WINBCRYPT_EXTRA="-lbcrypt"
elif [[ "$ARCH" = "mac-64" ]]; then
if [[ "$STATIC_OPENAL" = 1 ]]; then
OPENAL_EXTRA="-lstdc++"
fi
fi
if [ -f "$(pwd)/lzma/qmake/$ARCH/liblzma.a" ]; then
LZMA="-L$(pwd)/lzma/qmake/$ARCH -llzma"
fi
LIBICONV="-L$(pwd)/libiconv/libiconv-$ARCH/lib -liconv"
if [ "$LINK_ACFUTILS" -ne 0 ]; then
if [[ "$ARCH" == "win-64" ]]; then
ACFUTILS_EXTRA="-L$(pwd)/qmake/win64 -lacfutils"
elif [[ "$ARCH" == "mac-64" ]]; then
ACFUTILS_EXTRA="-L$(pwd)/qmake/mac64 -lacfutils"
else
ACFUTILS_EXTRA="-L$(pwd)/qmake/lin64 -lacfutils"
fi
fi
if [[ "$ARCH" = "mac-64" ]]; then
# Required for IPv6 support in libcurl
EXTRA="-framework SystemConfiguration"
else
EXTRA="-static-libstdc++"
fi
fi
echo $WHOLE_ARCH_ON ${ACFUTILS_EXTRA} ${LZMA} ${LIBICONV} \
$(pkg-config $@ $PACKAGES) \
$EXTRA $WHOLE_ARCH_OFF \
$OPENSSL_EXTRA $DBGEXTRA ${CGLM_EXTRA} ${PCRE2_EXTRA} ${OPENAL_EXTRA} \
${GLEW_EXTRA} ${STACKPROT_EXTRA} ${WINBCRYPT_EXTRA} ${WINMM_EXTRA}