1# $Id: own.mk,v 1.48 2024/04/09 21:52:52 sjg Exp $ 2 3# should be set properly in sys.mk 4_this ?= ${.PARSEFILE:S,bsd.,,} 5 6.if !target(__${_this}__) 7__${_this}__: .NOTMAIN 8 9.if !target(__init.mk__) 10.include "init.mk" 11.endif 12 13.if !defined(NOMAKECONF) && !defined(NO_MAKECONF) 14MAKECONF?= /etc/mk.conf 15.-include "${MAKECONF}" 16.endif 17 18.include <host-target.mk> 19 20TARGET_OSNAME?= ${_HOST_OSNAME} 21TARGET_OSREL?= ${_HOST_OSREL} 22TARGET_OSTYPE?= ${HOST_OSTYPE} 23TARGET_HOST?= ${HOST_TARGET} 24 25# these may or may not exist 26.-include <${TARGET_HOST}.mk> 27.-include <config.mk> 28 29RM?= rm 30LN?= ln 31INSTALL?= install 32 33prefix?= /usr 34.if exists(${prefix}/lib) 35libprefix?= ${prefix} 36.else 37libprefix?= /usr 38.endif 39 40# FreeBSD at least does not set this 41MACHINE_ARCH?= ${MACHINE} 42# we need to make sure these are defined too in case sys.mk fails to. 43 44# for suffix rules 45IMPFLAGS?= ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} 46.for s in .c .cc 47COMPILE.$s += ${IMPFLAGS} 48LINK.$s += ${IMPFLAGS} 49.endfor 50 51PRINT.VAR.MAKE = MAKESYSPATH=${MAKESYSPATH:U${.PARSEDIR}} ${.MAKE} 52.if empty(.MAKEFLAGS:M-V*) 53.if defined(MAKEOBJDIRPREFIX) || defined(MAKEOBJDIR) 54PRINTOBJDIR= ${PRINT.VAR.MAKE} -r -V .OBJDIR -f /dev/null xxx 55.else 56PRINTOBJDIR= ${PRINT.VAR.MAKE} -V .OBJDIR 57.endif 58.else 59PRINTOBJDIR= echo # prevent infinite recursion 60.endif 61 62# we really like to have SRCTOP and OBJTOP defined... 63.if !defined(SRCTOP) || !defined(OBJTOP) 64.-include <srctop.mk> 65.endif 66 67.if !defined(SRCTOP) || !defined(OBJTOP) 68# dpadd.mk is rather pointless without these 69OPTIONS_DEFAULT_NO+= DPADD_MK 70.endif 71 72# process options 73OPTIONS_DEFAULT_NO+= \ 74 INSTALL_AS_USER \ 75 GPROF \ 76 PROG_LDORDER_MK \ 77 LIBTOOL \ 78 LINT \ 79 80OPTIONS_DEFAULT_YES+= \ 81 ARCHIVE \ 82 AUTODEP \ 83 CRYPTO \ 84 DOC \ 85 DPADD_MK \ 86 GDB \ 87 KERBEROS \ 88 LINKLIB \ 89 MAN \ 90 NLS \ 91 OBJ \ 92 PIC \ 93 SHARE \ 94 SKEY \ 95 YP \ 96 97OPTIONS_DEFAULT_DEPENDENT+= \ 98 CATPAGES/MAN \ 99 LDORDER_MK/PROG_LDORDER_MK \ 100 OBJDIRS/OBJ \ 101 PICINSTALL/LINKLIB \ 102 PICLIB/PIC \ 103 PROFILE/LINKLIB \ 104 STAGING_MAN/STAGING \ 105 STAGING_PROG/STAGING \ 106 107.include <options.mk> 108 109.if ${MK_INSTALL_AS_USER} == "yes" 110# We ignore this if user is root. 111_uid:= ${.MAKE.UID:U${id -u:L:sh}} 112.if ${_uid} != 0 113.if !defined(USERGRP) 114USERGRP:= ${.MAKE.GID:U${id -g:L:sh}} 115.export USERGRP 116.endif 117.for x in BIN CONF DOC INC INFO FILES KMOD LIB MAN NLS PROG SHARE 118$xOWN= ${USER} 119$xGRP= ${USERGRP} 120$x_INSTALL_OWN= 121.endfor 122.endif 123.endif 124 125# override this in sys.mk 126ROOT_GROUP?= wheel 127BINGRP?= ${ROOT_GROUP} 128BINOWN?= root 129BINMODE?= 555 130NONBINMODE?= 444 131DIRMODE?= 755 132 133INCLUDEDIR?= ${prefix}/include 134INCDIR?= ${INCLUDEDIR} 135 136# Define MANZ to have the man pages compressed (gzip) 137#MANZ= 1 138 139MANDIR?= ${prefix}/share/man 140MANGRP?= ${BINGRP} 141MANOWN?= ${BINOWN} 142MANMODE?= ${NONBINMODE} 143 144INCLUDEDIR?= ${libprefix}/include 145LIBDIR?= ${libprefix}/lib 146SHLIBDIR?= ${libprefix}/lib 147.if ${USE_SHLIBDIR:Uno} == "yes" 148_LIBSODIR?= ${SHLIBDIR} 149.else 150_LIBSODIR?= ${LIBDIR} 151.endif 152# this is where ld.*so lives 153SHLINKDIR?= /usr/libexec 154LINTLIBDIR?= ${libprefix}/libdata/lint 155LIBGRP?= ${BINGRP} 156LIBOWN?= ${BINOWN} 157LIBMODE?= ${NONBINMODE} 158 159DOCDIR?= ${prefix}/share/doc 160DOCGRP?= ${BINGRP} 161DOCOWN?= ${BINOWN} 162DOCMODE?= ${NONBINMODE} 163 164NLSDIR?= ${prefix}/share/nls 165NLSGRP?= ${BINGRP} 166NLSOWN?= ${BINOWN} 167NLSMODE?= ${NONBINMODE} 168 169KMODDIR?= ${prefix}/lkm 170KMODGRP?= ${BINGRP} 171KMODOWN?= ${BINOWN} 172KMODMODE?= ${NONBINMODE} 173 174SHAREGRP?= ${BINGRP} 175SHAREOWN?= ${BINOWN} 176SHAREMODE?= ${NONBINMODE} 177 178COPY?= -c 179STRIP_FLAG?= -s 180 181.if ${TARGET_OSNAME} == "NetBSD" 182.if exists(/usr/libexec/ld.elf_so) 183OBJECT_FMT=ELF 184.endif 185OBJECT_FMT?=a.out 186.endif 187# sys.mk should set something appropriate if need be. 188OBJECT_FMT?=ELF 189 190.if (${_HOST_OSNAME} == "FreeBSD") 191CFLAGS+= ${CPPFLAGS} 192.endif 193 194# allow for per target flags 195# apply the :T:R first, so the more specific :T can override if needed 196CPPFLAGS += ${CPPFLAGS_${.TARGET:T:R}} ${CPPFLAGS_${.TARGET:T}} 197CFLAGS += ${CFLAGS_${.TARGET:T:R}} ${CFLAGS_${.TARGET:T}} 198 199# Define SYS_INCLUDE to indicate whether you want symbolic links to the system 200# source (``symlinks''), or a separate copy (``copies''); (latter useful 201# in environments where it's not possible to keep /sys publicly readable) 202#SYS_INCLUDE= symlinks 203 204# don't try to generate PIC versions of libraries on machines 205# which don't support PIC. 206.if (${MACHINE_ARCH} == "vax") || \ 207 ((${MACHINE_ARCH} == "mips") && defined(STATIC_TOOLCHAIN)) || \ 208 ((${MACHINE_ARCH} == "alpha") && defined(ECOFF_TOOLCHAIN)) 209MK_PIC=no 210.endif 211 212# No lint, for now. 213NOLINT= 214 215 216.if ${MK_LINKLIB} == "no" 217MK_PICINSTALL= no 218MK_PROFILE= no 219.endif 220 221.if ${MK_MAN} == "no" 222MK_CATPAGES= no 223.endif 224 225.if ${MK_OBJ} == "no" 226MK_OBJDIRS= no 227MK_AUTO_OBJ= no 228.endif 229 230.if ${MK_SHARE} == "no" 231MK_CATPAGES= no 232MK_DOC= no 233MK_INFO= no 234MK_MAN= no 235MK_NLS= no 236.endif 237 238# :U incase not using our sys.mk 239.if ${MK_META_MODE:Uno} == "yes" 240# should all be set by sys.mk if not default 241TARGET_SPEC_VARS ?= MACHINE 242.if ${MAKE_VERSION} >= 20120325 243.if ${TARGET_SPEC_VARS:[#]} > 1 244TARGET_SPEC_VARS_REV := ${TARGET_SPEC_VARS:[-1..1]} 245.else 246TARGET_SPEC_VARS_REV = ${TARGET_SPEC_VARS} 247.endif 248.endif 249.if ${MK_STAGING} == "yes" 250STAGE_ROOT?= ${OBJROOT}/stage 251STAGE_OBJTOP?= ${STAGE_ROOT}/${TARGET_SPEC_VARS_REV:ts/} 252.endif 253.endif 254 255.endif 256