chiark / gitweb /
date for 2.4 release
[nlopt.git] / BUILD-MINGW64.sh
1 #!/bin/sh
2 set -e
3
4 rm -rf mingw64
5
6 ./configure --prefix=`pwd`/mingw64 --host=amd64-mingw32msvc --enable-shared --disable-static --without-matlab --without-octave --without-python --without-guile --without-threadlocal && make -j4 && make install
7
8 cd mingw64/bin
9 for dll in *.dll; do
10     def=`basename $dll .dll`.def
11     echo "LIBRARY $dll" > $def
12     echo EXPORTS >> $def
13     amd64-mingw32msvc-nm $dll | grep ' T _' | sed 's/.* T _//' | egrep 'nlopt|nlo_' >> $def
14 done
15 cd ../..
16
17 perl -pi -e 's,^ * #define NLOPT_DLL,*/\n#define NLOPT_DLL\n/*,' mingw64/include/nlopt.h
18
19 cat > README-WINDOWS <<EOF
20 This .zip archive contains DLL libraries and the associated header (.h)
21 and module-definition (.def) files of NLopt compiled for Win64.
22
23 In order to link to this .dll files from Visual C++, you need to
24 create a .lib "import libraries" for it, and can do so with the "lib"
25 command that comes with VC++.  In particular, run:
26      lib /def:libnlopt-0.def
27
28 To compile the Matlab plugin, use the Matlab "mex" compiler on the file
29 nlopt_optimize.c (being sure to link to the libnlopt DLL) in the matlab
30 subdirectory.
31
32 To build the Python plugin (assuming that you have Python and Numpy
33 installed), do:
34    python setup.py build_ext --inplace
35
36 They were compiled by the GNU C compiler for MinGW, specifically:
37 EOF
38 amd64-mingw32msvc-gcc --version |head -1 >> README-WINDOWS
39
40 # grep -v "nlopt-util.h" octave/nlopt_minimize_constrained-mex.c > mingw64/nlopt_minimize_constrained.c
41
42 nlopt_vers=`grep PACKAGE_VERSION config.h |cut -d" " -f3 |tr -d \"`
43
44 mkdir mingw64/matlab
45 cd octave
46 cp `grep 'MFILES =' Makefile.am | cut -d= -f2` ../mingw64/matlab
47 cp `grep 'm_DATA =' Makefile.am | cut -d\) -f2` ../mingw64/matlab
48 cp nlopt_optimize-mex.c ../mingw64/matlab/nlopt_optimize.c
49 cd ..
50
51 mkdir mingw64/python
52 cp swig/nlopt.py swig/nlopt-python.cpp mingw64/python
53 cat > mingw64/python/setup.py <<EOF
54 from distutils.core import setup, Extension
55 nlopt_module = Extension('_nlopt',
56                            sources=['nlopt-python.cpp'],
57                            libraries=['libnlopt-0'],
58                            )
59 import numpy
60 setup (name = 'nlopt',
61        version = '${nlopt_vers}',
62        author      = "Steven G. Johnson",
63        description = """NLopt nonlinear-optimization library""",
64        ext_modules = [nlopt_module],
65        py_modules = ["nlopt"],
66        include_dirs = ['.', numpy.get_include()],
67        )
68 EOF
69
70 nlopt_vers=`grep PACKAGE_VERSION config.h |cut -d" " -f3 |tr -d \"`
71 zip=nlopt-${nlopt_vers}-dll64.zip
72 rm -f $zip
73 zip -vj $zip mingw64/bin/*.dll mingw64/bin/*.exe
74 zip -vjgl $zip mingw64/bin/*.def mingw64/include/* mingw64/python/* README COPYING COPYRIGHT NEWS README-WINDOWS
75
76 cd mingw64
77 zip -vgl ../$zip matlab/*
78 cd ..