1331246Ssjg# $Id: autoconf.mk,v 1.9 2017/08/13 20:03:13 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
18331246SsjgCONFIGURE_DEPS += ${.CURDIR}/config.h.in ${.CURDIR}/configure
19331246Ssjg
20246149Ssjg.if !target(config.h)
21331246Ssjgconfig.h:	${CONFIGURE_DEPS} config.status
22246149Ssjg	./config.status
23246149Ssjg.endif
24246149Ssjg
25246149Ssjg.if !target(config.status)
26246149Ssjg# avoid the targets behaving differently
27246149Ssjg.if exists(${.OBJDIR}/config.status)
28246149Ssjgconfig.status:	config.recheck
29246149Ssjg.else
30246149Ssjgconfig.status:  config.gen
31246149Ssjg.endif
32246149Ssjg
33331246Ssjgconfig.recheck: ${CONFIGURE_DEPS}
34246149Ssjg	./config.status --recheck
35246149Ssjg	@touch $@
36246149Ssjg
37331246Ssjgconfig.gen: ${CONFIGURE_DEPS}
38246149Ssjg	CC="${CC} ${CCMODE}" ${.CURDIR}/configure --no-create ${CONFIGURE_ARGS}
39246149Ssjg	@touch $@ config.recheck
40246149Ssjg
41246149SsjgCLEANFILES+= config.recheck config.gen config.status *.meta
42246149Ssjg.endif
43246149Ssjg
44246149Ssjg# avoid things blowing up if these are not here...
45246149Ssjg# this is not quite per the autoconf manual,
46246149Ssjg# and is extremely convoluted - but all utterly necessary!
47246149Ssjg
48246149Ssjg.if make(autoconf-in) || make(configure) || make(config.h.in) || ${AUTO_AUTOCONF:Uno:tl} == "yes"
49246149SsjgAUTOCONF ?= autoconf
50246149SsjgAUTOHEADER ?= autoheader
51246149Ssjg
52246149Ssjg# expand it to a full path 
53246149SsjgAUTOCONF := ${AUTOCONF:${M_whence}}
54246149Ssjg
55246149Ssjg.if exists(${AUTOCONF})
56246149Ssjg
57246149Ssjg.PRECIOUS: configure config.h.in config.status
58246149Ssjg
59246149SsjgACLOCAL =
60246149SsjgACCONFIG =
61246149Ssjg
62246149Ssjg.if exists(${.CURDIR}/aclocal.m4)
63246149SsjgACLOCAL += aclocal.m4
64246149Ssjg.endif
65246149Ssjg# use of acconfig.h is deprecated!
66246149Ssjg.if exists(${.CURDIR}/acconfig.h)
67246149SsjgACCONFIG += acconfig.h
68246149Ssjg.endif
69246149Ssjg
70246149Ssjgconfig.h.in:	${.CURDIR}/configure.in ${ACCONFIG}
71246149Ssjg	(cd ${.CURDIR} && ${AUTOHEADER})
72246149Ssjg
73246149Ssjgconfigure:	${.CURDIR}/configure.in ${ACLOCAL}
74246149Ssjg	(cd ${.CURDIR} && ${AUTOCONF})
75246149Ssjg
76246149SsjgAUTOCONF_INPUTS += configure
77246149Ssjgautoconf-input:	${AUTOCONF_INPUTS}
78246149Ssjg
79246149Ssjg.endif
80246149Ssjg.endif
81