<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>com.github.fommil.netlib</groupId>
        <artifactId>native_system-xbuilds</artifactId>
        <version>1.1</version>
    </parent>

    <artifactId>netlib-native_system-linux-i686</artifactId>
    <packaging>so</packaging>

    <!--
    This is built for Linux i686 on an x86_64 architecture.

      sudo apt-get install libc6-dev-i386 gfortran-multilib

    get the 32 bit JDK from

      http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html
        
    and install into

      /opt/linux-i686/jdk7
        
    along with the contents of
        
        for A in b/blas/libblas-dev_1.2.20110419-5_i386.deb b/blas/libblas3_1.2.20110419-5_i386.deb l/lapack/liblapack3_3.4.1+dfsg-1+deb70u1_i386.deb l/lapack/liblapack-dev_3.4.1+dfsg-1+deb70u1_i386.deb ; do
          curl -O "http://mirrors.kernel.org/debian/pool/main/$A"
          ar vx `basename $A`
          sudo tar xfzv data.tar.gz -C /opt/linux-i686/
        done

    It is impossible to compile a library on Ubuntu that has static
    references to the fortran libraries, as the static fortran library
    has not been compiled with -fPIC. The only workaround would be
    to compile gcc from scratch, with the flags added, and then compile
    these natives. That is not a wise move.
        
    NOTE: on some Ubuntu systems, the libblas.so.3 and liblapack.so.3
        don't always exist. So you need to create them against the
        sudo ln -s libblas.so /usr/lib/libblas.so.3
        sudo ln -s liblapack.so /usr/lib/liblapack.so.3
    -->
    <properties>
        <netlib.src>../../../netlib</netlib.src>
    </properties>

    <dependencies>
        <dependency>
            <groupId>${project.parent.groupId}</groupId>
            <artifactId>native_system-java</artifactId>
            <version>${project.parent.version}</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>com.github.fommil.netlib</groupId>
                <artifactId>generator</artifactId>
                <executions>
                    <execution>
                        <id>blas</id>
                    </execution>
                    <execution>
                        <id>lapack</id>
                    </execution>
                    <execution>
                        <id>arpack</id>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>native-maven-plugin</artifactId>
                <extensions>true</extensions>
                <configuration>
                    <javahOS>linux</javahOS>
                    <jdkIncludePath>/opt/linux-i686/jdk7/include</jdkIncludePath>
                    <compilerEndOptions>
                        <compilerEndOption>-m32</compilerEndOption>
                        <compilerEndOption>-I/opt/linux-i686/usr/include/</compilerEndOption>
                    </compilerEndOptions>
                    <linkerEndOptions>
                        <linkerEndOption>-m32</linkerEndOption>
                    </linkerEndOptions>
                    <linkerMiddleOptions>
                        <linkerMiddleOption>-L/opt/linux-i686/usr/lib/libblas</linkerMiddleOption>
                        <linkerMiddleOption>-L/opt/linux-i686/usr/lib/lapack</linkerMiddleOption>
                        <linkerMiddleOption>-shared</linkerMiddleOption>
                        <linkerMiddleOption>-lgfortran</linkerMiddleOption>
                        <linkerMiddleOption>-lblas</linkerMiddleOption>
                        <linkerMiddleOption>-llapack</linkerMiddleOption>
                        <linkerMiddleOption>-Wl,-s</linkerMiddleOption>
                        <linkerMiddleOption>-Wl,--version-script=${netlib.src}/symbol.map</linkerMiddleOption>
                        <linkerMiddleOption>-Wl,--gc-sections</linkerMiddleOption>
                    </linkerMiddleOptions>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <executions>
                    <execution>
                        <id>runtime</id>
                    </execution>
                    <execution>
                        <id>source</id>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>
