1# $Id: autoconf.mk,v 1.21 2025/08/09 22:42:24 sjg Exp $ 2# 3# @(#) Copyright (c) 1996-2024, Simon J. Gerraty 4# 5# SPDX-License-Identifier: BSD-2-Clause 6# 7# Please send copies of changes and bug-fixes to: 8# sjg@crufty.net 9# 10 11.NOPATH: config.h config.gen config.recheck config.status 12 13CONFIGURE_DEPS += ${.CURDIR}/config.h.in ${.CURDIR}/configure 14 15.if !target(config.h) 16config.h: .NOTMAIN ${CONFIGURE_DEPS} config.status 17 ./config.status 18.if !empty(AUTOCONF_GENERATED_MAKEFILE) && ${AUTOCONF_GENERATED_MAKEFILE:T:@m@${"${.MAKE.MAKEFILES:T:M$m}":?yes:no}@:Mno} != "" 19 @echo Generated ${AUTOCONF_GENERATED_MAKEFILE}, you need to restart; exit 1 20.endif 21.endif 22 23.if !target(config.status) 24# avoid the targets behaving differently 25config.status: .NOTMAIN 26.if exists(${.OBJDIR}/config.status) 27config.status: config.recheck 28.else 29config.status: config.gen 30.endif 31 32beforebuild: .NOTMAIN config.status .WAIT 33 34config.recheck: .NOTMAIN ${CONFIGURE_DEPS} config.gen 35 ./config.status --recheck 36 @touch $@ 37 38config.gen: .NOTMAIN ${CONFIGURE_DEPS} 39 CC="${CC} ${CCMODE}" ${.CURDIR}/configure --no-create ${CONFIGURE_ARGS} 40 @touch $@ config.recheck 41 42CLEANFILES+= config.recheck config.gen config.status *.meta \ 43 ${AUTOCONF_GENERATED_MAKEFILE:U} 44.endif 45 46# avoid things blowing up if these are not here... 47# this is not quite per the autoconf manual, 48# and is extremely convoluted - but all utterly necessary! 49 50.if make(autoconf-input) || make(configure) || make(config.h.in) || ${MK_AUTO_AUTOCONF:Uno} == "yes" 51AUTOCONF ?= autoconf 52AUTOHEADER ?= autoheader 53 54# expand it to a full path 55AUTOCONF := ${AUTOCONF:${M_whence}} 56 57.if exists(${AUTOCONF}) 58 59.PRECIOUS: configure config.h.in config.status 60 61ACLOCAL = 62ACCONFIG = 63 64.if exists(${.CURDIR}/aclocal.m4) 65ACLOCAL += aclocal.m4 66.endif 67# use of acconfig.h is deprecated! 68.if exists(${.CURDIR}/acconfig.h) 69ACCONFIG += acconfig.h 70.endif 71.if exists(${.CURDIR}/configure.ac) 72CONFIGURE_SRC = ${.CURDIR}/configure.ac 73.else 74CONFIGURE_SRC ?= ${.CURDIR}/configure.in 75.endif 76 77config.h.in: .NOTMAIN ${CONFIGURE_SRC} ${ACCONFIG} 78 (cd ${.CURDIR} && ${AUTOHEADER}) 79 80configure: .NOTMAIN ${CONFIGURE_SRC} ${ACLOCAL} 81 (cd ${.CURDIR} && ${AUTOCONF}) 82 83AUTOCONF_INPUTS += configure 84.if exists(${.CURDIR}/config.h.in) 85AUTOCONF_INPUTS += config.h.in 86.endif 87 88autoconf-input: .NOTMAIN ${AUTOCONF_INPUTS} 89 90.endif 91.endif 92