1246149Ssjg# $Id: autoconf.mk,v 1.8 2012/11/19 05:37:48 sjg Exp $
2246149Ssjg#
3246149Ssjg#	@(#) Copyright (c) 1996-2009, Simon J. Gerraty
4246149Ssjg#
5246149Ssjg#	This file is provided in the hope that it will
6246149Ssjg#	be of use.  There is absolutely NO WARRANTY.
7246149Ssjg#	Permission to copy, redistribute or otherwise
8246149Ssjg#	use this file is hereby granted provided that 
9246149Ssjg#	the above copyright notice and this notice are
10246149Ssjg#	left intact. 
11246149Ssjg#      
12246149Ssjg#	Please send copies of changes and bug-fixes to:
13246149Ssjg#	sjg@crufty.net
14246149Ssjg#
15246149Ssjg
16246149Ssjg.NOPATH:	config.h config.status
17246149Ssjg
18246149Ssjg.if !target(config.h)
19246149Ssjgconfig.h:	${.CURDIR}/config.h.in config.status
20246149Ssjg	./config.status
21246149Ssjg.endif
22246149Ssjg
23246149Ssjg.if !target(config.status)
24246149Ssjg# avoid the targets behaving differently
25246149Ssjg.if exists(${.OBJDIR}/config.status)
26246149Ssjgconfig.status:	config.recheck
27246149Ssjg.else
28246149Ssjgconfig.status:  config.gen
29246149Ssjg.endif
30246149Ssjg
31246149Ssjgconfig.recheck: config.h.in ${.CURDIR}/configure
32246149Ssjg	./config.status --recheck
33246149Ssjg	@touch $@
34246149Ssjg
35246149Ssjgconfig.gen: config.h.in ${.CURDIR}/configure
36246149Ssjg	CC="${CC} ${CCMODE}" ${.CURDIR}/configure --no-create ${CONFIGURE_ARGS}
37246149Ssjg	@touch $@ config.recheck
38246149Ssjg
39246149SsjgCLEANFILES+= config.recheck config.gen config.status *.meta
40246149Ssjg.endif
41246149Ssjg
42246149Ssjg# avoid things blowing up if these are not here...
43246149Ssjg# this is not quite per the autoconf manual,
44246149Ssjg# and is extremely convoluted - but all utterly necessary!
45246149Ssjg
46246149Ssjg.if make(autoconf-in) || make(configure) || make(config.h.in) || ${AUTO_AUTOCONF:Uno:tl} == "yes"
47246149SsjgAUTOCONF ?= autoconf
48246149SsjgAUTOHEADER ?= autoheader
49246149Ssjg
50246149Ssjg# expand it to a full path 
51246149SsjgAUTOCONF := ${AUTOCONF:${M_whence}}
52246149Ssjg
53246149Ssjg.if exists(${AUTOCONF})
54246149Ssjg
55246149Ssjg.PRECIOUS: configure config.h.in config.status
56246149Ssjg
57246149SsjgACLOCAL =
58246149SsjgACCONFIG =
59246149Ssjg
60246149Ssjg.if exists(${.CURDIR}/aclocal.m4)
61246149SsjgACLOCAL += aclocal.m4
62246149Ssjg.endif
63246149Ssjg# use of acconfig.h is deprecated!
64246149Ssjg.if exists(${.CURDIR}/acconfig.h)
65246149SsjgACCONFIG += acconfig.h
66246149Ssjg.endif
67246149Ssjg
68246149Ssjgconfig.h.in:	${.CURDIR}/configure.in ${ACCONFIG}
69246149Ssjg	(cd ${.CURDIR} && ${AUTOHEADER})
70246149Ssjg
71246149Ssjgconfigure:	${.CURDIR}/configure.in ${ACLOCAL}
72246149Ssjg	(cd ${.CURDIR} && ${AUTOCONF})
73246149Ssjg
74246149SsjgAUTOCONF_INPUTS += configure
75246149Ssjgautoconf-input:	${AUTOCONF_INPUTS}
76246149Ssjg
77246149Ssjg.endif
78246149Ssjg.endif
79