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