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