Makefile revision 1.106
1# $NetBSD: Makefile,v 1.106 2020/10/25 13:25:19 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+= enum.c 11SRCS+= for.c 12SRCS+= hash.c 13SRCS+= job.c 14SRCS+= lst.c 15SRCS+= main.c 16SRCS+= make.c 17SRCS+= make_malloc.c 18SRCS+= metachar.c 19SRCS+= parse.c 20SRCS+= str.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+= enum.h 30HDRS+= hash.h 31HDRS+= job.h 32HDRS+= lst.h 33HDRS+= make.h 34HDRS+= make_malloc.h 35HDRS+= meta.h 36HDRS+= metachar.h 37HDRS+= nonints.h 38HDRS+= pathnames.h 39HDRS+= trace.h 40 41# Whether to generate a coverage report after running the tests. 42USE_COVERAGE?= no # works only with gcc; clang9 fails to link 43.if ${USE_COVERAGE} == "yes" 44GCOV?= gcov 45COPTS+= --coverage -O0 -ggdb 46LDADD+= --coverage 47.endif 48CLEANFILES+= *.gcda *.gcno *.gcov 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 57# Whether to compile with GCC 10 from pkgsrc, during development. 58USE_GCC10?= no 59.if ${USE_GCC10} == "yes" 60# CC is set further down in this file 61COPTS+= -Wno-attributes # for abs and labs 62COPTS.arch.c+= -Wno-error=format-truncation 63COPTS.dir.c+= -Wno-error=format-truncation 64COPTS.main.c+= -Wno-error=format-truncation 65COPTS.meta.c+= -Wno-error=format-truncation 66.endif 67 68# Whether to compile with GCC 9 from pkgsrc, during development. 69USE_GCC9?= no 70.if ${USE_GCC9} == "yes" 71# CC is set further down in this file 72COPTS+= -Wno-attributes # for abs and labs 73COPTS.arch.c+= -Wno-error=format-truncation 74COPTS.dir.c+= -Wno-error=format-truncation 75COPTS.main.c+= -Wno-error=format-truncation 76COPTS.meta.c+= -Wno-error=format-truncation 77.endif 78 79# Whether to compile with GCC 8 from pkgsrc, during development. 80USE_GCC8?= no 81.if ${USE_GCC8} == "yes" 82# CC is set further down in this file 83COPTS+= -Wno-attributes # for abs and labs 84COPTS.arch.c+= -Wno-error=format-truncation 85COPTS.dir.c+= -Wno-error=format-truncation 86COPTS.main.c+= -Wno-error=format-truncation 87COPTS.meta.c+= -Wno-error=format-truncation 88.endif 89 90USE_META?= yes 91.if ${USE_META:tl} != "no" 92 93SRCS+= meta.c 94CPPFLAGS+= -DUSE_META 95 96USE_FILEMON?= ktrace 97. if ${USE_FILEMON:tl} != "no" 98 99.PATH: ${.CURDIR}/filemon 100SRCS+= filemon_${USE_FILEMON}.c 101CPPFLAGS+= -DUSE_FILEMON 102CPPFLAGS+= -DUSE_FILEMON_${USE_FILEMON:tu} 103 104. if ${USE_FILEMON} == "dev" 105FILEMON_H?= /usr/include/dev/filemon/filemon.h 106. if exists(${FILEMON_H}) && ${FILEMON_H:T} == "filemon.h" 107COPTS.filemon_dev.c+= \ 108 -DHAVE_FILEMON_H -I${FILEMON_H:H} 109. endif 110. endif 111. endif 112.endif 113 114SUBDIR.roff+= PSD.doc 115.if make(obj) || make(clean) 116SUBDIR+= unit-tests 117.endif 118 119${SRCS:M*.c:.c=.o}: ${HDRS} 120CLEANFILES+= *.o 121 122.include <bsd.prog.mk> 123.include <bsd.subdir.mk> 124 125CPPFLAGS+= -DMAKE_NATIVE 126COPTS.job.c+= -Wno-format-nonliteral 127COPTS.parse.c+= -Wno-format-nonliteral 128COPTS.var.c+= -Wno-format-nonliteral 129 130.if ${USE_GCC10} == "yes" 131GCC10BASE?= /usr/pkg/gcc10 132CC= ${GCC10BASE}/bin/gcc 133GCOV= ${GCC10BASE}/bin/gcov 134.endif 135 136.if ${USE_GCC9} == "yes" 137GCC9BASE?= /usr/pkg/gcc9 138CC= ${GCC9BASE}/bin/gcc 139GCOV= ${GCC9BASE}/bin/gcov 140.endif 141 142.if ${USE_GCC8} == "yes" 143GCC8BASE?= /usr/pkg/gcc8 144CC= ${GCC8BASE}/bin/gcc 145GCOV= ${GCC8BASE}/bin/gcov 146.endif 147 148.if defined(TOOLDIR) 149# This is a native NetBSD build, use libutil rather than the local emalloc etc. 150CPPFLAGS+= -DUSE_EMALLOC 151LDADD+= -lutil 152DPADD+= ${LIBUTIL} 153.endif 154 155COPTS.arch.c+= ${GCC_NO_FORMAT_TRUNCATION} 156COPTS.dir.c+= ${GCC_NO_FORMAT_TRUNCATION} 157COPTS.main.c+= ${GCC_NO_FORMAT_TRUNCATION} ${GCC_NO_STRINGOP_TRUNCATION} 158COPTS.meta.c+= ${GCC_NO_FORMAT_TRUNCATION} 159 160COPTS+= -Wdeclaration-after-statement 161 162# For -DCLEANUP and similar feature toggles. 163CPPFLAGS+= ${USER_CPPFLAGS} 164# For overriding -std=gnu99 or similar options. 165CFLAGS+= ${USER_CFLAGS} 166 167# A simple unit-test driver to help catch regressions 168TEST_MAKE ?= ${.OBJDIR}/${PROG:T} 169test: .MAKE 170 cd ${.CURDIR}/unit-tests \ 171 && MAKEFLAGS= ${TEST_MAKE} -r -m / TEST_MAKE=${TEST_MAKE} ${TESTS:DTESTS=${TESTS:Q}} ${.TARGET} 172.if ${USE_COVERAGE} == yes 173 ${GCOV} ${GCOV_OPTS} ${SRCS} 174 sed -i 's,^\([^:]*\): *[0-9]*:,\1: ,' *.gcov 175.endif 176 177accept sync-mi: .MAKE 178 cd ${.CURDIR}/unit-tests && ${.MAKE} ${.TARGET} 179 180retest: 181 ${.MAKE} -C ${.CURDIR}/unit-tests cleandir 182.if ${USE_COVERAGE} == yes 183 rm -f *.gcov *.gcda 184.endif 185 ${.MAKE} test 186 187# Just out of curiosity, during development. 188.SUFFIXES: .cpre .casm 189.c.cpre: 190 ${COMPILE.c:S,^-c$,-E,} ${COPTS.${.IMPSRC}} ${.IMPSRC} -o ${.TARGET} 191.c.casm: 192 ${COMPILE.c:S,^-c$,-S,} ${COPTS.${.IMPSRC}} ${.IMPSRC} -o ${.TARGET} 193