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