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