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