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