Home | History | Annotate | Line # | Download | only in make
Makefile revision 1.80
      1 #	$NetBSD: Makefile,v 1.80 2020/08/06 05:27:31 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 TARGETS+=	retest
     57 
     58 .include <bsd.prog.mk>
     59 .include <bsd.subdir.mk>
     60 
     61 CPPFLAGS+=	-DMAKE_NATIVE
     62 COPTS.var.c+=	-Wno-cast-qual
     63 COPTS.job.c+=	-Wno-format-nonliteral
     64 COPTS.parse.c+=	-Wno-format-nonliteral
     65 COPTS.var.c+=	-Wno-format-nonliteral
     66 
     67 .if defined(TOOLDIR)
     68 # This is a native NetBSD build, use libutil rather than the local emalloc etc.
     69 CPPFLAGS+=	-DUSE_EMALLOC
     70 LDADD+=		-lutil
     71 DPADD+=		${LIBUTIL}
     72 .endif
     73 
     74 COPTS.arch.c+=	${GCC_NO_FORMAT_TRUNCATION}
     75 COPTS.dir.c+=	${GCC_NO_FORMAT_TRUNCATION}
     76 COPTS.main.c+=	${GCC_NO_FORMAT_TRUNCATION} ${GCC_NO_STRINGOP_TRUNCATION}
     77 COPTS.meta.c+=	${GCC_NO_FORMAT_TRUNCATION}
     78 COPTS.parse.c+=	${GCC_NO_FORMAT_TRUNCATION}
     79 
     80 COPTS+=		-Wdeclaration-after-statement
     81 
     82 # A simple unit-test driver to help catch regressions
     83 test: .MAKE
     84 	cd ${.CURDIR}/unit-tests \
     85 	&& MAKEFLAGS= ${.MAKE} -r -m / TEST_MAKE=${TEST_MAKE:U${.OBJDIR}/${PROG:T}} ${.TARGET}
     86 .if ${USE_COVERAGE} == yes
     87 	gcov ${SRCS}
     88 	sed -i 's,^\([^:]*\): *[0-9]*:,\1: ,' *.gcov
     89 .endif
     90 
     91 accept: .MAKE
     92 	cd ${.CURDIR}/unit-tests && ${.MAKE} ${.TARGET}
     93 
     94 retest:
     95 	${.MAKE} -C ${.CURDIR}/unit-tests cleandir
     96 .if ${USE_COVERAGE} == yes
     97 	rm -f *.gcov *.gcda
     98 .endif
     99 	${.MAKE} test
    100