-
Notifications
You must be signed in to change notification settings - Fork 558
/
build_tarballs.jl
129 lines (115 loc) · 4.79 KB
/
build_tarballs.jl
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
# Note that this script can accept some limited command-line arguments, run
# `julia build_tarballs.jl --help` to see a usage message.
using BinaryBuilder, Pkg
name = "GDAL"
upstream_version = v"3.4.1"
version_offset = v"0.0.0"
version = VersionNumber(upstream_version.major * 100 + version_offset.major,
upstream_version.minor * 100 + version_offset.minor,
upstream_version.patch * 100 + version_offset.patch)
# Collection of sources required to build GDAL
sources = [
ArchiveSource("https://github.com/OSGeo/gdal/releases/download/v$upstream_version/gdal-$upstream_version.tar.gz",
"e360387bc25ec24940f46afbeada48002d72c74aaf9eccf2a40e8d74e711a2e4"),
DirectorySource("./bundled"),
]
# Bash recipe for building across all platforms
script = raw"""
cd $WORKSPACE/srcdir/gdal-*/
if [[ ${target} == *mingw* ]]; then
export LDFLAGS="-L${libdir}"
# Apply patch to customise PROJ library
atomic_patch -p1 "$WORKSPACE/srcdir/patches/configure_ac_proj_libs.patch"
autoreconf -vi
export PROJ_LIBS="proj_8_2"
elif [[ "${target}" == *-linux-* ]]; then
# Hint to find libstdc++, required to link against C++ libs when using C compiler
if [[ "${nbits}" == 32 ]]; then
export CFLAGS="-Wl,-rpath-link,/opt/${target}/${target}/lib"
else
export CFLAGS="-Wl,-rpath-link,/opt/${target}/${target}/lib64"
fi
# Use same flags also for GEOS
atomic_patch -p1 "$WORKSPACE/srcdir/patches/geos-m4-extra-cflags.patch"
export EXTRA_GEOS_CFLAGS="${CFLAGS}"
if [[ "${target}" == powerpc64le-* ]]; then
atomic_patch -p1 "$WORKSPACE/srcdir/patches/sqlite3-m4-extra-libs.patch"
export EXTRA_GEOS_LIBS="${EXTRA_GEOS_LIBS} -lm"
export EXTRA_SQLITE3_LIBS="-lm"
# libpthread and libldl are needed for libgdal, so let's always use them
export LDFLAGS="$LDFLAGS -lpthread -ldl"
fi
autoreconf -vi
fi
# same fix as used for PROJ
if [[ "${target}" == x86_64-linux-musl* ]]; then
export LDFLAGS="$LDFLAGS -lcurl"
fi
# Clear out `.la` files since they're often wrong and screw us up
rm -f ${prefix}/lib/*.la
# Read the options in the log file
./configure --help
./configure --prefix=${prefix} --build=${MACHTYPE} --host=${target} \
--with-geos=${bindir}/geos-config \
--with-proj=$prefix \
--with-tiff=$prefix \
--with-geotiff=$prefix \
--with-libz=$prefix \
--with-expat=$prefix \
--with-zstd=$prefix \
--with-sqlite3=$prefix \
--with-curl=${bindir}/curl-config \
--with-openjpeg \
--with-python=no \
--enable-shared \
--disable-static
# Make sure that some important libraries are found
grep "HAVE_GEOS='yes'" config.log
grep "HAVE_SQLITE='yes'" config.log
grep "CURL_SETTING='yes'" config.log
grep "ZSTD_SETTING='yes'" config.log
grep "HAVE_EXPAT='yes'" config.log
make -j${nproc}
make install
"""
# These are the platforms we will build for by default, unless further
# platforms are passed in on the command line
platforms = expand_cxxstring_abis(supported_platforms())
# The products that we will ensure are always built
products = [
LibraryProduct("libgdal", :libgdal),
ExecutableProduct("gdal_contour", :gdal_contour_path),
ExecutableProduct("gdal_grid", :gdal_grid_path),
ExecutableProduct("gdal_rasterize", :gdal_rasterize_path),
ExecutableProduct("gdal_translate", :gdal_translate_path),
ExecutableProduct("gdaladdo", :gdaladdo_path),
ExecutableProduct("gdalbuildvrt", :gdalbuildvrt_path),
ExecutableProduct("gdaldem", :gdaldem_path),
ExecutableProduct("gdalinfo", :gdalinfo_path),
ExecutableProduct("gdallocationinfo", :gdallocationinfo_path),
ExecutableProduct("gdalmanage", :gdalmanage_path),
ExecutableProduct("gdalsrsinfo", :gdalsrsinfo_path),
ExecutableProduct("gdaltindex", :gdaltindex_path),
ExecutableProduct("gdaltransform", :gdaltransform_path),
ExecutableProduct("gdalwarp", :gdalwarp_path),
ExecutableProduct("nearblack", :nearblack_path),
ExecutableProduct("ogr2ogr", :ogr2ogr_path),
ExecutableProduct("ogrinfo", :ogrinfo_path),
ExecutableProduct("ogrlineref", :ogrlineref_path),
ExecutableProduct("ogrtindex", :ogrtindex_path),
]
# Dependencies that must be installed before this package can be built
dependencies = [
Dependency("GEOS_jll"; compat="~3.10"),
Dependency("PROJ_jll"; compat="~800.200"),
Dependency("Zlib_jll"),
Dependency("SQLite_jll"),
Dependency("OpenJpeg_jll"),
Dependency("Expat_jll"; compat="2.2.10"),
Dependency("Zstd_jll"),
Dependency("Libtiff_jll"; compat="4.3"),
Dependency("libgeotiff_jll"; compat="1.7"),
Dependency("LibCURL_jll"),
]
# Build the tarballs, and possibly a `build.jl` as well.
build_tarballs(ARGS, name, version, sources, script, platforms, products, dependencies; julia_compat="1.6", preferred_gcc_version=v"6")