xref: /freebsd/contrib/bmake/mk/autoconf.mk (revision c59c3bf34db360695f07735bebc76a768cac5afc)
1*c59c3bf3SSimon J. Gerraty# SPDX-License-Identifier: BSD-2-Clause
23cbdda60SSimon J. Gerraty#
3*c59c3bf3SSimon J. Gerraty# $Id: autoconf.mk,v 1.20 2024/02/17 17:26:57 sjg Exp $
4*c59c3bf3SSimon J. Gerraty#
5*c59c3bf3SSimon J. Gerraty#	@(#) Copyright (c) 1996-2024, Simon J. Gerraty
63cbdda60SSimon J. Gerraty#
73cbdda60SSimon J. Gerraty#	This file is provided in the hope that it will
83cbdda60SSimon J. Gerraty#	be of use.  There is absolutely NO WARRANTY.
93cbdda60SSimon J. Gerraty#	Permission to copy, redistribute or otherwise
103cbdda60SSimon J. Gerraty#	use this file is hereby granted provided that
113cbdda60SSimon J. Gerraty#	the above copyright notice and this notice are
123cbdda60SSimon J. Gerraty#	left intact.
133cbdda60SSimon J. Gerraty#
143cbdda60SSimon J. Gerraty#	Please send copies of changes and bug-fixes to:
153cbdda60SSimon J. Gerraty#	sjg@crufty.net
163cbdda60SSimon J. Gerraty#
173cbdda60SSimon J. Gerraty
1812904384SSimon J. Gerraty.NOPATH:	config.h config.gen config.recheck config.status
193cbdda60SSimon J. Gerraty
20e22fef7dSSimon J. GerratyCONFIGURE_DEPS += ${.CURDIR}/config.h.in ${.CURDIR}/configure
21e22fef7dSSimon J. Gerraty
223cbdda60SSimon J. Gerraty.if !target(config.h)
2312904384SSimon J. Gerratyconfig.h:	.NOTMAIN ${CONFIGURE_DEPS} config.status
243cbdda60SSimon J. Gerraty	./config.status
2512904384SSimon J. Gerraty.if !empty(AUTOCONF_GENERATED_MAKEFILE) && ${AUTOCONF_GENERATED_MAKEFILE:T:@m@${"${.MAKE.MAKEFILES:T:M$m}":?yes:no}@:Mno} != ""
2612904384SSimon J. Gerraty	@echo Generated ${AUTOCONF_GENERATED_MAKEFILE}, you need to restart; exit 1
2712904384SSimon J. Gerraty.endif
283cbdda60SSimon J. Gerraty.endif
293cbdda60SSimon J. Gerraty
303cbdda60SSimon J. Gerraty.if !target(config.status)
313cbdda60SSimon J. Gerraty# avoid the targets behaving differently
3212904384SSimon J. Gerratyconfig.status:	.NOTMAIN
333cbdda60SSimon J. Gerraty.if exists(${.OBJDIR}/config.status)
343cbdda60SSimon J. Gerratyconfig.status:	config.recheck
353cbdda60SSimon J. Gerraty.else
363cbdda60SSimon J. Gerratyconfig.status:  config.gen
373cbdda60SSimon J. Gerraty.endif
383cbdda60SSimon J. Gerraty
398c973ee2SSimon J. Gerratybeforebuild: .NOTMAIN config.status .WAIT
40dc1b8c9aSSimon J. Gerraty
4112904384SSimon J. Gerratyconfig.recheck: .NOTMAIN ${CONFIGURE_DEPS} config.gen
423cbdda60SSimon J. Gerraty	./config.status --recheck
433cbdda60SSimon J. Gerraty	@touch $@
443cbdda60SSimon J. Gerraty
4512904384SSimon J. Gerratyconfig.gen: .NOTMAIN ${CONFIGURE_DEPS}
463cbdda60SSimon J. Gerraty	CC="${CC} ${CCMODE}" ${.CURDIR}/configure --no-create ${CONFIGURE_ARGS}
473cbdda60SSimon J. Gerraty	@touch $@ config.recheck
483cbdda60SSimon J. Gerraty
4912904384SSimon J. GerratyCLEANFILES+= config.recheck config.gen config.status *.meta \
5012904384SSimon J. Gerraty	${AUTOCONF_GENERATED_MAKEFILE:U}
513cbdda60SSimon J. Gerraty.endif
523cbdda60SSimon J. Gerraty
533cbdda60SSimon J. Gerraty# avoid things blowing up if these are not here...
543cbdda60SSimon J. Gerraty# this is not quite per the autoconf manual,
553cbdda60SSimon J. Gerraty# and is extremely convoluted - but all utterly necessary!
563cbdda60SSimon J. Gerraty
57*c59c3bf3SSimon J. Gerraty.if make(autoconf-input) || make(configure) || make(config.h.in) || ${MK_AUTO_AUTOCONF:Uno} == "yes"
583cbdda60SSimon J. GerratyAUTOCONF ?= autoconf
593cbdda60SSimon J. GerratyAUTOHEADER ?= autoheader
603cbdda60SSimon J. Gerraty
613cbdda60SSimon J. Gerraty# expand it to a full path
623cbdda60SSimon J. GerratyAUTOCONF := ${AUTOCONF:${M_whence}}
633cbdda60SSimon J. Gerraty
643cbdda60SSimon J. Gerraty.if exists(${AUTOCONF})
653cbdda60SSimon J. Gerraty
663cbdda60SSimon J. Gerraty.PRECIOUS: configure config.h.in config.status
673cbdda60SSimon J. Gerraty
683cbdda60SSimon J. GerratyACLOCAL =
693cbdda60SSimon J. GerratyACCONFIG =
703cbdda60SSimon J. Gerraty
713cbdda60SSimon J. Gerraty.if exists(${.CURDIR}/aclocal.m4)
723cbdda60SSimon J. GerratyACLOCAL += aclocal.m4
733cbdda60SSimon J. Gerraty.endif
743cbdda60SSimon J. Gerraty# use of acconfig.h is deprecated!
753cbdda60SSimon J. Gerraty.if exists(${.CURDIR}/acconfig.h)
763cbdda60SSimon J. GerratyACCONFIG += acconfig.h
773cbdda60SSimon J. Gerraty.endif
78*c59c3bf3SSimon J. Gerraty.if exists(${.CURDIR}/configure.ac)
79*c59c3bf3SSimon J. GerratyCONFIGURE_SRC = ${.CURDIR}/configure.ac
80*c59c3bf3SSimon J. Gerraty.else
81*c59c3bf3SSimon J. GerratyCONFIGURE_SRC ?= ${.CURDIR}/configure.in
82*c59c3bf3SSimon J. Gerraty.endif
833cbdda60SSimon J. Gerraty
84*c59c3bf3SSimon J. Gerratyconfig.h.in:	.NOTMAIN ${CONFIGURE_SRC} ${ACCONFIG}
853cbdda60SSimon J. Gerraty	(cd ${.CURDIR} && ${AUTOHEADER})
863cbdda60SSimon J. Gerraty
87*c59c3bf3SSimon J. Gerratyconfigure:	.NOTMAIN ${CONFIGURE_SRC} ${ACLOCAL}
883cbdda60SSimon J. Gerraty	(cd ${.CURDIR} && ${AUTOCONF})
893cbdda60SSimon J. Gerraty
903cbdda60SSimon J. GerratyAUTOCONF_INPUTS += configure
91*c59c3bf3SSimon J. Gerraty.if exists(${.CURDIR}/config.h.in)
92*c59c3bf3SSimon J. GerratyAUTOCONF_INPUTS += config.h.in
93*c59c3bf3SSimon J. Gerraty.endif
94*c59c3bf3SSimon J. Gerraty
9512904384SSimon J. Gerratyautoconf-input:	.NOTMAIN ${AUTOCONF_INPUTS}
963cbdda60SSimon J. Gerraty
973cbdda60SSimon J. Gerraty.endif
983cbdda60SSimon J. Gerraty.endif
99