Skip to content

Commit

Permalink
add GDAL builder (#293)
Browse files Browse the repository at this point in the history
* add GDAL build script

* add CompilerSupportLibraries dependency

This gets us past a failure during the `configure` step where it checks the PROJ dependency by compiling test programs. This led to this failure related to `libstdc++`:

```
configure:24103: checking for proj_create_from_wkt in -lproj
configure:24128: c++ -std=c++11 -o conftest -DHAVE_AVX_AT_COMPILE_TIME -DHAVE_SSSE3_AT_COMPILE_TIME -DHAVE_SSE_AT_COMPILE_TIME -g -O2   conftest.cpp -lproj  -L/workspace/destdir/lib -lproj -lz -L/workspace/destdir -L/workspace/destdir/lib -lpthread -lm -lrt -ldl  >&5
/workspace/destdir/lib/libproj.so: undefined reference to `__cxa_throw_bad_array_new_length@CXXABI_1.3.8'
/workspace/destdir/lib/libproj.so: undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>
```

* add review suggestions

* add missing -L flag in LDFLAGS

Co-Authored-By: Mosè Giordano <giordano@users.noreply.github.com>

* Clear out `.la` files

* [GDAL] Customise name of PROJ lib to link against

* [GDAL] Fixes for Windows and PowerPC

* [GDAL] use latest bugfix release 3.0.3

Includes a few build bug fixes:
https://github.com/OSGeo/gdal/blob/v3.0.3/gdal/NEWS

* [GDAL] Build with GCC v6, for compatibility with GEOS

Co-authored-by: Mosè Giordano <giordano@users.noreply.github.com>
  • Loading branch information
visr and giordano committed Jan 19, 2020
1 parent 53af578 commit 5556c40
Show file tree
Hide file tree
Showing 2 changed files with 155 additions and 0 deletions.
82 changes: 82 additions & 0 deletions G/GDAL/build_tarballs.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
using BinaryBuilder

name = "GDAL"
version = v"3.0.3"

# Collection of sources required to build GDAL
sources = [
"https://github.com/OSGeo/gdal/releases/download/v$version/gdal-$version.tar.gz" =>
"fe9bbe1cd4f74a4917dec9585a91d9018d3a3b61e379aa9a1b709e278dde11d6",
"./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_6_3"
elif [[ "${target}" == powerpc64le-* ]]; then
# Need to remember to link against libpthread and libdl
export LDFLAGS="-lpthread -ldl"
fi
# Clear out `.la` files since they're often wrong and screw us up
rm -f ${prefix}/lib/*.la
./configure --prefix=$prefix --host=$target \
--with-geos=${bindir}/geos-config \
--with-proj=$prefix \
--with-libz=$prefix \
--with-sqlite3=$prefix \
--with-curl=${bindir}/curl-config \
--with-python=no \
--enable-shared \
--disable-static
make -j${nproc}
make install
"""

platforms = supported_platforms()
platforms = expand_cxxstring_abis(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 = [
"GEOS_jll",
"PROJ_jll",
"Zlib_jll",
"SQLite_jll",
"LibCURL_jll",
]

# Build the tarballs, and possibly a `build.jl` as well.
build_tarballs(ARGS, name, version, sources, script, platforms, products, dependencies; preferred_gcc_version=v"6")
73 changes: 73 additions & 0 deletions G/GDAL/bundled/patches/configure_ac_proj_libs.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
--- a/configure.ac
+++ b/configure.ac
@@ -1198,15 +1198,18 @@

else

+ if test -z "$PROJ_LIBS"; then
+ PROJ_LIBS="proj"
+ fi
if test "x$with_proj" = "xyes" -o "x$with_proj" = "x"; then
ORIG_LIBS="$LIBS"
- LIBS="-lproj $ORIG_LIBS"
+ LIBS="-l$PROJ_LIBS $ORIG_LIBS"
AC_LANG_PUSH([C++])
- AC_CHECK_LIB(proj,proj_create_from_wkt,PROJ_FOUND=yes,PROJ_FOUND=no,)
+ AC_CHECK_LIB($PROJ_LIBS,proj_create_from_wkt,PROJ_FOUND=yes,PROJ_FOUND=no,)
AC_LANG_POP([C++])
if test "$PROJ_FOUND" = "no"; then
AC_LANG_PUSH([C++])
- AC_CHECK_LIB(proj,internal_proj_create_from_wkt,PROJ_FOUND=yes,PROJ_FOUND=no,)
+ AC_CHECK_LIB($PROJ_LIBS,internal_proj_create_from_wkt,PROJ_FOUND=yes,PROJ_FOUND=no,)
AC_LANG_POP([C++])
if test "$PROJ_FOUND" = "yes"; then
PROJ_INCLUDE="-DPROJ_RENAME_SYMBOLS"
@@ -1233,27 +1236,27 @@
else

ORIG_LIBS="$LIBS"
- LIBS="-L$with_proj/lib -lproj $ORIG_LIBS"
+ LIBS="-L$with_proj/lib -l$PROJ_LIBS $ORIG_LIBS"
AC_LANG_PUSH([C++])
- AC_CHECK_LIB(proj,proj_create_from_wkt,PROJ_FOUND=yes,PROJ_FOUND=no,)
+ AC_CHECK_LIB($PROJ_LIBS,proj_create_from_wkt,PROJ_FOUND=yes,PROJ_FOUND=no,)
AC_LANG_POP([C++])
if test "$PROJ_FOUND" = "no"; then
- LIBS="-L$with_proj/lib -lproj -lsqlite3 $ORIG_LIBS"
+ LIBS="-L$with_proj/lib -l$PROJ_LIBS -lsqlite3 $ORIG_LIBS"
unset ac_cv_lib_proj_proj_create_from_wkt
AC_LANG_PUSH([C++])
- AC_CHECK_LIB(proj,proj_create_from_wkt,PROJ_FOUND=yes,PROJ_FOUND=no,)
+ AC_CHECK_LIB(-l$PROJ_LIBS,proj_create_from_wkt,PROJ_FOUND=yes,PROJ_FOUND=no,)
AC_LANG_POP([C++])
fi
if test "$PROJ_FOUND" = "no"; then
- LIBS="-L$with_proj/lib -lproj $ORIG_LIBS"
+ LIBS="-L$with_proj/lib -l$PROJ_LIBS $ORIG_LIBS"
AC_LANG_PUSH([C++])
- AC_CHECK_LIB(proj,internal_proj_create_from_wkt,PROJ_FOUND=yes,PROJ_FOUND=no,)
+ AC_CHECK_LIB($PROJ_LIBS,internal_proj_create_from_wkt,PROJ_FOUND=yes,PROJ_FOUND=no,)
AC_LANG_POP([C++])
if test "$PROJ_FOUND" = "no"; then
- LIBS="-L$with_proj/lib -lproj -lsqlite3 $ORIG_LIBS"
+ LIBS="-L$with_proj/lib -l$PROJ_LIBS -lsqlite3 $ORIG_LIBS"
unset ac_cv_lib_proj_internal_proj_create_from_wkt
AC_LANG_PUSH([C++])
- AC_CHECK_LIB(proj,internal_proj_create_from_wkt,PROJ_FOUND=yes,PROJ_FOUND=no,)
+ AC_CHECK_LIB($PROJ_LIBS,internal_proj_create_from_wkt,PROJ_FOUND=yes,PROJ_FOUND=no,)
AC_LANG_POP([C++])
fi
if test "$PROJ_FOUND" = "yes"; then
@@ -4100,10 +4103,10 @@
AC_MSG_CHECKING([for spatialite.h in /usr/include or /usr/local/include])
if test -f "/usr/include/spatialite.h" -o -f "/usr/local/include/spatialite.h"; then
AC_MSG_RESULT(found)
- AC_CHECK_LIB(spatialite,spatialite_init,SPATIALITE_INIT_FOUND=yes,SPATIALITE_INIT_FOUND=no,-lsqlite3 -lproj)
+ AC_CHECK_LIB(spatialite,spatialite_init,SPATIALITE_INIT_FOUND=yes,SPATIALITE_INIT_FOUND=no,-lsqlite3 -l$PROJ_LIBS)
if test "$SPATIALITE_INIT_FOUND" = "yes"; then
HAVE_SPATIALITE=yes
- SPATIALITE_LIBS="-lspatialite -lsqlite3 -lproj"
+ SPATIALITE_LIBS="-lspatialite -lsqlite3 -l$PROJ_LIBS"
LIBS="$LIBS $SPATIALITE_LIBS"
HAVE_SQLITE3=yes
fi

0 comments on commit 5556c40

Please sign in to comment.