#!/usr/bin/make -f

# Okay, I admit.
# I only do these things in a weird way because, frankly, I can't get my head around how to
# make automake do the things I want it to do.

# Now, usage...
# Unlike traditional GNU packages, we have a shipped Makefile.
# We still have a ./configure script - and it's still autoconf, amazingly.
# However, it (can) be built from fragment files, which are scattered about, and gathered by
# this Makefile.
# We ship a default one, though, because not everyone has autoconf installed.
# Similarly, this Makefile builds its own parts.
# The result is something I can understand, that people who don't read the documentation
# will still run, probably without noticing it's any different.
# All in all, it's quite cunning, I think.
# The only bummer is that this needs GNU make, as far as I'm aware.

# So, to use:
# 1) If you've pulled this from Subversion, but don't have the autoconf development tools
# installed, then:
#     $ touch configure
#     This will stop the Makefile from rebuilding it. The Subversion tree has all this in,
#     by the way, so that different autoconf versions don't impact developers as much,
#     but this does mean that developers must rebuild configure before a commit if needs be.
# 2) If you want to pass specific options to configure, then just call configure normally.
#     If you don't know what options would be good for you, or don't care, then you can
#     skip this step. I always skip it outside of package building.
#     $ ./configure --enable-spiky-monsters --without-reading-documentation # Or whatever.
#     Yes, you'll probably need to read some documentation before this will do anything
#     particularly useful.
#     At least running "make help config" would be needed.
# 3) Now do the Make thing:
#     $ make
#     Note that this will, by default, just build sensible things. It'll dump them out into
#     a directory 'output'.
# 4) Now, or later, or whatever, probably as root:
#     # make install
#     Hopefully, you can now start the ACAP server in a sane way.

# Change these if you want. Or on the command line.
BUILDDIR=build
OUTPUTDIR=output
# If you do change them on the command line, you'll need to keep them consistent
# across different invocations of make.

###

# Best not to change these, but distributors see below.

# Targets get built by 'make all', or 'make'.
TARGETS=acapd acapd-real
# This stuff gets shoved into configure.ac during rebuild.
PACKAGE_NAME=infotrope-acapd
PACKAGE_VERSION=0.2.1
PACKAGE_MAINTAINER=dave@cridland.net
# This directory gets created, but also shipped. It contains stuff that gets built by
# maintainers, like configure.ac, stuff like that. It means that 'source' distributions are
# less painful.
MAINTDIR=src/maint-output
# The default configure options.
# BIG LEGAL NOTE TO DISTRIBUTORS:
# The GPL specifies that, in order to ship a binary, you must also ship sources which
# build *that* binary.
# So, unless you've a packaging system which supplies the configure arguments, (such as
# Debian's dpkg, or RedHat's RPM), *and* you're distributing the files used to build that
# package (As normally happens with debs and RPMs), you will need to change
# the default arguments as listed below. Otherwise you're in breach of the license.
CONFIGURE_OPTIONS=--enable-starttls --with-openssl --enable-xunique
# The above is how I generally build the thing while I develop... What I install is generally different.

###

-include SVNREV

all: targets support
.PHONY: all
everything: all tests
.PHONY: everything

targets: config.status
.PHONY: targets
support: config.status
.PHONY: support
tests: config.status
.PHONY: tests

# Actual funky stuff happens in here.
include src/build-sys/main
