unstack, sort: cleanup and improvement
[minix.git] / share / mk / bsd.own.mk
blob362a134bcea11a695fa2b678d62c981104f3a8a2
1 # $NetBSD: bsd.own.mk,v 1.603 2009/12/06 16:15:15 uebayasi Exp $
3 .if !defined(_MINIX_OWN_MK_)
4 _MINIX_OWN_MK_=1
6 .ifdef CONFIG_SMP
7 SMP_FLAGS += -DCONFIG_SMP
8 .ifdef CONFIG_MAX_CPUS
9 SMP_FLAGS += -DCONFIG_MAX_CPUS=${CONFIG_MAX_CPUS}
10 .endif
11 .endif
13 CPPFLAGS+= ${SMP_FLAGS}
15 MAKECONF?= /etc/make.conf
16 .-include "${MAKECONF}"
18 .ifdef NOASSERTS
19 CFLAGS += -DNDEBUG=1
20 .endif
23 # CPU model, derived from MACHINE_ARCH
25 MACHINE_CPU= ${MACHINE_ARCH:C/mipse[bl]/mips/:C/mips64e[bl]/mips/:C/sh3e[bl]/sh3/:S/m68000/m68k/:S/armeb/arm/}
28 # Subdirectory used below ${RELEASEDIR} when building a release
30 RELEASEMACHINEDIR?= ${MACHINE}
33 # Subdirectory or path component used for the following paths:
34 # distrib/${RELEASEMACHINE}
35 # distrib/notes/${RELEASEMACHINE}
36 # etc/etc.${RELEASEMACHINE}
37 # Used when building a release.
39 RELEASEMACHINE?= ${MACHINE}
42 # NEED_OWN_INSTALL_TARGET is set to "no" by pkgsrc/mk/bsd.pkg.mk to
43 # ensure that things defined by <bsd.own.mk> (default targets,
44 # INSTALL_FILE, etc.) are not conflicting with bsd.pkg.mk.
46 NEED_OWN_INSTALL_TARGET?= yes
49 # This lists the platforms which do not have working in-tree toolchains.
50 # For the in-tree gcc 3.3.2 toolchain, this list is empty.
51 # If some future port is not supported by the in-tree toolchain, this
52 # should be set to "yes" for that port only.
54 TOOLCHAIN_MISSING?= no
56 # default to GCC4
57 .if !defined(HAVE_GCC) && !defined(HAVE_PCC)
58 HAVE_GCC= 4
59 .if !defined(_GCC_LIBGCCDIR)
60 _GCC_LIBGCCDIR= ${DESTDIR}/usr/lib
61 .endif
62 .endif
64 .if \
65 ${MACHINE_ARCH} == "i386" || \
66 ${MACHINE_ARCH} == "powerpc" || \
67 ${MACHINE_ARCH} == "x86_64"
68 USE_COMPILERCRTSTUFF?= no
69 .endif
70 USE_COMPILERCRTSTUFF?= yes
72 USE_FORT?= no
74 # default to GDB6
75 HAVE_GDB?= 6
77 # default to binutils 2.19
78 HAVE_BINUTILS?= 219
80 CPPFLAG_ISYSTEM= -isystem
81 .if defined(HAVE_GCC)
82 .if ${HAVE_GCC} == 3
83 CPPFLAG_ISYSTEMXX= -isystem-cxx
84 .else # GCC 4
85 CPPFLAG_ISYSTEMXX= -cxx-isystem
86 .endif
87 .endif
89 .if empty(.MAKEFLAGS:M-V*)
90 .if defined(MAKEOBJDIRPREFIX) || defined(MAKEOBJDIR)
91 PRINTOBJDIR= ${MAKE} -r -V .OBJDIR -f /dev/null xxx
92 .else
93 PRINTOBJDIR= ${MAKE} -V .OBJDIR
94 .endif
95 .else
96 PRINTOBJDIR= echo # prevent infinite recursion
97 .endif
101 # Determine if running in the NetBSD source tree by checking for the
102 # existence of build.sh and tools/ in the current or a parent directory,
103 # and setting _SRC_TOP_ to the result.
105 .if !defined(_SRC_TOP_) # {
106 _SRC_TOP_!= cd ${.CURDIR}; while :; do \
107 here=`pwd`; \
108 [ -f build.sh ] && [ -d tools ] && { echo $$here; break; }; \
109 case $$here in /) echo ""; break;; esac; \
110 cd ..; done
112 .MAKEOVERRIDES+= _SRC_TOP_
114 .endif # }
117 # If _SRC_TOP_ != "", we're within the NetBSD source tree, so set
118 # defaults for NETBSDSRCDIR and _SRC_TOP_OBJ_.
120 .if (${_SRC_TOP_} != "") # {
122 NETBSDSRCDIR?= ${_SRC_TOP_}
124 .if !defined(_SRC_TOP_OBJ_)
125 _SRC_TOP_OBJ_!= cd ${_SRC_TOP_} && ${PRINTOBJDIR}
126 .MAKEOVERRIDES+= _SRC_TOP_OBJ_
127 .endif
129 .endif # _SRC_TOP_ != "" # }
132 .if (${_SRC_TOP_} != "") && \
133 (${TOOLCHAIN_MISSING} == "no" || defined(EXTERNAL_TOOLCHAIN))
134 .if (defined(BUILDSH))
135 USETOOLS?= yes
136 .endif
137 .endif
138 USETOOLS?= no
141 .if ${MACHINE_ARCH} == "mips" || ${MACHINE_ARCH} == "mips64" || \
142 ${MACHINE_ARCH} == "sh3"
143 .BEGIN:
144 @echo "Must set MACHINE_ARCH to one of ${MACHINE_ARCH}eb or ${MACHINE_ARCH}el"
145 @false
146 .elif defined(REQUIRETOOLS) && \
147 (${TOOLCHAIN_MISSING} == "no" || defined(EXTERNAL_TOOLCHAIN)) && \
148 ${USETOOLS} == "no"
149 .BEGIN:
150 @echo "USETOOLS=no, but this component requires a version-specific host toolchain"
151 @false
152 .endif
155 # Host platform information; may be overridden
157 .if !defined(HOST_OSTYPE)
158 _HOST_OSNAME!= uname -s
159 _HOST_OSREL!= uname -r
160 # For _HOST_ARCH, if uname -p fails, or prints "unknown", or prints
161 # something that does not look like an identifier, then use uname -m.
162 _HOST_ARCH!= uname -p 2>/dev/null
163 _HOST_ARCH:= ${HOST_ARCH:tW:C/.*[^-_A-Za-z0-9].*//:S/unknown//}
164 .if empty(_HOST_ARCH)
165 _HOST_ARCH!= uname -m
166 .endif
167 HOST_OSTYPE:= ${_HOST_OSNAME}-${_HOST_OSREL:C/\([^\)]*\)//g:[*]:C/ /_/g}-${_HOST_ARCH:C/\([^\)]*\)//g:[*]:C/ /_/g}
168 .MAKEOVERRIDES+= HOST_OSTYPE
169 .endif # !defined(HOST_OSTYPE)
171 .if ${USETOOLS} == "yes" # {
174 # Provide a default for TOOLDIR.
176 .if !defined(TOOLDIR)
177 TOOLDIR:= ${_SRC_TOP_OBJ_}/tooldir.${HOST_OSTYPE}
178 .MAKEOVERRIDES+= TOOLDIR
179 .endif
182 # This is the prefix used for the NetBSD-sourced tools.
184 _TOOL_PREFIX?= nb
187 # If an external toolchain base is specified, use it.
189 .if defined(EXTERNAL_TOOLCHAIN) # {
190 AR= ${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-ar
191 AS= ${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-as
192 LD= ${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-ld
193 NM= ${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-nm
194 OBJCOPY= ${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-objcopy
195 OBJDUMP= ${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-objdump
196 RANLIB= ${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-ranlib
197 SIZE= ${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-size
198 STRIP= ${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-strip
200 CC= ${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-gcc
201 CPP= ${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-cpp
202 CXX= ${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-c++
203 FC= ${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-g77
204 OBJC= ${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-gcc
205 .else # } {
206 # Define default locations for common tools.
207 .if ${USETOOLS_BINUTILS:Uyes} == "yes" # {
208 AR= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-ar
209 AS= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-as
210 LD= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-ld
211 NM= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-nm
212 OBJCOPY= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-objcopy
213 OBJDUMP= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-objdump
214 RANLIB= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-ranlib
215 SIZE= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-size
216 STRIP= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-strip
217 .endif # }
219 .if defined(HAVE_GCC) && ${USETOOLS_GCC:Uyes} == "yes" # {
220 CC= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-gcc
221 CPP= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-cpp
222 CXX= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-c++
223 FC= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-g77
224 OBJC= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-gcc
225 .endif # }
227 .if defined(HAVE_PCC) && ${USETOOLS_PCC:Uyes} == "yes"
228 CC= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-pcc
229 CPP= ${TOOLDIR}/libexec/${MACHINE_GNU_PLATFORM}-cpp
230 CXX= false
231 FC= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-f77
232 OBJC= false
233 .endif
235 .endif # EXTERNAL_TOOLCHAIN # }
237 HOST_MKDEP= ${TOOLDIR}/bin/${_TOOL_PREFIX}host-mkdep
239 DBSYM= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-dbsym
240 ELF2ECOFF= ${TOOLDIR}/bin/${_TOOL_PREFIX}mips-elf2ecoff
241 INSTALL= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-install
242 LEX= ${TOOLDIR}/bin/${_TOOL_PREFIX}lex
243 LINT= CC=${CC:Q} ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-lint
244 LORDER= NM=${NM:Q} MKTEMP=${TOOL_MKTEMP:Q} ${TOOLDIR}/bin/${_TOOL_PREFIX}lorder
245 MKDEP= CC=${CC:Q} ${TOOLDIR}/bin/${_TOOL_PREFIX}mkdep
246 PAXCTL= ${TOOLDIR}/bin/${_TOOL_PREFIX}paxctl
247 TSORT= ${TOOLDIR}/bin/${_TOOL_PREFIX}tsort -q
248 YACC= ${TOOLDIR}/bin/${_TOOL_PREFIX}yacc
250 TOOL_AMIGAAOUT2BB= ${TOOLDIR}/bin/${_TOOL_PREFIX}amiga-aout2bb
251 TOOL_AMIGAELF2BB= ${TOOLDIR}/bin/${_TOOL_PREFIX}amiga-elf2bb
252 TOOL_AMIGATXLT= ${TOOLDIR}/bin/${_TOOL_PREFIX}amiga-txlt
253 TOOL_ASN1_COMPILE= ${TOOLDIR}/bin/${_TOOL_PREFIX}asn1_compile
254 TOOL_ATF_COMPILE= ${TOOLDIR}/bin/${_TOOL_PREFIX}atf-compile
255 TOOL_AWK= ${TOOLDIR}/bin/${_TOOL_PREFIX}awk
256 TOOL_CAP_MKDB= ${TOOLDIR}/bin/${_TOOL_PREFIX}cap_mkdb
257 TOOL_CAT= ${TOOLDIR}/bin/${_TOOL_PREFIX}cat
258 TOOL_CKSUM= ${TOOLDIR}/bin/${_TOOL_PREFIX}cksum
259 TOOL_COMPILE_ET= ${TOOLDIR}/bin/${_TOOL_PREFIX}compile_et
260 TOOL_CONFIG= ${TOOLDIR}/bin/${_TOOL_PREFIX}config
261 TOOL_CRUNCHGEN= MAKE=${.MAKE:Q} ${TOOLDIR}/bin/${_TOOL_PREFIX}crunchgen
262 TOOL_CTAGS= ${TOOLDIR}/bin/${_TOOL_PREFIX}ctags
263 TOOL_DB= ${TOOLDIR}/bin/${_TOOL_PREFIX}db
264 TOOL_DISKLABEL= ${TOOLDIR}/bin/nbdisklabel-${MAKEWRAPPERMACHINE}
265 TOOL_EQN= ${TOOLDIR}/bin/${_TOOL_PREFIX}eqn
266 TOOL_FDISK= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-fdisk
267 TOOL_FGEN= ${TOOLDIR}/bin/${_TOOL_PREFIX}fgen
268 TOOL_GENASSYM= ${TOOLDIR}/bin/${_TOOL_PREFIX}genassym
269 TOOL_GENCAT= ${TOOLDIR}/bin/${_TOOL_PREFIX}gencat
270 TOOL_GMAKE= ${TOOLDIR}/bin/${_TOOL_PREFIX}gmake
271 TOOL_GREP= ${TOOLDIR}/bin/${_TOOL_PREFIX}grep
272 TOOL_GROFF= PATH=${TOOLDIR}/lib/groff:$${PATH} ${TOOLDIR}/bin/${_TOOL_PREFIX}groff
273 TOOL_HEXDUMP= ${TOOLDIR}/bin/${_TOOL_PREFIX}hexdump
274 TOOL_HP300MKBOOT= ${TOOLDIR}/bin/${_TOOL_PREFIX}hp300-mkboot
275 TOOL_HP700MKBOOT= ${TOOLDIR}/bin/${_TOOL_PREFIX}hp700-mkboot
276 TOOL_INDXBIB= ${TOOLDIR}/bin/${_TOOL_PREFIX}indxbib
277 TOOL_INSTALLBOOT= ${TOOLDIR}/bin/${_TOOL_PREFIX}installboot
278 TOOL_INSTALL_INFO= ${TOOLDIR}/bin/${_TOOL_PREFIX}install-info
279 TOOL_JOIN= ${TOOLDIR}/bin/${_TOOL_PREFIX}join
280 TOOL_M4= ${TOOLDIR}/bin/${_TOOL_PREFIX}m4
281 TOOL_MACPPCFIXCOFF= ${TOOLDIR}/bin/${_TOOL_PREFIX}macppc-fixcoff
282 TOOL_MAKEFS= ${TOOLDIR}/bin/${_TOOL_PREFIX}makefs
283 TOOL_MAKEINFO= ${TOOLDIR}/bin/${_TOOL_PREFIX}makeinfo
284 TOOL_MAKEWHATIS= ${TOOLDIR}/bin/${_TOOL_PREFIX}makewhatis
285 TOOL_MANDOC_ASCII= ${TOOLDIR}/bin/${_TOOL_PREFIX}mandoc -Tascii
286 TOOL_MANDOC_HTML= ${TOOLDIR}/bin/${_TOOL_PREFIX}mandoc -Thtml
287 TOOL_MANDOC_LINT= ${TOOLDIR}/bin/${_TOOL_PREFIX}mandoc -Tlint
288 TOOL_MDSETIMAGE= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-mdsetimage
289 TOOL_MENUC= MENUDEF=${TOOLDIR}/share/misc ${TOOLDIR}/bin/${_TOOL_PREFIX}menuc
290 TOOL_MIPSELF2ECOFF= ${TOOLDIR}/bin/${_TOOL_PREFIX}mips-elf2ecoff
291 TOOL_MKCSMAPPER= ${TOOLDIR}/bin/${_TOOL_PREFIX}mkcsmapper
292 TOOL_MKESDB= ${TOOLDIR}/bin/${_TOOL_PREFIX}mkesdb
293 TOOL_MKFSMFS= ${TOOLDIR}/bin/${_TOOL_PREFIX}mkfs.mfs
294 TOOL_MKLOCALE= ${TOOLDIR}/bin/${_TOOL_PREFIX}mklocale
295 TOOL_MKMAGIC= ${TOOLDIR}/bin/${_TOOL_PREFIX}file
296 TOOL_MKTEMP= ${TOOLDIR}/bin/${_TOOL_PREFIX}mktemp
297 TOOL_MSGC= MSGDEF=${TOOLDIR}/share/misc ${TOOLDIR}/bin/${_TOOL_PREFIX}msgc
298 TOOL_MTREE= ${TOOLDIR}/bin/${_TOOL_PREFIX}mtree
299 TOOL_PAX= ${TOOLDIR}/bin/${_TOOL_PREFIX}pax
300 TOOL_PIC= ${TOOLDIR}/bin/${_TOOL_PREFIX}pic
301 TOOL_PKG_CREATE= ${TOOLDIR}/bin/${_TOOL_PREFIX}pkg_create
302 TOOL_POWERPCMKBOOTIMAGE=${TOOLDIR}/bin/${_TOOL_PREFIX}powerpc-mkbootimage
303 TOOL_PWD_MKDB= ${TOOLDIR}/bin/${_TOOL_PREFIX}pwd_mkdb
304 TOOL_REFER= ${TOOLDIR}/bin/${_TOOL_PREFIX}refer
305 TOOL_ROFF_ASCII= PATH=${TOOLDIR}/lib/groff:$${PATH} ${TOOLDIR}/bin/${_TOOL_PREFIX}nroff
306 TOOL_ROFF_DVI= ${TOOL_GROFF} -Tdvi
307 TOOL_ROFF_HTML= ${TOOL_GROFF} -Tlatin1 -mdoc2html
308 TOOL_ROFF_PS= ${TOOL_GROFF} -Tps
309 TOOL_ROFF_RAW= ${TOOL_GROFF} -Z
310 TOOL_RPCGEN= RPCGEN_CPP=${CPP:Q} ${TOOLDIR}/bin/${_TOOL_PREFIX}rpcgen
311 TOOL_SED= ${TOOLDIR}/bin/${_TOOL_PREFIX}sed
312 TOOL_SOELIM= ${TOOLDIR}/bin/${_TOOL_PREFIX}soelim
313 TOOL_SPARKCRC= ${TOOLDIR}/bin/${_TOOL_PREFIX}sparkcrc
314 TOOL_STAT= ${TOOLDIR}/bin/${_TOOL_PREFIX}stat
315 TOOL_STRFILE= ${TOOLDIR}/bin/${_TOOL_PREFIX}strfile
316 TOOL_SUNLABEL= ${TOOLDIR}/bin/${_TOOL_PREFIX}sunlabel
317 TOOL_TBL= ${TOOLDIR}/bin/${_TOOL_PREFIX}tbl
318 TOOL_TIC= ${TOOLDIR}/bin/${_TOOL_PREFIX}tic
319 TOOL_UUDECODE= ${TOOLDIR}/bin/${_TOOL_PREFIX}uudecode
320 TOOL_VGRIND= ${TOOLDIR}/bin/${_TOOL_PREFIX}vgrind -f
321 TOOL_ZIC= ${TOOLDIR}/bin/${_TOOL_PREFIX}zic
323 .else # USETOOLS != yes # } {
325 TOOL_AMIGAAOUT2BB= amiga-aout2bb
326 TOOL_AMIGAELF2BB= amiga-elf2bb
327 TOOL_AMIGATXLT= amiga-txlt
328 TOOL_ASN1_COMPILE= asn1_compile
329 TOOL_ATF_COMPILE= atf-compile
330 TOOL_AWK= awk
331 TOOL_CAP_MKDB= cap_mkdb
332 TOOL_CAT= cat
333 TOOL_CKSUM= cksum
334 TOOL_COMPILE_ET= compile_et
335 TOOL_CONFIG= config
336 TOOL_CRUNCHGEN= crunchgen
337 TOOL_CTAGS= ctags
338 TOOL_DB= db
339 TOOL_DISKLABEL= disklabel
340 TOOL_EQN= eqn
341 TOOL_FDISK= fdisk
342 TOOL_FGEN= fgen
343 TOOL_GENASSYM= genassym
344 TOOL_GENCAT= gencat
345 TOOL_GMAKE= gmake
346 TOOL_GREP= grep
347 TOOL_GROFF= groff
348 TOOL_HEXDUMP= hexdump
349 TOOL_HP300MKBOOT= hp300-mkboot
350 TOOL_HP700MKBOOT= hp700-mkboot
351 TOOL_INDXBIB= indxbib
352 TOOL_INSTALLBOOT= installboot
353 TOOL_INSTALL_INFO= install-info
354 TOOL_JOIN= join
355 TOOL_M4= m4
356 TOOL_MACPPCFIXCOFF= macppc-fixcoff
357 TOOL_MAKEFS= makefs
358 TOOL_MAKEINFO= makeinfo
359 TOOL_MAKEWHATIS= /usr/libexec/makewhatis
360 #TOOL_MAKEWHATIS= /usr/bin/makewhatis
361 TOOL_MDSETIMAGE= mdsetimage
362 TOOL_MENUC= menuc
363 TOOL_MIPSELF2ECOFF= mips-elf2ecoff
364 TOOL_MKCSMAPPER= mkcsmapper
365 TOOL_MKESDB= mkesdb
366 TOOL_MKFSMFS= mkfs.mfs
367 TOOL_MKLOCALE= mklocale
368 TOOL_MKMAGIC= file
369 TOOL_MKTEMP= mktemp
370 TOOL_MSGC= msgc
371 TOOL_MTREE= mtree
372 TOOL_PAX= pax
373 TOOL_PIC= pic
374 TOOL_PKG_CREATE= pkg_create
375 TOOL_POWERPCMKBOOTIMAGE= powerpc-mkbootimage
376 TOOL_PWD_MKDB= pwd_mkdb
377 TOOL_REFER= refer
378 TOOL_ROFF_ASCII= nroff
379 TOOL_ROFF_DVI= ${TOOL_GROFF} -Tdvi
380 TOOL_ROFF_HTML= ${TOOL_GROFF} -Tlatin1 -mdoc2html
381 TOOL_ROFF_PS= ${TOOL_GROFF} -Tps
382 TOOL_ROFF_RAW= ${TOOL_GROFF} -Z
383 TOOL_RPCGEN= rpcgen
384 TOOL_SED= sed
385 TOOL_SOELIM= soelim
386 TOOL_SPARKCRC= sparkcrc
387 TOOL_STAT= stat
388 TOOL_STRFILE= strfile
389 TOOL_SUNLABEL= sunlabel
390 TOOL_TBL= tbl
391 TOOL_TIC= tic
392 TOOL_UUDECODE= uudecode
393 TOOL_VGRIND= vgrind -f
394 TOOL_ZIC= zic
396 .endif # USETOOLS != yes # }
399 # Targets to check if DESTDIR or RELEASEDIR is provided
401 .if !target(check_DESTDIR)
402 check_DESTDIR: .PHONY .NOTMAIN
403 .if !defined(DESTDIR)
404 @echo "setenv DESTDIR before doing that!"
405 @false
406 .else
407 @true
408 .endif
409 .endif
411 .if !target(check_RELEASEDIR)
412 check_RELEASEDIR: .PHONY .NOTMAIN
413 .if !defined(RELEASEDIR)
414 @echo "setenv RELEASEDIR before doing that!"
415 @false
416 .else
417 @true
418 .endif
419 .endif
422 .if ${USETOOLS} == "yes" # {
424 # Make sure DESTDIR is set, so that builds with these tools always
425 # get appropriate -nostdinc, -nostdlib, etc. handling. The default is
426 # <empty string>, meaning start from /, the root directory.
428 DESTDIR?=
429 .endif # }
432 # Build a dynamically linked /bin and /sbin, with the necessary shared
433 # libraries moved from /usr/lib to /lib and the shared linker moved
434 # from /usr/libexec to /lib
436 # Note that if the BINDIR is not /bin or /sbin, then we always use the
437 # non-DYNAMICROOT behavior (i.e. it is only enabled for programs in /bin
438 # and /sbin). See <bsd.shlib.mk>.
440 MKDYNAMICROOT?= yes
443 # Where the system object and source trees are kept; can be configurable
444 # by the user in case they want them in ~/foosrc and ~/fooobj (for example).
446 BSDSRCDIR?= /usr/src
447 BSDOBJDIR?= /usr/obj
448 NETBSDSRCDIR?= ${BSDSRCDIR}
450 #BINGRP?= wheel
451 BINGRP?= operator
452 BINOWN?= root
453 BINMODE?= 755
454 NONBINMODE?= 644
456 #MANDIR?= /usr/share/man
457 MANDIR?= /usr/man
458 #MANGRP?= wheel
459 MANGRP?= operator
460 MANOWN?= root
461 MANMODE?= ${NONBINMODE}
462 #MANINSTALL?= catinstall htmlinstall maninstall
463 MANINSTALL?= maninstall
465 INFODIR?= /usr/share/info
466 #INFOGRP?= wheel
467 INFOGRP?= operator
468 INFOOWN?= root
469 INFOMODE?= ${NONBINMODE}
471 LIBDIR?= /usr/lib
473 LINTLIBDIR?= /usr/libdata/lint
474 LIBGRP?= ${BINGRP}
475 LIBOWN?= ${BINOWN}
476 LIBMODE?= ${NONBINMODE}
478 DOCDIR?= /usr/share/doc
479 HTMLDOCDIR?= /usr/share/doc/html
480 #DOCGRP?= wheel
481 DOCGRP?= operator
482 DOCOWN?= root
483 DOCMODE?= ${NONBINMODE}
485 NLSDIR?= /usr/share/nls
486 NLSGRP?= wheel
487 NLSOWN?= root
488 NLSMODE?= ${NONBINMODE}
490 KMODULEGRP?= wheel
491 KMODULEOWN?= root
492 KMODULEMODE?= ${NONBINMODE}
494 LOCALEDIR?= /usr/share/locale
495 LOCALEGRP?= wheel
496 LOCALEOWN?= root
497 LOCALEMODE?= ${NONBINMODE}
499 FIRMWAREDIR?= /libdata/firmware
500 FIRMWAREGRP?= wheel
501 FIRMWAREOWN?= root
502 FIRMWAREMODE?= ${NONBINMODE}
504 DEBUGDIR?= /usr/libdata/debug
505 DEBUGGRP?= wheel
506 DEBUGOWN?= root
507 DEBUGMODE?= ${NONBINMODE}
510 # Data-driven table using make variables to control how
511 # toolchain-dependent targets and shared libraries are built
512 # for different platforms and object formats.
514 # OBJECT_FMT: currently either "ELF" or "a.out".
516 # All platforms are ELF.
518 OBJECT_FMT= ELF
521 # If this platform's toolchain is missing, we obviously cannot build it.
523 .if ${TOOLCHAIN_MISSING} != "no"
524 MKBINUTILS:= no
525 MKGDB:= no
526 MKGCC:= no
527 .endif
530 # If we are using an external toolchain, we can still build the target's
531 # binutils, but we cannot build GCC's support libraries, since those are
532 # tightly-coupled to the version of GCC being used.
534 .if defined(EXTERNAL_TOOLCHAIN)
535 MKGCC:= no
536 .endif
539 # The m68000 port is incomplete.
541 .if ${MACHINE_ARCH} == "m68000"
542 NOPIC= # defined
543 MKISCSI= no
544 # XXX GCC 4 outputs mcount() calling sequences that try to load values
545 # from over 64KB away and this fails to assemble.
546 .if defined(HAVE_GCC) && (${HAVE_GCC} == 4)
547 NOPROFILE= # defined
548 .endif
549 .endif
552 # The ia64 port is incomplete.
554 .if ${MACHINE_ARCH} == "ia64"
555 MKLINT= no
556 MKGDB= no
557 .endif
560 # On the MIPS, all libs are compiled with ABIcalls (and are thus PIC),
561 # not just shared libraries, so don't build the _pic version.
563 .if ${MACHINE_ARCH} == "mipsel" || ${MACHINE_ARCH} == "mipseb" || \
564 ${MACHINE_ARCH} == "mips64el" || ${MACHINE_ARCH} == "mips64eb"
565 MKPICLIB:= no
566 .endif
569 # On VAX using ELF, all objects are PIC, not just shared libraries,
570 # so don't build the _pic version. Unless we are using GCC3 which
571 # doesn't support PIC yet.
573 .if ${MACHINE_ARCH} == "vax"
574 MKPICLIB= no
575 .endif
578 # Location of the file that contains the major and minor numbers of the
579 # version of a shared library. If this file exists a shared library
580 # will be built by <bsd.lib.mk>.
582 SHLIB_VERSION_FILE?= ${.CURDIR}/shlib_version
585 # GNU sources and packages sometimes see architecture names differently.
587 GNU_ARCH.coldfire=m68k
588 GNU_ARCH.i386=i486
589 GCC_CONFIG_ARCH.i386=i486
590 GCC_CONFIG_TUNE.i386=nocona
591 GCC_CONFIG_TUNE.x86_64=nocona
592 GNU_ARCH.m68000=m68010
593 GNU_ARCH.sh3eb=sh
594 GNU_ARCH.sh3el=shle
595 GNU_ARCH.mips64eb=mips64
596 MACHINE_GNU_ARCH=${GNU_ARCH.${MACHINE_ARCH}:U${MACHINE_ARCH}}
599 # In order to identify NetBSD to GNU packages, we sometimes need
600 # an "elf" tag for historically a.out platforms.
602 .if ${OBJECT_FMT} == "ELF" && \
603 (${MACHINE_GNU_ARCH} == "arm" || \
604 ${MACHINE_GNU_ARCH} == "armeb" || \
605 ${MACHINE_ARCH} == "i386" || \
606 ${MACHINE_CPU} == "m68k" || \
607 ${MACHINE_GNU_ARCH} == "sh" || \
608 ${MACHINE_GNU_ARCH} == "shle" || \
609 ${MACHINE_ARCH} == "sparc" || \
610 ${MACHINE_ARCH} == "vax")
611 MACHINE_GNU_PLATFORM?=${MACHINE_GNU_ARCH}--netbsdelf
612 .else
613 MACHINE_GNU_PLATFORM?=${MACHINE_GNU_ARCH}--netbsd
614 .endif
617 # Determine if arch uses native kernel modules with rump
619 .if ${MACHINE_ARCH} == "i386" || \
620 ${MACHINE_ARCH} == "x86_64"
621 RUMPKMOD= # defined
622 .endif
624 TARGETS+= all clean cleandir depend dependall includes \
625 install lint obj regress tags html
626 PHONY_NOTMAIN = all clean cleandir depend dependall distclean includes \
627 install lint obj regress tags beforedepend afterdepend \
628 beforeinstall afterinstall realinstall realdepend realall \
629 html subdir-all subdir-install subdir-depend
630 .PHONY: ${PHONY_NOTMAIN}
631 .NOTMAIN: ${PHONY_NOTMAIN}
633 .if ${NEED_OWN_INSTALL_TARGET} != "no"
634 .if !target(install)
635 install: beforeinstall .WAIT subdir-install realinstall .WAIT afterinstall
636 beforeinstall:
637 subdir-install:
638 realinstall:
639 afterinstall:
640 .endif
641 all: realall subdir-all
642 subdir-all:
643 realall:
644 depend: realdepend subdir-depend
645 subdir-depend:
646 realdepend:
647 distclean: cleandir
648 cleandir: clean
650 dependall: .NOTMAIN realdepend .MAKE
651 @cd ${.CURDIR}; ${MAKE} realall
652 .endif
655 # Define MKxxx variables (which are either yes or no) for users
656 # to set in /etc/mk.conf and override in the make environment.
657 # These should be tested with `== "no"' or `!= "no"'.
658 # The NOxxx variables should only be set by Makefiles.
660 # Please keep etc/Makefile and share/man/man5/mk.conf.5 in sync
661 # with changes to the MK* variables here.
665 # Supported NO* options (if defined, MK* will be forced to "no",
666 # regardless of user's mk.conf setting).
668 # Source makefiles should set NO*, and not MK*, and must do so before
669 # including bsd.own.mk.
671 .for var in \
672 NOCRYPTO NODOC NOHTML NOINFO NOLINKLIB NOLINT NOMAN NONLS NOOBJ NOPIC \
673 NOPICINSTALL NOPROFILE NOSHARE NOSTATICLIB
674 .if defined(${var})
675 MK${var:S/^NO//}:= no
676 .endif
677 .endfor
680 # Older-style variables that enabled behaviour when set.
682 .for var in MANZ UNPRIVED UPDATE
683 .if defined(${var})
684 MK${var}:= yes
685 .endif
686 .endfor
689 # MK* options which have variable defaults.
691 .if ${MACHINE} == "amd64" || ${MACHINE} == "sparc64"
692 MKCOMPAT?= yes
693 .else
694 # Don't let this build where it really isn't supported.
695 MKCOMPAT:= no
696 .endif
699 # MK* backward compatibility.
701 .if defined(MKBFD)
702 MKBINUTILS?= ${MKBFD}
703 .endif
706 # We want to build zfs only for i386 and amd64 by default for now.
708 .if ${MACHINE} == "amd64" || ${MACHINE} == "i386"
709 MKZFS?= yes
710 .endif
712 # Some tough Minix defaults
713 MKPROFILE?= no
714 MKSTATICLIB:= yes
715 MKLINT:= no
717 # Is a clang installed that understands what to do with -shared,
718 # needed to build shared libraries? If not then default to no
719 # to build them. (It could still be done with gcc though so MKPIC
720 # might be set to yes by the user.)
721 .if !exists(/usr/pkg/bin/clang.dynok)
722 NONPICCLANG= yes # Hint to other Makefiles
723 MKPIC?= no
724 .endif
727 # MK* options which default to "yes".
729 _MKVARS.yes= \
730 MKATF \
731 MKBINUTILS \
732 MKCATPAGES MKCRYPTO MKCOMPLEX MKCVS \
733 MKDOC \
734 MKGCC MKGCCCMDS MKGDB \
735 MKHESIOD MKHTML \
736 MKIEEEFP MKINET6 MKINFO MKIPFILTER MKISCSI \
737 MKKERBEROS \
738 MKKMOD \
739 MKLDAP MKLINKLIB MKLINT MKLVM \
740 MKMAN \
741 MKMDNS \
742 MKNLS \
743 MKOBJ \
744 MKPAM \
745 MKPF MKPIC MKPICINSTALL MKPICLIB MKPOSTFIX MKPROFILE \
746 MKSHARE MKSKEY MKSTATICLIB \
747 MKX11FONTS \
748 MKYP
749 #MINIX-specific vars
750 _MKVARS.yes+= \
751 MKMCONTEXT MKSYSDEBUG MKLIVEUPDATE MKSTATECTL MKTRACE
752 .if (${MACHINE_ARCH} == "i386")
753 _MKVARS.yes+= \
754 MKWATCHDOG MKACPI MKAPIC MKDEBUGREG MKINSTALLBOOT MKPCI
755 .endif
757 .for var in ${_MKVARS.yes}
758 ${var}?= yes
759 .endfor
762 # MK* options which default to "no".
764 _MKVARS.no= \
765 MKCRYPTO_IDEA MKCRYPTO_MDC2 MKCRYPTO_RC5 MKDEBUG MKDEBUGLIB \
766 MKEXTSRC MKCOVERAGE \
767 MKMANDOC MKMANZ MKOBJDIRS \
768 MKPCC MKPCCCMDS \
769 MKSOFTFLOAT MKSTRIPIDENT \
770 MKUNPRIVED MKUPDATE MKX11 MKZFS MKBSDTAR \
771 MKARZERO
772 #MINIX-specific vars
773 _MKVARS.no+= \
774 MKIMAGEONLY MKSMALL USETOOLS
775 .if (${MACHINE_ARCH} == "arm")
776 _MKVARS.no+= \
777 MKWATCHDOG MKACPI MKAPIC MKDEBUGREG MKINSTALLBOOT MKPCI
778 .endif
779 .for var in ${_MKVARS.no}
780 ${var}?=no
781 .endfor
784 # Force some options off if their dependencies are off.
787 .if ${MKCRYPTO} == "no"
788 MKKERBEROS:= no
789 .endif
791 .if ${MKMAN} == "no"
792 MKCATPAGES:= no
793 MKHTML:= no
794 .endif
796 .if ${MKLINKLIB} == "no"
797 MKLINT:= no
798 MKPICINSTALL:= no
799 MKPROFILE:= no
800 .endif
802 .if ${MKPIC} == "no"
803 MKPICLIB:= no
804 .endif
806 .if ${MKOBJ} == "no"
807 MKOBJDIRS:= no
808 .endif
810 .if ${MKSHARE} == "no"
811 MKCATPAGES:= no
812 MKDOC:= no
813 MKINFO:= no
814 MKHTML:= no
815 MKMAN:= no
816 MKNLS:= no
817 .endif
819 # MINIX
820 .if ${MKSMALL} == "yes"
821 MKWATCHDOG:= no
822 MKACPI:= no
823 MKAPIC:= no
824 MKMCONTEXT:= no
825 MKCOVERAGE:= no
826 MKDEBUGREG:= no
827 MKSYSDEBUG:= no
828 MKLIVEUPDATE:= no
829 MKSTATECTL:= no
830 MKTRACE:= no
831 .endif
834 # install(1) parameters.
836 COPY?= -c
837 .if ${MKUPDATE} == "no"
838 PRESERVE?=
839 .else
840 PRESERVE?= -p
841 .endif
842 #XXX: Not supported by MINIX install
843 #RENAME?= -r
844 HRDLINK?= -l h
845 SYMLINK?= -l s
847 METALOG?= ${DESTDIR}/METALOG
848 METALOG.add?= ${TOOL_CAT} -l >> ${METALOG}
849 .if (${_SRC_TOP_} != "") # only set INSTPRIV if inside ${NETBSDSRCDIR}
850 .if ${MKUNPRIVED} != "no"
851 INSTPRIV.unpriv=-U -M ${METALOG} -D ${DESTDIR} -h sha256
852 .else
853 INSTPRIV.unpriv=
854 .endif
855 INSTPRIV?= ${INSTPRIV.unpriv} -N ${NETBSDSRCDIR}/etc
856 .endif
857 STRIPFLAG?=
858 #XXX: Strip flag for MINIX
859 #STRIPFLAG?= -s
861 .if ${NEED_OWN_INSTALL_TARGET} != "no"
862 INSTALL_DIR?= ${INSTALL} ${INSTPRIV} -d
863 INSTALL_FILE?= ${INSTALL} ${INSTPRIV} ${COPY} ${PRESERVE} ${RENAME}
864 INSTALL_LINK?= ${INSTALL} ${INSTPRIV} ${HRDLINK} ${RENAME}
865 INSTALL_SYMLINK?= ${INSTALL} ${INSTPRIV} ${SYMLINK} ${RENAME}
866 HOST_INSTALL_FILE?= ${INSTALL} ${COPY} ${PRESERVE} ${RENAME}
867 HOST_INSTALL_DIR?= ${INSTALL} -d
868 HOST_INSTALL_SYMLINK?= ${INSTALL} ${SYMLINK} ${RENAME}
869 .endif
872 # Set defaults for the USE_xxx variables.
876 # USE_* options which default to "no" and will be forced to "no" if their
877 # corresponding MK* variable is set to "no".
879 .for var in USE_SKEY
880 .if (${${var:S/USE_/MK/}} == "no")
881 ${var}:= no
882 .else
883 ${var}?= no
884 .endif
885 .endfor
888 # USE_* options which default to "yes" unless their corresponding MK*
889 # variable is set to "no".
891 .for var in USE_HESIOD USE_INET6 USE_KERBEROS USE_LDAP USE_PAM USE_YP \
892 USE_WATCHDOG USE_ACPI USE_APIC USE_MCONTEXT USE_DEBUGREG USE_SYSDEBUG \
893 USE_LIVEUPDATE USE_STATECTL USE_TRACE USE_PCI
894 .if (${${var:S/USE_/MK/}} == "no")
895 ${var}:= no
896 .else
897 ${var}?= yes
898 .endif
899 .endfor
902 # USE_* options which default to "yes".
904 .for var in USE_JEMALLOC
905 ${var}?= yes
906 .endfor
909 # USE_* options which default to "no".
911 #.for var in
912 #${var}?= no
913 #.endfor
917 # MAKEDIRTARGET dir target [extra make(1) params]
918 # run "cd $${dir} && ${MAKE} [params] $${target}", with a pretty message
920 MAKEDIRTARGET=\
921 @_makedirtarget() { \
922 dir="$$1"; shift; \
923 target="$$1"; shift; \
924 case "$${dir}" in \
925 /*) this="$${dir}/"; \
926 real="$${dir}" ;; \
927 .) this="${_THISDIR_}"; \
928 real="${.CURDIR}" ;; \
929 *) this="${_THISDIR_}$${dir}/"; \
930 real="${.CURDIR}/$${dir}" ;; \
931 esac; \
932 show=$${this:-.}; \
933 echo "$${target} ===> $${show%/}$${1:+ (with: $$@)}"; \
934 cd "$${real}" \
935 && ${MAKE} _THISDIR_="$${this}" "$$@" $${target}; \
936 }; \
937 _makedirtarget
940 # MAKEVERBOSE support. Levels are:
941 # 0 Minimal output ("quiet")
942 # 1 Describe what is occurring
943 # 2 Describe what is occurring and echo the actual command
944 # 3 Ignore the effect of the "@" prefix in make commands
945 # 4 Trace shell commands using the shell's -x flag
947 MAKEVERBOSE?= 1
949 .if ${MAKEVERBOSE} == 0
950 _MKMSG?= @\#
951 _MKSHMSG?= : echo
952 _MKSHECHO?= : echo
953 .SILENT:
954 .elif ${MAKEVERBOSE} == 1
955 _MKMSG?= @echo ' '
956 _MKSHMSG?= echo ' '
957 _MKSHECHO?= : echo
958 .SILENT:
959 .else # MAKEVERBOSE >= 2
960 _MKMSG?= @echo '\# '
961 _MKSHMSG?= echo '\# '
962 _MKSHECHO?= echo
963 .SILENT: __makeverbose_dummy_target__
964 .endif # MAKEVERBOSE >= 2
965 .if ${MAKEVERBOSE} >= 3
966 .MAKEFLAGS: -dl
967 .endif # ${MAKEVERBOSE} >= 3
968 .if ${MAKEVERBOSE} >= 4
969 .MAKEFLAGS: -dx
970 .endif # ${MAKEVERBOSE} >= 4
972 _MKMSG_BUILD?= ${_MKMSG} " build "
973 _MKMSG_CREATE?= ${_MKMSG} " create "
974 _MKMSG_COMPILE?= ${_MKMSG} "compile "
975 _MKMSG_FORMAT?= ${_MKMSG} " format "
976 _MKMSG_INSTALL?= ${_MKMSG} "install "
977 _MKMSG_LINK?= ${_MKMSG} " link "
978 _MKMSG_LEX?= ${_MKMSG} " lex "
979 _MKMSG_REMOVE?= ${_MKMSG} " remove "
980 _MKMSG_YACC?= ${_MKMSG} " yacc "
982 _MKSHMSG_CREATE?= ${_MKSHMSG} " create "
983 _MKSHMSG_INSTALL?= ${_MKSHMSG} "install "
985 _MKTARGET_BUILD?= ${_MKMSG_BUILD} ${.CURDIR:T}/${.TARGET}
986 _MKTARGET_CREATE?= ${_MKMSG_CREATE} ${.CURDIR:T}/${.TARGET}
987 _MKTARGET_COMPILE?= ${_MKMSG_COMPILE} ${.CURDIR:T}/${.TARGET}
988 _MKTARGET_FORMAT?= ${_MKMSG_FORMAT} ${.CURDIR:T}/${.TARGET}
989 _MKTARGET_INSTALL?= ${_MKMSG_INSTALL} ${.TARGET}
990 _MKTARGET_LINK?= ${_MKMSG_LINK} ${.CURDIR:T}/${.TARGET}
991 _MKTARGET_LEX?= ${_MKMSG_LEX} ${.CURDIR:T}/${.TARGET}
992 _MKTARGET_REMOVE?= ${_MKMSG_REMOVE} ${.TARGET}
993 _MKTARGET_YACC?= ${_MKMSG_YACC} ${.CURDIR:T}/${.TARGET}
995 .if ${MKMANDOC} == "yes"
996 TARGETS+= lintmanpages
997 .endif
999 .endif # !defined(_MINIX_OWN_MK_)