1# $Id: autoconf.mk,v 1.18 2023/03/22 15:37:19 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.gen config.recheck config.status 17 18CONFIGURE_DEPS += ${.CURDIR}/config.h.in ${.CURDIR}/configure 19 20.if !target(config.h) 21config.h: .NOTMAIN ${CONFIGURE_DEPS} config.status 22 ./config.status 23.if !empty(AUTOCONF_GENERATED_MAKEFILE) && ${AUTOCONF_GENERATED_MAKEFILE:T:@m@${"${.MAKE.MAKEFILES:T:M$m}":?yes:no}@:Mno} != "" 24 @echo Generated ${AUTOCONF_GENERATED_MAKEFILE}, you need to restart; exit 1 25.endif 26.endif 27 28.if !target(config.status) 29# avoid the targets behaving differently 30config.status: .NOTMAIN 31.if exists(${.OBJDIR}/config.status) 32config.status: config.recheck 33.else 34config.status: config.gen 35.endif 36 37beforebuild: .NOTMAIN config.status .WAIT 38 39config.recheck: .NOTMAIN ${CONFIGURE_DEPS} config.gen 40 ./config.status --recheck 41 @touch $@ 42 43config.gen: .NOTMAIN ${CONFIGURE_DEPS} 44 CC="${CC} ${CCMODE}" ${.CURDIR}/configure --no-create ${CONFIGURE_ARGS} 45 @touch $@ config.recheck 46 47CLEANFILES+= config.recheck config.gen config.status *.meta \ 48 ${AUTOCONF_GENERATED_MAKEFILE:U} 49.endif 50 51# avoid things blowing up if these are not here... 52# this is not quite per the autoconf manual, 53# and is extremely convoluted - but all utterly necessary! 54 55.if make(autoconf-in) || make(configure) || make(config.h.in) || ${AUTO_AUTOCONF:Uno:tl} == "yes" 56AUTOCONF ?= autoconf 57AUTOHEADER ?= autoheader 58 59# expand it to a full path 60AUTOCONF := ${AUTOCONF:${M_whence}} 61 62.if exists(${AUTOCONF}) 63 64.PRECIOUS: configure config.h.in config.status 65 66ACLOCAL = 67ACCONFIG = 68 69.if exists(${.CURDIR}/aclocal.m4) 70ACLOCAL += aclocal.m4 71.endif 72# use of acconfig.h is deprecated! 73.if exists(${.CURDIR}/acconfig.h) 74ACCONFIG += acconfig.h 75.endif 76 77config.h.in: .NOTMAIN ${.CURDIR}/configure.in ${ACCONFIG} 78 (cd ${.CURDIR} && ${AUTOHEADER}) 79 80configure: .NOTMAIN ${.CURDIR}/configure.in ${ACLOCAL} 81 (cd ${.CURDIR} && ${AUTOCONF}) 82 83AUTOCONF_INPUTS += configure 84autoconf-input: .NOTMAIN ${AUTOCONF_INPUTS} 85 86.endif 87.endif 88