Makefile revision 1.81
1# $NetBSD: Makefile,v 1.81 2020/08/06 05:32:26 rillig Exp $ 2# @(#)Makefile 5.2 (Berkeley) 12/28/90 3 4PROG= make 5SRCS= arch.c buf.c compat.c cond.c dir.c for.c hash.c job.c lst.c main.c 6SRCS+= make.c make_malloc.c metachar.c parse.c 7SRCS+= str.c strlist.c suff.c targ.c trace.c var.c util.c 8 9# Whether to generate a coverage report after running the tests. 10USE_COVERAGE?= no # works only with gcc; clang9 fails to link 11.if ${USE_COVERAGE} == "yes" 12COPTS+= --coverage -O0 -ggdb 13LDADD+= --coverage 14CLEANFILES+= ${SRCS:.c=.gcda} ${SRCS:.c=.gcno} ${SRCS:=.gcov} 15.endif 16 17# Whether to compile using the Undefined Behavior Sanitizer (GCC, Clang). 18USE_UBSAN?= no 19.if ${USE_UBSAN} == "yes" 20COPTS+= -fsanitize=undefined 21LDADD+= -fsanitize=undefined 22.endif 23 24USE_META?= yes 25.if ${USE_META:tl} != "no" 26 27SRCS+= meta.c 28CPPFLAGS+= -DUSE_META 29 30USE_FILEMON?= ktrace 31. if ${USE_FILEMON:tl} != "no" 32 33.PATH: ${.CURDIR}/filemon 34SRCS+= filemon_${USE_FILEMON}.c 35CPPFLAGS+= -DUSE_FILEMON 36CPPFLAGS+= -DUSE_FILEMON_${USE_FILEMON:tu} 37 38. if ${USE_FILEMON} == "dev" 39FILEMON_H?= /usr/include/dev/filemon/filemon.h 40. if exists(${FILEMON_H}) && ${FILEMON_H:T} == "filemon.h" 41COPTS.filemon_dev.c+= \ 42 -DHAVE_FILEMON_H -I${FILEMON_H:H} 43. endif 44. endif 45. endif 46.endif 47 48SUBDIR.roff+= PSD.doc 49.if make(obj) || make(clean) 50SUBDIR+= unit-tests 51.endif 52 53${SRCS:M*.c:.c=.o}: buf.h config.h dir.h hash.h job.h lst.h make.h make_malloc.h 54${SRCS:M*.c:.c=.o}: meta.h metachar.h nonints.h pathnames.h sprite.h strlist.h trace.h 55 56.include <bsd.prog.mk> 57.include <bsd.subdir.mk> 58 59CPPFLAGS+= -DMAKE_NATIVE 60COPTS.var.c+= -Wno-cast-qual 61COPTS.job.c+= -Wno-format-nonliteral 62COPTS.parse.c+= -Wno-format-nonliteral 63COPTS.var.c+= -Wno-format-nonliteral 64 65.if defined(TOOLDIR) 66# This is a native NetBSD build, use libutil rather than the local emalloc etc. 67CPPFLAGS+= -DUSE_EMALLOC 68LDADD+= -lutil 69DPADD+= ${LIBUTIL} 70.endif 71 72COPTS.arch.c+= ${GCC_NO_FORMAT_TRUNCATION} 73COPTS.dir.c+= ${GCC_NO_FORMAT_TRUNCATION} 74COPTS.main.c+= ${GCC_NO_FORMAT_TRUNCATION} ${GCC_NO_STRINGOP_TRUNCATION} 75COPTS.meta.c+= ${GCC_NO_FORMAT_TRUNCATION} 76COPTS.parse.c+= ${GCC_NO_FORMAT_TRUNCATION} 77 78COPTS+= -Wdeclaration-after-statement 79 80# A simple unit-test driver to help catch regressions 81test: .MAKE 82 cd ${.CURDIR}/unit-tests \ 83 && MAKEFLAGS= ${.MAKE} -r -m / TEST_MAKE=${TEST_MAKE:U${.OBJDIR}/${PROG:T}} ${.TARGET} 84.if ${USE_COVERAGE} == yes 85 gcov ${SRCS} 86 sed -i 's,^\([^:]*\): *[0-9]*:,\1: ,' *.gcov 87.endif 88 89accept: .MAKE 90 cd ${.CURDIR}/unit-tests && ${.MAKE} ${.TARGET} 91 92retest: 93 ${.MAKE} -C ${.CURDIR}/unit-tests cleandir 94.if ${USE_COVERAGE} == yes 95 rm -f *.gcov *.gcda 96.endif 97 ${.MAKE} test 98