Edit

IABSD.fr/src/usr.bin/make/Makefile

Branch :

  • Show log

    Commit

  • Author : tb
    Date : 2025-11-27 09:08:49
    Hash : 44f31e46
    Message : tweak make "magic variables" handling The idea is that it's shorter to special-case ${@D} and the likes (two characters variables ending in D or F) instead of having a weird idx encoding. Cons: - this yields an extra "ext" parameter to classify_var Pros: - the weird index encoding vanishes - no need for special treatment if we add more similar variables. - drastically reduces the size of the switch (and the modulo shrinks from 82 to 36) - code will recognize constructs like ${?D} and ${?F}, which puts us in line with FreeBSD and NetBSD bmake, and also with gnu make. from espie

  • usr.bin/make/Makefile
  • #	$OpenBSD: Makefile,v 1.66 2025/11/27 09:08:49 tb Exp $
    
    PROG=	make
    CFLAGS+= -I${.OBJDIR} -I${.CURDIR}
    HOSTCFLAGS+= -I${.OBJDIR} -I${.CURDIR}
    CDIAGFLAGS=-Wall -W -Wno-char-subscripts -Wstrict-prototypes -pedantic \
    	-Wmissing-prototypes -Wdeclaration-after-statement -std=c99
    
    CDEFS+=-DMAKE_BSIZE=256 -DDEFMAXJOBS=4
    #CDEFS+=-DHAS_STATS
    
    DPADD += ${LIBUTIL}
    LDADD += -lutil
    CFLAGS+=${CDEFS}
    HOSTCFLAGS+=${CDEFS}
    
    SRCS=	arch.c buf.c cmd_exec.c compat.c cond.c dir.c direxpand.c dump.c \
    	engine.c enginechoice.c error.c expandchildren.c \
    	for.c init.c job.c lowparse.c main.c make.c memory.c parse.c \
    	parsevar.c str.c stats.c suff.c targ.c targequiv.c timestamp.c \
    	var.c varmodifiers.c varname.c
    
    .include "${.CURDIR}/lst.lib/Makefile.inc"
    
    CLEANFILES+=generate generate.o regress.o check
    
    CLEANFILES+= varhashconsts.h condhashconsts.h nodehashconsts.h
    
    # may need tweaking if you add variable synonyms or change the hash function
    MAGICVARSLOTS=36
    MAGICCONDSLOTS=65
    
    varhashconsts.h: generate
    	${.OBJDIR}/generate 1 ${MAGICVARSLOTS} >$@.tmp && mv $@.tmp $@
    
    condhashconsts.h: generate
    	${.OBJDIR}/generate 2 ${MAGICCONDSLOTS} >$@.tmp && mv $@.tmp $@
    
    nodehashconsts.h: generate
    	${.OBJDIR}/generate 3 0 >$@.tmp && mv $@.tmp $@
    
    generate: generate.c stats.c memory.c ${DPADD}
    	${HOSTCC} ${HOSTCFLAGS} ${LDSTATIC} -o ${.TARGET} ${.ALLSRC} ${LDFLAGS} ${LDADD}
    
    CHECKOBJS = regress.o str.o memory.o buf.o
    
    check: ${CHECKOBJS} ${DPADD}
    	${CC} -o ${.TARGET} ${CFLAGS} ${CHECKOBJS} ${LDADD}
    
    regress: check
    	${.OBJDIR}/check
    
    var.o: varhashconsts.h
    cond.o: condhashconsts.h
    targ.o parse.o: nodehashconsts.h
    
    .PHONY:		regress
    
    .include <bsd.prog.mk>