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