<?xml version="1.0"?>
<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/maven-v4_0_0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<groupId>org.liblouis</groupId>
	<artifactId>louis</artifactId>
	<version>2.6.3</version>
	<packaging>nar</packaging>
	<name>liblouis-nar</name>
	<description>liblouis packaged in a NAR (Native ARchive).</description>
	<url>https://github.com/bertfrees/liblouis-nar</url>
	<scm>
		<connection>scm:git:git@github.com:bertfrees/liblouis-nar.git</connection>
		<developerConnection>scm:git:git@github.com:bertfrees/liblouis-nar.git</developerConnection>
		<url>git@github.com:bertfrees/liblouis-nar.git</url>
	</scm>
	<licenses>
		<license>
			<name>GNU Lesser General Public License 3</name>
			<url>http://www.gnu.org/licenses/lgpl.html</url>
		</license>
	</licenses>
	<developers>
		<developer>
			<name>Bert Frees</name>
			<email>bertfrees@gmail.com</email>
			<url>http://github.com/bertfrees</url>
			<organization>SBS - Schweizerische Bibliothek f&#xFC;r Blinde, Seh- und Lesebehinderte</organization>
			<organizationUrl>http://www.sbs.ch</organizationUrl>
		</developer>
	</developers>
	<properties>
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
		<nar.arch.option/>
		<nar.install_name.option/>
		<nar.rpath.option/>
		<nar.host.option/>
	</properties>
	<build>
		<plugins>
			<plugin>
				<artifactId>maven-scm-plugin</artifactId>
				<version>1.9</version>
				<executions>
					<execution>
						<id>checkout-sources</id>
						<phase>generate-sources</phase>
						<goals>
							<goal>checkout</goal>
						</goals>
						<configuration>
							<connectionUrl>scm:git:git://github.com/liblouis/liblouis.git</connectionUrl>
							<scmVersion>v2.6.3-1</scmVersion>
							<scmVersionType>tag</scmVersionType>
							<skipCheckoutIfExists>true</skipCheckoutIfExists>
						</configuration>
					</execution>
				</executions>
			</plugin>
			<plugin>
				<artifactId>maven-nar-plugin</artifactId>
				<version>2.1-SNAPSHOT</version>
				<extensions>true</extensions>
				<configuration>
					<gnuConfigureArgs>${nar.host.option}</gnuConfigureArgs>
					<libraries>
						<library>
							<type>shared</type>
						</library>
					</libraries>
				</configuration>
				<executions>
					<execution>
						<id>default-nar-gnu-resources</id>
						<phase>none</phase>
					</execution>
				</executions>
			</plugin>
			<plugin>
				<artifactId>maven-resources-plugin</artifactId>
				<executions>
					<execution>
						<id>copy-sources</id>
						<phase>generate-sources</phase>
						<goals>
							<goal>copy-resources</goal>
						</goals>
						<configuration>
							<outputDirectory>src/gnu</outputDirectory>
							<overwrite>true</overwrite>
							<resources>
								<resource>
									<directory>target/checkout</directory>
								</resource>
							</resources>
						</configuration>
					</execution>
					<execution>
						<id>copy-results</id>
						<phase>process-classes</phase>
						<goals>
							<goal>copy-resources</goal>
						</goals>
						<configuration>
							<outputDirectory>target/nar/louis-${project.version}-${nar.aol}-shared/lib/${nar.aol}/shared</outputDirectory>
							<resources>
								<resource>
									<directory>target/nar/gnu/${nar.aol}/target/lib</directory>
									<includes>
										<include>*.dll.a</include>
										<include>pkgconfig/*</include>
									</includes>
								</resource>
							</resources>
						</configuration>
					</execution>
				</executions>
			</plugin>
			<plugin>
				<groupId>org.codehaus.mojo</groupId>
				<artifactId>shell-maven-plugin</artifactId>
				<configuration>
					<chmod>true</chmod>
				</configuration>
				<executions>
					<execution>
						<id>process-sources</id>
						<phase>process-sources</phase>
						<goals>
							<goal>shell</goal>
						</goals>
						<configuration>
							<workDir>src/gnu</workDir>
							<script>
								#!/bin/sh
								sed \
								-e 's|^\(liblouis_la_LDFLAGS =\)\(.*\)$|\1 ${nar.install_name.option} ${nar.rpath.option} -avoid-version \2|' \
								../../target/checkout/liblouis/Makefile.am > liblouis/Makefile.am
								sed \
								-e 's|^\(AC_INIT(\[Liblouis\],\)[^,]*\(,.*\)$|\1 [${project.version}]\2|' \
								-e '/^AC_INIT.*$/a\
								CFLAGS="$CFLAGS ${nar.arch.option}"\
								' \
								../../target/checkout/configure.ac > configure.ac
								sed \
								-e '/^prefix=/d' \
								-e '/^exec_prefix=/d' \
								-e '/^tablesdir=/d' \
								-e 's|@libdir@|@NAR@/lib/${nar.aol}/shared|' \
								-e 's|@includedir@|@NAR@/include|' \
								../../target/checkout/liblouis.pc.in > liblouis.pc.in
							</script>
						</configuration>
					</execution>
				</executions>
			</plugin>
			<plugin>
				<artifactId>maven-clean-plugin</artifactId>
				<configuration>
					<filesets>
						<fileset>
							<directory>src</directory>
						</fileset>
					</filesets>
				</configuration>
			</plugin>
		</plugins>
	</build>
	<profiles>
		<profile>
			<id>i386</id>
			<activation>
				<property>
					<name>os.arch</name>
					<value>i386</value>
				</property>
			</activation>
			<properties>
				<nar.arch.option>-m32</nar.arch.option>
			</properties>
		</profile>
		<profile>
			<id>linux</id>
			<activation>
				<property>
					<name>os.name</name>
					<value>Linux</value>
				</property>
			</activation>
			<properties>
				<nar.rpath.option>-Wl,-rpath,".:\\\$\$ORIGIN",--enable-new-dtags</nar.rpath.option>
			</properties>
		</profile>
		<profile>
			<id>mac</id>
			<activation>
				<property>
					<name>os.name</name>
					<value>Mac OS X</value>
				</property>
			</activation>
			<properties>
				<nar.install_name.option>-Wl,-install_name,@loader_path/liblouis.dylib</nar.install_name.option>
			</properties>
		</profile>
		<profile>
			<id>cross-compile</id>
			<properties>
				<nar.arch.option></nar.arch.option>
				<nar.rpath.option></nar.rpath.option>
				<nar.install_name.option></nar.install_name.option>
				<nar.host.option>--host ${os.arch}-${host.os}</nar.host.option>
			</properties>
			<build>
				<plugins>
					<plugin>
						<artifactId>maven-nar-plugin</artifactId>
						<configuration>
							<os>${host.os}</os>
							<linker>
								<name>gpp</name>
							</linker>
						</configuration>
						<executions>
							<execution>
								<id>default-nar-validate</id>
								<phase>none</phase>
							</execution>
						</executions>
					</plugin>
				</plugins>
			</build>
		</profile>
		<profile>
			<id>sonatype-deploy</id>
			<build>
				<plugins>
					<plugin>
						<groupId>org.apache.maven.plugins</groupId>
						<artifactId>maven-gpg-plugin</artifactId>
						<version>1.4</version>
						<configuration>
							<useAgent>true</useAgent>
						</configuration>
						<executions>
							<execution>
								<id>sign-artifacts</id>
								<phase>verify</phase>
								<goals>
									<goal>sign</goal>
								</goals>
							</execution>
						</executions>
					</plugin>
				</plugins>
			</build>
		</profile>
	</profiles>
	<pluginRepositories>
		<pluginRepository>
			<id>bertfrees-github-snapshots</id>
			<url>http://bertfrees.github.com/snapshots</url>
		</pluginRepository>
		<pluginRepository>
			<id>duns-maven-snapshots</id>
			<url>http://duns.github.com/maven-snapshots</url>
		</pluginRepository>
	</pluginRepositories>
	<distributionManagement>
		<repository>
			<id>sonatype-nexus-staging</id>
			<name>oss.sonatype.org Staging Repository</name>
			<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
		</repository>
		<snapshotRepository>
			<id>sonatype-nexus-snapshots</id>
			<name>oss.sonatype.org github Release Repository Snapshot Repository</name>
			<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
		</snapshotRepository>
	</distributionManagement>
</project>
