xref: /freebsd/contrib/bmake/mk/autoconf.mk (revision 62cfcf62f627e5093fb37026a6d8c98e4d2ef04c)
1# $Id: autoconf.mk,v 1.9 2017/08/13 20:03:13 sjg Exp $
2#
3#	@(#) Copyright (c) 1996-2009, Simon J. Gerraty
4#
5#	This file is provided in the hope that it will
6#	be of use.  There is absolutely NO WARRANTY.
7#	Permission to copy, redistribute or otherwise
8#	use this file is hereby granted provided that
9#	the above copyright notice and this notice are
10#	left intact.
11#
12#	Please send copies of changes and bug-fixes to:
13#	sjg@crufty.net
14#
15
16.NOPATH:	config.h config.status
17
18CONFIGURE_DEPS += ${.CURDIR}/config.h.in ${.CURDIR}/configure
19
20.if !target(config.h)
21config.h:	${CONFIGURE_DEPS} config.status
22	./config.status
23.endif
24
25.if !target(config.status)
26# avoid the targets behaving differently
27.if exists(${.OBJDIR}/config.status)
28config.status:	config.recheck
29.else
30config.status:  config.gen
31.endif
32
33config.recheck: ${CONFIGURE_DEPS}
34	./config.status --recheck
35	@touch $@
36
37config.gen: ${CONFIGURE_DEPS}
38	CC="${CC} ${CCMODE}" ${.CURDIR}/configure --no-create ${CONFIGURE_ARGS}
39	@touch $@ config.recheck
40
41CLEANFILES+= config.recheck config.gen config.status *.meta
42.endif
43
44# avoid things blowing up if these are not here...
45# this is not quite per the autoconf manual,
46# and is extremely convoluted - but all utterly necessary!
47
48.if make(autoconf-in) || make(configure) || make(config.h.in) || ${AUTO_AUTOCONF:Uno:tl} == "yes"
49AUTOCONF ?= autoconf
50AUTOHEADER ?= autoheader
51
52# expand it to a full path
53AUTOCONF := ${AUTOCONF:${M_whence}}
54
55.if exists(${AUTOCONF})
56
57.PRECIOUS: configure config.h.in config.status
58
59ACLOCAL =
60ACCONFIG =
61
62.if exists(${.CURDIR}/aclocal.m4)
63ACLOCAL += aclocal.m4
64.endif
65# use of acconfig.h is deprecated!
66.if exists(${.CURDIR}/acconfig.h)
67ACCONFIG += acconfig.h
68.endif
69
70config.h.in:	${.CURDIR}/configure.in ${ACCONFIG}
71	(cd ${.CURDIR} && ${AUTOHEADER})
72
73configure:	${.CURDIR}/configure.in ${ACLOCAL}
74	(cd ${.CURDIR} && ${AUTOCONF})
75
76AUTOCONF_INPUTS += configure
77autoconf-input:	${AUTOCONF_INPUTS}
78
79.endif
80.endif
81