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