<?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>
	<parent>
		<groupId>org.daisy</groupId>
		<artifactId>daisy</artifactId>
		<version>2</version>
		<relativePath/>
	</parent>
	<groupId>org.daisy.libs</groupId>
	<artifactId>hyphen</artifactId>
	<version>2.6.0</version>
	<packaging>nar</packaging>
	<name>libhyphen-nar</name>
	<description>libhyphen packaged in a NAR (Native ARchive).</description>
	<url>https://github.com/bertfrees/libhyphen-nar</url>
	<scm>
		<connection>scm:git:git@github.com:bertfrees/libhyphen-nar.git</connection>
		<developerConnection>scm:git:git@github.com:bertfrees/libhyphen-nar.git</developerConnection>
		<url>git@github.com:bertfrees/libhyphen-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.8.1</version>
				<executions>
					<execution>
						<id>checkout-sources</id>
						<phase>generate-sources</phase>
						<goals>
							<goal>checkout</goal>
						</goals>
						<configuration>
							<connectionUrl>scm:cvs:pserver:anonymous:@hunspell.cvs.sourceforge.net:/cvsroot/hunspell:hyphen</connectionUrl>
							<scmVersion>release-2-6</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/hyphen-${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>
									</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|^\(libhyphen_la_LDFLAGS =\)\(.*\)$|\1 ${nar.install_name.option} ${nar.rpath.option} -avoid-version \2|' \
								../../target/checkout/Makefile.am > Makefile.am
								sed \
								-e '/^AC_INIT.*$/a\
								CFLAGS="$CFLAGS ${nar.arch.option}"\
								' \
								../../target/checkout/configure.in > configure.in
								rm configure
								rm Makefile.in
								echo Running autoreconf...
								autoreconf --force --install
								chmod +x tbhyphext.sh
							</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/libhyphen.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>
	</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>
</project>
