From feeef908e6f943f32fa07ae77aebaedc67134cca Mon Sep 17 00:00:00 2001 From: Jacob Stanley Date: Wed, 9 Jan 2013 15:25:16 +0800 Subject: [PATCH] Fixed to work with latest netcdf --- .gitignore | 2 ++ config.h.patch | 6 ++--- lib.bat | 6 +++++ liblib-Makefile.am.patch | 2 -- rebuild-netcdf | 51 +++++++++++++++++++++++----------------- 5 files changed, 41 insertions(+), 26 deletions(-) create mode 100644 lib.bat diff --git a/.gitignore b/.gitignore index d38c149..29c6945 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ *.swp *~ +netcdf-* +bin/ diff --git a/config.h.patch b/config.h.patch index c295ade..0399104 100644 --- a/config.h.patch +++ b/config.h.patch @@ -1,8 +1,8 @@ --- a/config.h +++ b/config.h @@ -365,7 +365,13 @@ - #define SIZEOF_LONG 4 - + #define SIZEOF_LONG_LONG 8 + /* The size of `off_t', as computed by sizeof. */ -#define SIZEOF_OFF_T 4 +#include @@ -12,6 +12,6 @@ +#define off_t __int64 +#define _off_t __int64 +#define _OFF_T_DEFINED - + /* The size of `short', as computed by sizeof. */ #define SIZEOF_SHORT 2 diff --git a/lib.bat b/lib.bat new file mode 100644 index 0000000..2adeb33 --- /dev/null +++ b/lib.bat @@ -0,0 +1,6 @@ +@echo off +set VISUAL_STUDIO=C:\Program Files (x86)\Microsoft Visual Studio 10.0 +set SETUP_ENV="%VISUAL_STUDIO%\VC\bin\vcvars32.bat" + +call %SETUP_ENV% +lib.exe %* diff --git a/liblib-Makefile.am.patch b/liblib-Makefile.am.patch index a7ff213..e4f4509 100644 --- a/liblib-Makefile.am.patch +++ b/liblib-Makefile.am.patch @@ -1,5 +1,3 @@ -diff --git a/liblib/Makefile.am b/liblib/Makefile.am -index c6ab07f..0f4d7bf 100755 --- a/liblib/Makefile.am +++ b/liblib/Makefile.am @@ -19,7 +19,7 @@ libnetcdf_la_LIBADD = diff --git a/rebuild-netcdf b/rebuild-netcdf index 78fddba..1c319a6 100644 --- a/rebuild-netcdf +++ b/rebuild-netcdf @@ -2,18 +2,20 @@ set -e -NETCDF=netcdf-4.2.1.1 -NETCDF_WIN="$( cd "$( dirname "$0" )" && pwd )" -BINARIES=$NETCDF_WIN/bin +NETCDF_VERSION=netcdf-4.2.1.1 + +BASE="$( cd "$( dirname "$0" )" && pwd )" +BIN=$BASE/bin +SRC=$BASE/$NETCDF_VERSION # Reset to known state echo "# Resetting NetCDF sources to clean state" -cd $NETCDF_WIN -rm -rf $NETCDF -tar -zxvf $NETCDF.tar.gz -cd $NETCDF +cd $BASE +rm -rf $SRC +tar -zxvf $NETCDF_VERSION.tar.gz +cd $SRC # Generate stdcall wrappers @@ -21,12 +23,12 @@ cd $NETCDF echo echo "# Generating stdcall wrappers" -runghc $NETCDF_WIN/mkstdcall.hs \ - --exclude=$NETCDF_WIN/netcdf.ignore \ - include/netcdf.h > \ - liblib/stdcall.c +runghc $BASE/mkstdcall.hs \ + --exclude=$BASE/netcdf.ignore \ + $SRC/include/netcdf.h > \ + $SRC/liblib/stdcall.c -patch liblib/Makefile.am $NETCDF_WIN/liblib-Makefile.am.patch +patch $SRC/liblib/Makefile.am $BASE/liblib-Makefile.am.patch # Configure NetCDF @@ -36,7 +38,10 @@ echo "# Configuring NetCDF" autoreconf -i ./configure --enable-dll --disable-netcdf-4 -patch config.h $NETCDF_WIN/config.h.patch +make config.h + +echo patch $SRC/config.h $BASE/config.h.patch +patch $SRC/config.h $BASE/config.h.patch # Build NetCDF @@ -51,12 +56,16 @@ make echo echo "# Harvesting Binaries" -rm -rf $BINARIES -mkdir $BINARIES +rm -rf $BIN +mkdir $BIN + +cp $SRC/include/netcdf.h $BIN/netcdf.h +cp $SRC/liblib/.libs/libnetcdf-7.dll $BIN/netcdf.dll +pexports $BIN/netcdf.dll | sed -e 's/libnetcdf-7/netcdf/' >$BIN/netcdf.def + +cd $BIN +cmd //c $BASE/lib.bat //machine:i386 //def:netcdf.def //out:netcdf.lib -cp include/netcdf.h $BINARIES/netcdf.h -cp liblib/netcdfdll.def $BINARIES/netcdf.def -cp liblib/.libs/libnetcdf-7.dll $BINARIES/netcdf.dll -dlltool --input-def=$BINARIES/netcdf.def \ - --dllname=netcdf.dll \ - --output-lib=$BINARIES/netcdf.lib +#dlltool --input-def=$BIN/netcdf.def \ +# --dllname=netcdf.dll \ +# --output-lib=$BIN/netcdf.lib