<?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>
    <artifactId>junixsocket-native</artifactId>
    <packaging>nar</packaging>
    <parent>
        <groupId>com.kohlschutter.junixsocket</groupId>
        <artifactId>junixsocket</artifactId>
        <version>2.9.1</version>
        <relativePath>../pom.xml</relativePath>
    </parent>
    <name>junixsocket-native</name>

    <description>The native JNI library</description>

    <properties>
        <project.build.outputTimestamp>${git.commit.time}</project.build.outputTimestamp>
        <kohlschutter.project.base.directory>${project.parent.basedir}</kohlschutter.project.base.directory>
        <nar.aolProperties>${project.build.outputDirectory}/aol.properties</nar.aolProperties>
        <!-- <nar.aolProperties>${project.basedir}/aol.properties</nar.aolProperties> -->

        <!-- IMPORTANT: junixsocket.native properties that end up in aol.properties:
      Use CDATA to prevent line breaks when formatting — line breaks will break nar-maven-plugin, and may not trigger an error
    -->
        <junixsocket.native.default.options><![CDATA[-Wall -Wextra -Wstrict-prototypes -Wno-reserved-id-macro -Wno-undef -Wno-cast-qual -Wno-disabled-macro-expansion -Wno-language-extension-token -Wno-gnu-auto-type -Wno-c++11-extensions -Wno-c++98-compat -Wno-empty-translation-unit -Wno-gnu-empty-initializer -Werror-implicit-function-declaration -Wint-conversion -Wno-unused-command-line-argument -Werror-implicit-function-declaration -fno-strict-overflow -finline-functions -fwrapv -fno-c++-static-destructors -fPIC -fvisibility=hidden -fno-common -Os]]></junixsocket.native.default.options>
        <junixsocket.native.default.linker.options><![CDATA[ -shared ]]></junixsocket.native.default.linker.options>
        <junixsocket.native.default.c.options>${junixsocket.native.default.options}<![CDATA[ -std=gnu11]]></junixsocket.native.default.c.options>
        <junixsocket.native.default.cpp.options>${junixsocket.native.default.options}<![CDATA[ -std=gnu++17]]></junixsocket.native.default.cpp.options>
        <junixsocket.native.default.c.includes><![CDATA[**/*.c **/*.m]]></junixsocket.native.default.c.includes>
        <junixsocket.native.default.cpp.includes><![CDATA[**/*.cc **/*.cpp **/*.cxx **/*.mm]]></junixsocket.native.default.cpp.includes>
        <!-- if some of these options above turn out to be non-portable, move them to the clang-specific property below -->
        <junixsocket.native.clang.c.options>${junixsocket.native.default.c.options}</junixsocket.native.clang.c.options>
        <junixsocket.native.clang.cpp.options>${junixsocket.native.default.cpp.options}</junixsocket.native.clang.cpp.options>
        <junixsocket.native.aol.llvm>${junixsocket.native.aol}</junixsocket.native.aol.llvm>
        <junixsocket.install.skip></junixsocket.install.skip>
    </properties>
    <profiles>
        <profile>
            <id>current-arch</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>com.github.maven-nar</groupId>
                        <artifactId>nar-maven-plugin</artifactId>
                        <configuration>
                            <c>
                                <toolPath>${junixsocket.native.default.toolPath}</toolPath>
                            </c>
                            <linker>
                                <prefix>${junixsocket.native.default.toolPath}</prefix>
                                <toolPath></toolPath>
                                <name>${junixsocket.native.default.linkerName}</name>
                            </linker>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>cross</id>
            <activation>
                <property>
                    <name>cross</name>
                    <value>true</value>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>com.github.maven-nar</groupId>
                        <artifactId>nar-maven-plugin</artifactId>
                        <configuration>
                            <aol>${junixsocket.native.aol.llvm}</aol>
                            <c>
                                <toolPath>${junixsocket.native.llvm.toolPath}</toolPath>
                            </c>
                            <linker>
                                <prefix>${junixsocket.native.llvm.toolPath}/</prefix>
                                <toolPath></toolPath>
                                <name>clang</name>
                            </linker>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>llvm</id>
            <activation>
                <property>
                    <name>!crossclang.disable</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>com.github.maven-nar</groupId>
                        <artifactId>nar-maven-plugin</artifactId>
                        <configuration>
                            <aol>${junixsocket.native.aol.llvm}</aol>
                            <c>
                                <toolPath>${junixsocket.native.llvm.toolPath}</toolPath>
                                <defines>
                                    <!-- Add the following define to work-around an issue
                    on custom platforms that do not respect socket timeout -->
                                    <!--
                    <define>junixsocket_use_poll</define>
                  -->
                                </defines>
                            </c>
                            <linker>
                                <prefix>${junixsocket.native.llvm.toolPath}/</prefix>
                                <toolPath></toolPath>
                                <name>clang</name>
                            </linker>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>custom-build-directory</id>
            <activation>
                <property>
                    <name>junixsocket.build.directory</name>
                </property>
            </activation>
            <build>
                <directory>${junixsocket.build.directory}</directory>
            </build>
        </profile>
        <profile>
            <id>codeql-skip-c</id>
            <activation>
                <property>
                    <name>codeql-skip-c</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <configuration>
                            <skip>true</skip>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>com.github.maven-nar</groupId>
                        <artifactId>nar-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>default-nar-compile</id>
                                <configuration>
                                    <skip>true</skip>
                                </configuration>
                            </execution>
                            <execution>
                                <id>codeql-nar-compile</id>
                                <phase>compile</phase>
                                <goals>
                                    <goal>nar-compile</goal>
                                </goals>
                                <configuration>
                                    <c>
                                        <sourceDirectory>${basedir}/src/main/c-codeql</sourceDirectory>
                                        <toolPath>${junixsocket.native.default.toolPath}</toolPath>
                                    </c>
                                    <linker>
                                        <prefix>${junixsocket.native.default.toolPath}</prefix>
                                        <toolPath></toolPath>
                                        <name>${junixsocket.native.default.linkerName}</name>
                                    </linker>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>fix-jnilib</id>
            <activation>
                <property>
                    <name>!m2e.version</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-antrun-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>fix-jnilib</id>
                                <phase>prepare-package</phase>
                                <configuration>
                                    <!-- nar-maven-plugin may hardcode jnilib extension, but we need dylib -->
                                    <!-- also add GraalVM native-image metadata for the native library -->
                                    <!-- and make build more reproducible by removing property timestamp -->
                                    <!-- as well as setting file timestamps -->
                                    <target>
                                        <delete>
                                            <fileset dir="${project.build.directory}/nar" includes="**/history.xml" />
                                        </delete>
                                        <replaceregexp match="^\#[^N][^A][^R].*" replace="#" byline="true" encoding="UTF-8">
                                            <fileset dir="${project.build.directory}" includes="**/nar.properties" />
                                        </replaceregexp>
                                        <move todir="${project.build.directory}/nar">
                                            <fileset dir="${project.build.directory}/nar" />
                                            <globmapper from="*.so" to="*.${junixsocket.native.jnilib.extension}" />
                                        </move>
                                        <move todir="${project.build.directory}/nar">
                                            <fileset dir="${project.build.directory}/nar" />
                                            <globmapper from="*.jnilib" to="*.${junixsocket.native.jnilib.extension}" />
                                        </move>
                                        <move todir="${project.build.directory}/nar">
                                            <fileset dir="${project.build.directory}/nar" />
                                            <globmapper from="**/${junixsocket.native.jnilib.strip.prefix}*" to="*" />
                                        </move>
                                        <mkdir dir="${project.build.directory}/nar/junixsocket-native-${project.version}-${junixsocket.native.aol.llvm}-jni/META-INF/native-image/com.kohlschutter.junixsocket/junixsocket-native-${junixsocket.native.aol.llvm}-jni" />
                                        <echo file="${project.build.directory}/nar/junixsocket-native-${project.version}-${junixsocket.native.aol.llvm}-jni/META-INF/native-image/com.kohlschutter.junixsocket/junixsocket-native-${junixsocket.native.aol.llvm}-jni/resource-config.json" append="false">{
"resources":{
"includes":[
{
"pattern":"^lib/${junixsocket.native.aol.llvm}/jni/.*"
}
]},
"bundles":[]
}
</echo>
                                        <touch datetime="${project.build.outputTimestamp}" pattern="yyyy-MM-dd'T'HH:mm:ssXXX">
                                            <fileset dir="${project.build.directory}/nar" includes="**/*" />
                                        </touch>
                                    </target>
                                </configuration>
                                <goals>
                                    <goal>run</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <executions>
                    <execution>
                        <id>prepare-aol</id>
                        <phase>clean</phase>
                        <goals>
                            <goal>resources</goal>
                        </goals>
                        <configuration>
                            <resources>
                                <resource>
                                    <directory>src/main/nar</directory>
                                    <includes>
                                        <include>aol.properties</include>
                                    </includes>
                                    <filtering>true</filtering>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>com.github.maven-nar</groupId>
                <artifactId>nar-maven-plugin</artifactId>
                <extensions>true</extensions>
                <configuration>
                    <aol>${junixsocket.native.aol}</aol>
                    <libraries>
                        <library>
                            <type>jni</type>
                            <linkCPP>false</linkCPP>
                        </library>
                    </libraries>
                    <java>
                        <include>true</include>
                    </java>
                </configuration>
                <executions>
                    <execution>
                        <!-- disabled to allow building with Java 10+ -->
                        <id>default-nar-javah</id>
                        <phase>none</phase>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-install-plugin</artifactId>
                <configuration>
                    <skip>${junixsocket.install.skip}</skip>
                </configuration>
            </plugin>
        </plugins>
    </build>
    <dependencies></dependencies>
</project>
