<?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">
	<parent>
		<groupId>org.cryptomator</groupId>
		<artifactId>jfuse</artifactId>
		<version>0.1.0-beta1</version>
	</parent>
	<modelVersion>4.0.0</modelVersion>
	<artifactId>jfuse-linux-amd64</artifactId>
	<name>jFUSE Linux x86_64</name>
	<description>Java FUSE bindings for Linux x86_64</description>
	<url>https://github.com/cryptomator/jfuse/tree/develop/jfuse-linux-amd64</url>

	<properties>
		<maven.deploy.skip>false</maven.deploy.skip>
		<linux.headerSearchPath>/usr/x86_64-linux-gnu/include/</linux.headerSearchPath> <!-- debian package libc6-dev-amd64-cross -->
	</properties>

	<dependencies>
		<dependency>
			<groupId>org.cryptomator</groupId>
			<artifactId>jfuse-api</artifactId>
			<version>${project.version}</version>
		</dependency>
	</dependencies>

	<profiles>
		<profile>
			<id>jextract</id>
			<build>
				<plugins>
					<plugin>
						<groupId>org.apache.maven.plugins</groupId>
						<artifactId>maven-enforcer-plugin</artifactId>
						<executions>
							<execution>
								<id>check-preconditions</id>
								<goals>
									<goal>enforce</goal>
								</goals>
								<configuration>
									<rules>
										<requireOS>
											<family>unix</family>
											<name>linux</name>
											<message>This build configuration requires Linux.</message>
										</requireOS>
										<requireFilesExist>
											<files>
												<file>${linux.headerSearchPath}</file>
											</files>
											<message>libc6 headers not found.</message>
										</requireFilesExist>
									</rules>
								</configuration>
							</execution>
						</executions>
					</plugin>
					<plugin>
						<artifactId>maven-clean-plugin</artifactId>
						<configuration>
							<filesets>
								<fileset>
									<directory>${project.build.sourceDirectory}/org/cryptomator/jfuse/linux/amd64/extr</directory>
									<includes>
										<include>*.java</include>
									</includes>
									<followSymlinks>false</followSymlinks>
								</fileset>
							</filesets>
						</configuration>
					</plugin>
					<plugin>
						<groupId>org.codehaus.mojo</groupId>
						<artifactId>exec-maven-plugin</artifactId>
						<executions>
							<execution>
								<id>jextract-fuse</id>
								<goals>
									<goal>exec</goal>
								</goals>
								<phase>generate-sources</phase>
								<configuration>
									<executable>${java.home}/bin/jextract</executable>
									<workingDirectory>${project.basedir}</workingDirectory>
									<arguments>
										<argument>--source</argument>
										<argument>-l</argument>
										<argument>fuse</argument>
										<argument>-d</argument>
										<argument>${project.build.sourceDirectory}</argument>
										<argument>-t</argument>
										<argument>org.cryptomator.jfuse.linux.amd64.extr</argument>
										<argument>-I</argument>
										<argument>${linux.headerSearchPath}</argument>
										<argument>-C-D_FILE_OFFSET_BITS=64</argument>
										<argument>-C-DFUSE_USE_VERSION=29</argument>
										<!-- structs: -->
										<argument>--include-struct</argument>
										<argument>fuse_operations</argument>
										<argument>--include-struct</argument>
										<argument>fuse_file_info</argument>
										<argument>--include-struct</argument>
										<argument>fuse_context</argument>
										<argument>--include-struct</argument>
										<argument>stat</argument>
										<argument>--include-struct</argument>
										<argument>statvfs</argument>
										<argument>--include-struct</argument>
										<argument>timespec</argument>
										<argument>--include-struct</argument>
										<argument>fuse_conn_info</argument>
										<!-- typedefs: -->
										<argument>--include-typedef</argument>
										<argument>fuse_fill_dir_t</argument>
										<!-- functions: -->
										<argument>--include-function</argument>
										<argument>fuse_main_real</argument>
										<argument>--include-function</argument>
										<argument>fuse_get_context</argument>
										<argument>--include-function</argument>
										<argument>fuse_exit</argument>
										<!-- extract fuse.h header: -->
										<argument>${project.parent.basedir}/libfuse/include/fuse.h</argument>
									</arguments>
								</configuration>
							</execution>
							<execution>
								<id>jextract-errno</id>
								<goals>
									<goal>exec</goal>
								</goals>
								<phase>generate-sources</phase>
								<configuration>
									<executable>${java.home}/bin/jextract</executable>
									<workingDirectory>${project.basedir}</workingDirectory>
									<arguments>
										<argument>--source</argument>
										<argument>-d</argument>
										<argument>${project.build.sourceDirectory}</argument>
										<argument>-t</argument>
										<argument>org.cryptomator.jfuse.linux.amd64.extr</argument>
										<argument>-I</argument>
										<argument>${linux.headerSearchPath}</argument>
										<!-- constants -->
										<argument>--include-macro</argument>
										<argument>ENOENT</argument>
										<argument>--include-macro</argument>
										<argument>ENOSYS</argument>
										<argument>--include-macro</argument>
										<argument>ENOMEM</argument>
										<argument>--include-macro</argument>
										<argument>EACCES</argument>
										<argument>--include-macro</argument>
										<argument>EIO</argument>
										<argument>--include-macro</argument>
										<argument>EROFS</argument>
										<argument>--include-macro</argument>
										<argument>EBADF</argument>
										<argument>--include-macro</argument>
										<argument>EEXIST</argument>
										<argument>--include-macro</argument>
										<argument>ENOTDIR</argument>
										<argument>--include-macro</argument>
										<argument>EISDIR</argument>
										<argument>--include-macro</argument>
										<argument>ENOTEMPTY</argument>
										<argument>--include-macro</argument>
										<argument>EINVAL</argument>
										<!-- extract errno.h header: -->
										<argument>${linux.headerSearchPath}/errno.h</argument>
									</arguments>
								</configuration>
							</execution>
							<execution>
								<id>jextract-stat</id>
								<goals>
									<goal>exec</goal>
								</goals>
								<phase>generate-sources</phase>
								<configuration>
									<executable>${jextract.path}</executable>
									<workingDirectory>${project.basedir}</workingDirectory>
									<arguments>
										<argument>--source</argument>
										<argument>-d</argument>
										<argument>${project.build.sourceDirectory}</argument>
										<argument>-t</argument>
										<argument>org.cryptomator.jfuse.linux.amd64.extr</argument>
										<argument>-I</argument>
										<argument>${linux.headerSearchPath}</argument>
										<!-- file type bits -->
										<argument>--include-macro</argument>
										<argument>S_IFREG</argument>
										<argument>--include-macro</argument>
										<argument>S_IFDIR</argument>
										<argument>--include-macro</argument>
										<argument>S_IFLNK</argument>
										<!-- special utime values -->
										<argument>--include-macro</argument>
										<argument>UTIME_NOW</argument>
										<argument>--include-macro</argument>
										<argument>UTIME_OMIT</argument>
										<!-- extract sys/stat.h header: -->
										<argument>${linux.headerSearchPath}/sys/stat.h</argument>
									</arguments>
								</configuration>
							</execution>
							<execution>
								<id>jextract-fcntl</id>
								<goals>
									<goal>exec</goal>
								</goals>
								<phase>generate-sources</phase>
								<configuration>
									<executable>${jextract.path}</executable>
									<workingDirectory>${project.basedir}</workingDirectory>
									<arguments>
										<argument>--source</argument>
										<argument>-d</argument>
										<argument>${project.build.sourceDirectory}</argument>
										<argument>-t</argument>
										<argument>org.cryptomator.jfuse.linux.amd64.extr</argument>
										<argument>-I</argument>
										<argument>${linux.headerSearchPath}</argument>
										<!-- open flags -->
										<argument>--include-macro</argument>
										<argument>O_RDONLY</argument>
										<argument>--include-macro</argument>
										<argument>O_WRONLY</argument>
										<argument>--include-macro</argument>
										<argument>O_RDWR</argument>
										<argument>--include-macro</argument>
										<argument>O_APPEND</argument>
										<argument>--include-macro</argument>
										<argument>O_CREAT</argument>
										<argument>--include-macro</argument>
										<argument>O_TRUNC</argument>
										<argument>--include-macro</argument>
										<argument>O_EXCL</argument>
										<argument>--include-macro</argument>
										<argument>O_DSYNC</argument>
										<argument>--include-macro</argument>
										<argument>O_SYNC</argument>
										<!-- extract fcntl.h header: -->
										<argument>${linux.headerSearchPath}/fcntl.h</argument>
									</arguments>
								</configuration>
							</execution>
						</executions>
					</plugin>
				</plugins>
			</build>
		</profile>
	</profiles>

</project>