Home | History | Annotate | Line # | Download | only in make
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 
      4 PROG=	make
      5 SRCS=	arch.c buf.c compat.c cond.c dir.c for.c hash.c job.c lst.c main.c
      6 SRCS+=	make.c make_malloc.c metachar.c parse.c
      7 SRCS+=	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.
     10 USE_COVERAGE?=	no		# works only with gcc; clang9 fails to link
     11 .if ${USE_COVERAGE} == "yes"
     12 COPTS+=		--coverage -O0 -ggdb
     13 LDADD+=		--coverage
     14 CLEANFILES+=	${SRCS:.c=.gcda} ${SRCS:.c=.gcno} ${SRCS:=.gcov}
     15 .endif
     16 
     17 # Whether to compile using the Undefined Behavior Sanitizer (GCC, Clang).
     18 USE_UBSAN?=	no
     19 .if ${USE_UBSAN} == "yes"
     20 COPTS+=		-fsanitize=undefined
     21 LDADD+=		-fsanitize=undefined
     22 .endif
     23 
     24 USE_META?=	yes
     25 .if ${USE_META:tl} != "no"
     26 
     27 SRCS+=		meta.c
     28 CPPFLAGS+=	-DUSE_META
     29 
     30 USE_FILEMON?=	ktrace
     31 .  if ${USE_FILEMON:tl} != "no"
     32 
     33 .PATH:	${.CURDIR}/filemon
     34 SRCS+=		filemon_${USE_FILEMON}.c
     35 CPPFLAGS+=	-DUSE_FILEMON
     36 CPPFLAGS+=	-DUSE_FILEMON_${USE_FILEMON:tu}
     37 
     38 .    if ${USE_FILEMON} == "dev"
     39 FILEMON_H?=	/usr/include/dev/filemon/filemon.h
     40 .      if exists(${FILEMON_H}) && ${FILEMON_H:T} == "filemon.h"
     41 COPTS.filemon_dev.c+= \
     42 		-DHAVE_FILEMON_H -I${FILEMON_H:H}
     43 .      endif
     44 .    endif
     45 .  endif
     46 .endif
     47 
     48 SUBDIR.roff+=	PSD.doc
     49 .if make(obj) || make(clean)
     50 SUBDIR+=	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 
     59 CPPFLAGS+=	-DMAKE_NATIVE
     60 COPTS.var.c+=	-Wno-cast-qual
     61 COPTS.job.c+=	-Wno-format-nonliteral
     62 COPTS.parse.c+=	-Wno-format-nonliteral
     63 COPTS.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.
     67 CPPFLAGS+=	-DUSE_EMALLOC
     68 LDADD+=		-lutil
     69 DPADD+=		${LIBUTIL}
     70 .endif
     71 
     72 COPTS.arch.c+=	${GCC_NO_FORMAT_TRUNCATION}
     73 COPTS.dir.c+=	${GCC_NO_FORMAT_TRUNCATION}
     74 COPTS.main.c+=	${GCC_NO_FORMAT_TRUNCATION} ${GCC_NO_STRINGOP_TRUNCATION}
     75 COPTS.meta.c+=	${GCC_NO_FORMAT_TRUNCATION}
     76 COPTS.parse.c+=	${GCC_NO_FORMAT_TRUNCATION}
     77 
     78 COPTS+=		-Wdeclaration-after-statement
     79 
     80 # A simple unit-test driver to help catch regressions
     81 test: .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 
     89 accept: .MAKE
     90 	cd ${.CURDIR}/unit-tests && ${.MAKE} ${.TARGET}
     91 
     92 retest:
     93 	${.MAKE} -C ${.CURDIR}/unit-tests cleandir
     94 .if ${USE_COVERAGE} == yes
     95 	rm -f *.gcov *.gcda
     96 .endif
     97 	${.MAKE} test
     98