Skip to content

Commit

Permalink
Fixed to work with latest netcdf
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobstanley committed Jan 9, 2013
1 parent 7324db5 commit feeef90
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 26 deletions.
2 changes: 2 additions & 0 deletions .gitignore
@@ -1,2 +1,4 @@
*.swp
*~
netcdf-*
bin/
6 changes: 3 additions & 3 deletions 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 <io.h>
Expand All @@ -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
6 changes: 6 additions & 0 deletions 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 %*
2 changes: 0 additions & 2 deletions 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 =
Expand Down
51 changes: 30 additions & 21 deletions rebuild-netcdf
Expand Up @@ -2,31 +2,33 @@

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

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
Expand All @@ -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
Expand All @@ -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

0 comments on commit feeef90

Please sign in to comment.