xref: /freebsd/contrib/bmake/mk/init.mk (revision 55141f2c8991b2a6adbf30bb0fe3e6cbc303f06d)
1# $Id: init.mk,v 1.27 2022/01/01 17:32:18 sjg Exp $
2#
3#	@(#) Copyright (c) 2002, Simon J. Gerraty
4#
5#	This file is provided in the hope that it will
6#	be of use.  There is absolutely NO WARRANTY.
7#	Permission to copy, redistribute or otherwise
8#	use this file is hereby granted provided that
9#	the above copyright notice and this notice are
10#	left intact.
11#
12#	Please send copies of changes and bug-fixes to:
13#	sjg@crufty.net
14#
15
16.if !target(__${.PARSEFILE}__)
17__${.PARSEFILE}__: .NOTMAIN
18
19.if ${MAKE_VERSION:U0} > 20100408
20_this_mk_dir := ${.PARSEDIR:tA}
21.else
22_this_mk_dir := ${.PARSEDIR}
23.endif
24
25.-include <local.init.mk>
26.-include <${.CURDIR:H}/Makefile.inc>
27.include <own.mk>
28.include <compiler.mk>
29
30.MAIN:		all
31
32# should have been set by sys.mk
33CXX_SUFFIXES?= .cc .cpp .cxx .C
34
35.if !empty(WARNINGS_SET) || !empty(WARNINGS_SET_${MACHINE_ARCH})
36.include <warnings.mk>
37.endif
38
39# these are applied in order, least specific to most
40VAR_QUALIFIER_LIST += \
41	${TARGET_SPEC_VARS:UMACHINE:@v@${$v}@} \
42	${COMPILER_TYPE} \
43	${.TARGET:T:R} \
44	${.TARGET:T} \
45	${.IMPSRC:T} \
46	${VAR_QUALIFIER_XTRA_LIST}
47
48QUALIFIED_VAR_LIST += \
49	CFLAGS \
50	COPTS \
51	CPPFLAGS \
52	CPUFLAGS \
53	LDFLAGS \
54
55# a final :U avoids errors if someone uses :=
56.for V in ${QUALIFIED_VAR_LIST:O:u:@q@$q $q_LAST@}
57.for Q in ${VAR_QUALIFIER_LIST:u}
58$V += ${$V.$Q:U} ${$V.$Q.${COMPILER_TYPE}:U}
59.endfor
60.endfor
61
62CC_PG?= -pg
63CXX_PG?= ${CC_PG}
64CC_PIC?= -DPIC
65CXX_PIC?= ${CC_PIC}
66PROFFLAGS?= -DGPROF -DPROF
67
68.if ${.MAKE.LEVEL:U1} == 0 && ${MK_DIRDEPS_BUILD:Uno} == "yes"
69.if ${RELDIR} == "."
70# top-level targets that are ok at level 0
71DIRDEPS_BUILD_LEVEL0_TARGETS += clean* destroy*
72M_ListToSkip?= O:u:S,^,N,:ts:
73.if ${.TARGETS:Uall:${DIRDEPS_BUILD_LEVEL0_TARGETS:${M_ListToSkip}}} != ""
74# this tells lib.mk and prog.mk to not actually build anything
75_SKIP_BUILD = not building at level 0
76.endif
77.elif ${.TARGETS:U:Nall} == ""
78_SKIP_BUILD = not building at level 0
79.endif
80.endif
81
82.if !defined(.PARSEDIR)
83# no-op is the best we can do if not bmake.
84.WAIT:
85.endif
86
87# define this once for consistency
88.if !defined(_SKIP_BUILD)
89# beforebuild is a hook for things that must be done early
90all: beforebuild .WAIT realbuild
91.else
92all: .PHONY
93.if !empty(_SKIP_BUILD) && ${.MAKEFLAGS:M-V} == ""
94.warning ${_SKIP_BUILD}
95.endif
96.endif
97beforebuild:
98realbuild:
99
100.endif
101