Skip to content

Commit

Permalink
working on #23
Browse files Browse the repository at this point in the history
 - gdal builds for both runtimes
 - rewrote makefiles
 - shared config for makefiles
  • Loading branch information
MaxRev-Dev committed Aug 13, 2020
1 parent 70ab3da commit bff4708
Show file tree
Hide file tree
Showing 39 changed files with 417 additions and 346 deletions.
Binary file modified maxrev.gdal.core.libshared/proj.db
Binary file not shown.
4 changes: 3 additions & 1 deletion test/GdalCoreTest/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
using OSGeo.GDAL;
using OSGeo.OSR;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace GdalCoreTest
{
Expand All @@ -22,7 +24,7 @@ static void Main(string[] args)
"GDAL Version: " + Gdal.VersionInfo("RELEASE_NAME"),
"GDAL INFO: " + Gdal.VersionInfo("")));
var spatialReference = new SpatialReference(null);
spatialReference.SetWellKnownGeogCS("wgs84");
spatialReference.SetWellKnownGeogCS("wgs84");

// list of common drivers
var drivers = new[]
Expand Down
13 changes: 6 additions & 7 deletions unix/GNUmakefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
include GdalCore.opt
RUNTIME_RID=unix
include ../shared/GdalCore.opt
include $(BASE_GDAL_)/GDALmake.opt
include $(GDAL_ROOT)/swig/csharp/csharp.opt

SRC_=$(PWD)

ifeq ($(LIBGDAL_CURRENT),)
LIBGDAL_CURRENT := 27
endif
Expand Down Expand Up @@ -37,15 +36,15 @@ endif
OUTPUT = $(ROOTDIR_)/runtimes/$(RID)/native

CSHARP_MODULES = libgdalcsharp.$(SO_EXT) libogrcsharp.$(SO_EXT) libgdalconstcsharp.$(SO_EXT) libosrcsharp.$(SO_EXT)
CSHARP_OBJECTS = $(SRC_)/const/gdalconst_wrap.$(OBJ_EXT) $(SRC_)/gdal/gdal_wrap.$(OBJ_EXT) $(SRC_)/osr/osr_wrap.$(OBJ_EXT) $(SRC_)/ogr/ogr_wrap.$(OBJ_EXT)
CSHARP_OBJECTS = $(BASE)/const/gdalconst_wrap.$(OBJ_EXT) $(BASE)/gdal/gdal_wrap.$(OBJ_EXT) $(BASE)/osr/osr_wrap.$(OBJ_EXT) $(BASE)/ogr/ogr_wrap.$(OBJ_EXT)
echo:
echo $(CXX)
clean:
(cd $(SRC_) && rm -f ${CSHARP_MODULES} *.$(OBJ_EXT) *.config *.dll *.mdb *.exe)
(cd $(BASE) && rm -f ${CSHARP_MODULES} *.$(OBJ_EXT) *.config *.dll *.mdb *.exe)
(cd $(PWD) && rm -f ${CSHARP_MODULES} *.$(OBJ_EXT) *.config *.dll *.mdb *.exe)

veryclean: clean
(cd $(SRC_) && rm -f -R const/*.cs const/*.c gdal/*.cs gdal/*.cpp osr/*.cs osr/*.cpp ogr/*.cs ogr/*.cpp Data)
(cd $(BASE) && rm -f -R const/*.cs const/*.c gdal/*.cs gdal/*.cpp osr/*.cs osr/*.cpp ogr/*.cs ogr/*.cpp Data)
(cd $(PWD) && rm -f -R *.so *.o ./*.cs gdal/*.cs gdal/*.cpp osr/*.cs osr/*.cpp ogr/*.cs *.c *.cpp .libs/ const/ ogr/ osr/ gdal/ obj/ runtimes/ bin/)

cleangdal:
Expand All @@ -65,7 +64,7 @@ prebuild: interface
build: ${CSHARP_OBJECTS} ${CSHARP_MODULES} gdal_csharp

sign:
(cd $(SRC_) && sn -k gdal.snk)
(cd $(BASE) && sn -k gdal.snk)

install:
@echo "No installation to be done"
Expand Down
40 changes: 0 additions & 40 deletions unix/GdalCore.opt

This file was deleted.

47 changes: 0 additions & 47 deletions unix/GdalMakefile

This file was deleted.

43 changes: 11 additions & 32 deletions unix/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

* [Easy way compiling](#easy-way-compiling)
* [Alternate way](#alternate-way)
+ [1. Compile SQLite3 (optional)](#1-compile-sqlite3-optional)
+ [1. Install prerequisite packages](#1-install-prerequisite-packages)
+ [2. Compile PROJ6](#2-compile-proj6)
+ [3. Clone and Compile GDAL](#3-clone-and-compile-gdal)
+ [4. Build a wrapper](#4-build-a-wrapper)
Expand All @@ -18,10 +18,6 @@ First of all I wish you to be patient & bring your snacks. Compilation from scra
1. `yum install tcl tcl-devel -y` - for building sqlite3
2. `yum install patchelf -y` - dynamic linking

If you have installed **libsqlite3-dev** and **proj6** - go forward to step **#3**

If you have **libsqlite3-dev** installed you may skip the first step.

Set a root variable for convenience
``export gc_root=`pwd` ``

Expand All @@ -32,40 +28,23 @@ Set a root variable for convenience
Assuming you have `tclsh` for compiling `sqlite3`

```shell
make -f GdalMakefile
make -f gdal-makefile
```

this will compile `sqlite3, proj6, geos` and `gdal` from scratch

## Alternate way

### 1. Compile SQLite3 (optional)

1. [Download SQLite3 Autoconf](https://www.sqlite.org/download.html) & unpack (GdalMakefile uses git for this)

```shell
mkdir $gc_root/build-unix
curl -o sqlite.tar.gz "https://www.sqlite.org/2019/sqlite-autoconf-3290000.tar.gz"
tar xfv sqlite.tar.gz && mv sqlite-autoconf-3290000 sqlite3-source && cd sqlite3-source
```

2. Configure sqlite3

```shell
./configure --prefix=$gc_root/sqlite3-build
```

3. Compile and install

```shell
make && make install && cd $gc_root
```
### 1. Install prerequisite packages

```shell
`yum install xz-devel hdf hdf5-devel libtiff sqlite-devel expat curl-devel -y` - LZMA, HDF4, HDF5
```


### 2. Compile PROJ6

1. [Download proj](https://proj.org/download.html) & unpack (GdalMakefile uses git for this)
1. [Download proj](https://proj.org/download.html) & unpack (gdal-makefile uses git for this)

```shell
mkdir $gc_root/build-unix
Expand All @@ -85,10 +64,10 @@ this will compile `sqlite3, proj6, geos` and `gdal` from scratch

### 3. Clone and Compile GDAL

You can build gdal using **GdalMakefile**, but before you must setup paths in **GdalCore.opt** file.
You can build gdal using **gdal-makefile**, but before you must setup paths in **GdalCore.opt** file.
Also you must change **configuregdal.sh** script to setup necessary drivers.

Then you may just call `make -f GdalMakefile gdal` - this will sync gdal repository, configure it and finaly build.
Then you may just call `make -f gdal-makefile gdal` - this will sync gdal repository, configure it and finaly build.

*Or alternatively...* (assuming you are in the root of this repo)

Expand All @@ -97,11 +76,11 @@ Then you may just call `make -f GdalMakefile gdal` - this will sync gdal reposit
```

2. ```shell
cd $gc_root && make -f GdalMakefile configure_gdal #calls ./configuregdal.sh
cd $gc_root && make -f gdal-makefile configure_gdal #calls ./configuregdal.sh
```

3. ```shell
make -f GdalMakefile build_gdal
make -f gdal-makefile build_gdal
```

After you have gdal installed, you can proceed to netcore bindings build.
Expand Down
29 changes: 19 additions & 10 deletions unix/configuregdal.sh
Original file line number Diff line number Diff line change
@@ -1,25 +1,35 @@
#!/bin/sh
source=`pwd`/../build-unix
cd ${source}/gdal-source/gdal
vcdir=${source}/vcpkg/installed/x64-linux
chmod +x ./configure
./configure --prefix=${source}/gdal-build CFLAGS="-fPIC" \
export PKG_CONFIG_PATH="${vcdir}/lib/pkgconfig"

# hdf5 path - only this works.
# tried with vcpkg static and other HDF5_LIBS

./configure --prefix=${source}/gdal-build \
CFLAGS="-fPIC" \
--with-geos=${source}/geos-build/bin/geos-config \
--with-proj=${source}/proj6-build \
--with-proj=${source}/proj-build \
--with-liblzma \
--with-libtool \
--with-geotiff=internal \
--with-hide-internal-symbols \
--with-libtiff=internal \
--with-libz=internal \
--with-jpeg=internal \
--with-threads \
--with-hdf4 \
--with-hdf5 \
--with-sqlite3 \
--with-curl \
--with-png \
--with-sqlite3 \
--with-hdf4 \
--with-hdf5="/usr/lib64" \
--with-libz=${vcdir} \
--with-jpeg=${vcdir} \
--with-expat=${vcdir} \
--with-libtiff=${vcdir} \
--with-xerces=${vcdir} \
--without-cfitsio \
--without-cryptopp \
--without-ecw \
--without-expat \
--without-fme \
--without-freexl \
--without-gif \
Expand Down Expand Up @@ -47,7 +57,6 @@ chmod +x ./configure
--without-qhull \
--without-sde \
--without-webp \
--without-xerces \
--without-xml2 \
--without-poppler \
--without-crypto
86 changes: 86 additions & 0 deletions unix/gdal-makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
#
# gdal.netcore package automation
#

BASE=$(PWD)
BASE_RUNTIME_RID=unix
VCPKG_RID=x64-linux

include ../shared/GdalCore.opt

# default targets on linux
TARGETS = proj geos gdal
all: $(TARGETS)

# lower and uppercase funcs
UP = $(shell echo '$*' | tr a-z A-Z)
LW = $(shell echo '$*' | tr A-Z a-z)

# add support for [-force] param
REP = $(shell echo '$(LW)' | sed "s/-force//g")

# accepts any user params
% :
ifneq ($(filter $(REP),$(TARGETS)),'')
@if [ ! -d "$(BUILD_ROOT)/$(REP)-build" ] || [[ "$(LW)" == *"-force"* ]] ; then \
$(MAKE) -f gdal-makefile init_$(REP); \
$(MAKE) -f gdal-makefile configure_$(REP); \
$(MAKE) -f gdal-makefile build_$(REP); \
else \
echo "Build folder exists $(BUILD_ROOT)/$(REP)-build"; \
echo "To rebuild add {key}-force"; \
fi;
else
@echo "Can not make $(REP)"
endif

init_%:
@if [ ! -d "$($(UP)_ROOT)" ]; then \
git clone $($(UP)_REPO) $($(UP)_ROOT); \
fi;
@echo "Restoring $(LW) sources version to $($(UP)_COMMIT_VER)"
@cd $($(UP)_ROOT) && git fetch
@cd $($(UP)_ROOT) && git checkout -q $($(UP)_COMMIT_VER) --force
@cd $($(UP)_ROOT) && git reset --hard
@cd $($(UP)_ROOT) && $(GIT_CLEAN)
@echo "Sources restore complete for $(LW)"

configure_gdal:
./configuregdal.sh

configure_%:
@cd $(PROJ_ROOT) && chmod +x ./autogen.sh
cd $(PROJ_ROOT) && ./autogen.sh
cd $(PROJ_ROOT) && ./configure --prefix=$(BUILD_ROOT)/$(LW)-build

configure_proj:
@cd $(PROJ_ROOT) && chmod +x ./autogen.sh
cd $(PROJ_ROOT) && ./autogen.sh

# 1. --with-curl=[path] does not work because curl-config not found
# 2. vcpkg's tiff_x64-linux default location in pkg-config also not found

cd $(PROJ_ROOT) && ./configure --prefix=$(BUILD_ROOT)/proj-build \
LIBS="-L$(VCPKG_INSTALLED)/lib -lsqlite3 -L$(VCPKG_INSTALLED)/lib -ltiff -L$(VCPKG_INSTALLED)/lib -llzma -L$(VCPKG_INSTALLED)/lib -ljpeg" \
TIFF_INCLUDE_DIR=-I$(VCPKG_INSTALLED)/include \
TIFF_CFLAGS=-L$(VCPKG_INSTALLED)/lib \
SQLITE3_CFLAGS=-I$(VCPKG_INSTALLED)/include \
SQLITE3_LIBS=-L$(VCPKG_INSTALLED)/lib \
TIFF_LIBRARY_RELEASE=$(VCPKG_INSTALLED)/lib/libtiff.a

build_%:
cd $($(UP)_ROOT) && $(MAKE) && $(MAKE) install


build_gdal:
cd $(GDAL_ROOT) && $(MAKE)
cd $(GDAL_ROOT) && $(MAKE) install

reset: reset_proj reset_gdal reset_geos
reset_%:
cd $($(UP)_ROOT) && git checkout -q $($(UP)_COMMIT_VER) && git reset --hard && git clean -fqdx;


.EXPORT_ALL_VARIABLES:

PKG_CONFIG_PATH=$(VCPKG_INSTALLED)/lib/pkgconfig
Loading

0 comments on commit bff4708

Please sign in to comment.