<?xml version="1.0" encoding="UTF-8"?>
<!--
To compile on win64, you need
1. Download visual studio
2. Download intel parallel studio for window
3. Find "Compiler 17.0 Update 4 for Intel 64 Visual Studio 2017 environment" cmd and open it
4. run mklvars.bat
5. mvn compile -P win64
-->
<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">
    <parent>
        <artifactId>bigquant-parent</artifactId>
        <groupId>com.intel.analytics.bigdl</groupId>
        <version>0.3.0</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.intel.analytics.bigdl.bigquant</groupId>
    <artifactId>bigquant-native</artifactId>
    <packaging>${dynamicLibType}</packaging>

    <properties>
      <native.source.dir>${project.basedir}\..\native</native.source.dir>
      <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <build>
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
		<version>3.1</version>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>native-maven-plugin</artifactId>
                <version>1.0-alpha-8</version>
                <extensions>true</extensions>
                <configuration>
                    <compilerProvider>msvc</compilerProvider>
                    <sources>
                        <source>
                            <directory>${project.basedir}\..\quant\src\main\c\jni</directory>
                            <fileNames>
                                <fileName>quant.c</fileName>
                            </fileNames>
                        </source>
                    </sources>

                    <compilerStartOptions>
                        <compilerStartOption>/EHsc /LD</compilerStartOption>
                        <compilerStartOption>/I "${JAVA_HOME}\include"</compilerStartOption>
                        <compilerStartOption>/I "${JAVA_HOME}\include\win32"</compilerStartOption>
                    </compilerStartOptions>

                    <linkerSecondaryOutputExtensions>lib</linkerSecondaryOutputExtensions>

                    <linkerStartOptions>
			<linkerStartOption>/LIBPATH:${native.source.dir}</linkerStartOption>
                        <linkerStartOption>libbigquant_rt.lib</linkerStartOption>
                        <linkerStartOption>/DLL</linkerStartOption>
                    </linkerStartOptions>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>1.2.1</version>
                <executions>
                    <execution>
                        <phase>process-resources</phase>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <configuration>
                            <executable>mingw32-make</executable>
                            <workingDirectory>${native.source.dir}</workingDirectory>
                            <arguments>
                              <argument>-f</argument>
                              <argument>${native.source.dir}\Makefile</argument>
                              <argument>LOAD_METHOD=MANUAL</argument>
                              <argument>PLATFORM=WINDOWS</argument>
                              <argument>all</argument>
                            </arguments>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>
