9 ./configure --prefix=`pwd`/mingw32 --host=i686-w64-mingw32 --enable-shared --disable-static --without-matlab --without-octave --without-python --without-guile --without-threadlocal && make -j4 && make install
11 echo "POST-PROCESSING..."
15 def=`basename $dll .dll`.def
16 echo "LIBRARY $dll" > $def
18 i686-w64-mingw32-nm $dll | grep ' T _' | sed 's/.* T _//' | egrep 'nlopt|nlo_' >> $def
22 perl -pi -e 's,^ * #define NLOPT_DLL,*/\n#define NLOPT_DLL\n/*,' mingw32/include/nlopt.h
24 cat > README-WINDOWS <<EOF
25 This .zip archive contains DLL libraries and the associated header (.h)
26 and module-definition (.def) files of NLopt compiled for Win32.
28 In order to link to this .dll files from Visual C++, you need to
29 create a .lib "import libraries" for it, and can do so with the "lib"
30 command that comes with VC++. In particular, run:
31 lib /def:libnlopt-0.def
33 To compile the Matlab plugin, use the Matlab "mex" compiler on the file
34 nlopt_optimize.c (being sure to link to the libnlopt DLL) in the matlab
37 To build the Python plugin (assuming that you have Python and Numpy
39 python setup.py build_ext --inplace
41 They were compiled by the GNU C compiler for MinGW, specifically:
43 i686-w64-mingw32-gcc --version |head -1 >> README-WINDOWS
45 # grep -v "nlopt-util.h" octave/nlopt_minimize_constrained-mex.c > mingw32/nlopt_minimize_constrained.c
47 nlopt_vers=`grep PACKAGE_VERSION config.h |cut -d" " -f3 |tr -d \"`
51 cp `grep 'MFILES =' Makefile.am | cut -d= -f2` ../mingw32/matlab
52 cp `grep 'm_DATA =' Makefile.am | cut -d\) -f2` ../mingw32/matlab
53 cp nlopt_optimize-mex.c ../mingw32/matlab/nlopt_optimize.c
57 cp swig/nlopt.py swig/nlopt-python.cpp mingw32/python
58 cat > mingw32/python/setup.py <<EOF
59 from distutils.core import setup, Extension
60 nlopt_module = Extension('_nlopt',
61 sources=['nlopt-python.cpp'],
62 libraries=['libnlopt-0'],
65 setup (name = 'nlopt',
66 version = '${nlopt_vers}',
67 author = "Steven G. Johnson",
68 description = """NLopt nonlinear-optimization library""",
69 ext_modules = [nlopt_module],
70 py_modules = ["nlopt"],
71 include_dirs = ['.', numpy.get_include()],
75 nlopt_vers=`grep PACKAGE_VERSION config.h |cut -d" " -f3 |tr -d \"`
76 zip=nlopt-${nlopt_vers}-dll32.zip
78 zip -vj $zip mingw32/bin/*.dll mingw32/bin/*.exe
79 zip -vjgl $zip mingw32/bin/*.def mingw32/include/* mingw32/python/* README COPYING COPYRIGHT NEWS README-WINDOWS
81 echo "PACKAGING $zip..."
84 zip -vgl ../$zip matlab/*