1# $Id: own.mk,v 1.36 2017/07/08 21:58:46 sjg Exp $ 2 3.if !target(__${.PARSEFILE}__) 4__${.PARSEFILE}__: 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 LIBTOOL \ 95 LINT \ 96 97OPTIONS_DEFAULT_YES+= \ 98 ARCHIVE \ 99 AUTODEP \ 100 CRYPTO \ 101 DOC \ 102 DPADD_MK \ 103 GDB \ 104 KERBEROS \ 105 LINKLIB \ 106 MAN \ 107 NLS \ 108 OBJ \ 109 PIC \ 110 SHARE \ 111 SKEY \ 112 YP \ 113 114OPTIONS_DEFAULT_DEPENDENT+= \ 115 CATPAGES/MAN \ 116 OBJDIRS/OBJ \ 117 PICINSTALL/LINKLIB \ 118 PICLIB/PIC \ 119 PROFILE/LINKLIB \ 120 STAGING_PROG/STAGING \ 121 122.include <options.mk> 123 124.if ${MK_INSTALL_AS_USER} == "yes" 125# We ignore this if user is root. 126_uid!= id -u 127.if ${_uid} != 0 128.if !defined(USERGRP) 129USERGRP!= id -g 130.export USERGRP 131.endif 132.for x in BIN CONF DOC INC INFO FILES KMOD LIB MAN NLS PROG SHARE 133$xOWN= ${USER} 134$xGRP= ${USERGRP} 135$x_INSTALL_OWN= 136.endfor 137.endif 138.endif 139 140# override this in sys.mk 141ROOT_GROUP?= wheel 142BINGRP?= ${ROOT_GROUP} 143BINOWN?= root 144BINMODE?= 555 145NONBINMODE?= 444 146DIRMODE?= 755 147 148INCLUDEDIR?= ${prefix}/include 149INCDIR?= ${INCLUDEDIR} 150 151# Define MANZ to have the man pages compressed (gzip) 152#MANZ= 1 153 154MANTARGET?= cat 155MANDIR?= ${prefix}/share/man/${MANTARGET} 156MANGRP?= ${BINGRP} 157MANOWN?= ${BINOWN} 158MANMODE?= ${NONBINMODE} 159 160INCLUDEDIR?= ${libprefix}/include 161LIBDIR?= ${libprefix}/lib 162SHLIBDIR?= ${libprefix}/lib 163.if ${USE_SHLIBDIR:Uno} == "yes" 164_LIBSODIR?= ${SHLIBDIR} 165.else 166_LIBSODIR?= ${LIBDIR} 167.endif 168# this is where ld.*so lives 169SHLINKDIR?= /usr/libexec 170LINTLIBDIR?= ${libprefix}/libdata/lint 171LIBGRP?= ${BINGRP} 172LIBOWN?= ${BINOWN} 173LIBMODE?= ${NONBINMODE} 174 175DOCDIR?= ${prefix}/share/doc 176DOCGRP?= ${BINGRP} 177DOCOWN?= ${BINOWN} 178DOCMODE?= ${NONBINMODE} 179 180NLSDIR?= ${prefix}/share/nls 181NLSGRP?= ${BINGRP} 182NLSOWN?= ${BINOWN} 183NLSMODE?= ${NONBINMODE} 184 185KMODDIR?= ${prefix}/lkm 186KMODGRP?= ${BINGRP} 187KMODOWN?= ${BINOWN} 188KMODMODE?= ${NONBINMODE} 189 190SHAREGRP?= ${BINGRP} 191SHAREOWN?= ${BINOWN} 192SHAREMODE?= ${NONBINMODE} 193 194COPY?= -c 195STRIP_FLAG?= -s 196 197.if ${TARGET_OSNAME} == "NetBSD" 198.if exists(/usr/libexec/ld.elf_so) 199OBJECT_FMT=ELF 200.endif 201OBJECT_FMT?=a.out 202.endif 203# sys.mk should set something appropriate if need be. 204OBJECT_FMT?=ELF 205 206.if (${_HOST_OSNAME} == "FreeBSD") 207CFLAGS+= ${CPPFLAGS} 208.endif 209 210# allow for per target flags 211# apply the :T:R first, so the more specific :T can override if needed 212CPPFLAGS += ${CPPFLAGS_${.TARGET:T:R}} ${CPPFLAGS_${.TARGET:T}} 213CFLAGS += ${CFLAGS_${.TARGET:T:R}} ${CFLAGS_${.TARGET:T}} 214 215# Define SYS_INCLUDE to indicate whether you want symbolic links to the system 216# source (``symlinks''), or a separate copy (``copies''); (latter useful 217# in environments where it's not possible to keep /sys publicly readable) 218#SYS_INCLUDE= symlinks 219 220# don't try to generate PIC versions of libraries on machines 221# which don't support PIC. 222.if (${MACHINE_ARCH} == "vax") || \ 223 ((${MACHINE_ARCH} == "mips") && defined(STATIC_TOOLCHAIN)) || \ 224 ((${MACHINE_ARCH} == "alpha") && defined(ECOFF_TOOLCHAIN)) 225MK_PIC=no 226.endif 227 228# No lint, for now. 229NOLINT= 230 231 232.if ${MK_LINKLIB} == "no" 233MK_PICINSTALL= no 234MK_PROFILE= no 235.endif 236 237.if ${MK_MAN} == "no" 238MK_CATPAGES= no 239.endif 240 241.if ${MK_OBJ} == "no" 242MK_OBJDIRS= no 243MK_AUTO_OBJ= no 244.endif 245 246.if ${MK_SHARE} == "no" 247MK_CATPAGES= no 248MK_DOC= no 249MK_INFO= no 250MK_MAN= no 251MK_NLS= no 252.endif 253 254# :U incase not using our sys.mk 255.if ${MK_META_MODE:Uno} == "yes" 256# should all be set by sys.mk if not default 257TARGET_SPEC_VARS ?= MACHINE 258.if ${TARGET_SPEC_VARS:[#]} > 1 259TARGET_SPEC_VARS_REV := ${TARGET_SPEC_VARS:[-1..1]} 260.else 261TARGET_SPEC_VARS_REV = ${TARGET_SPEC_VARS} 262.endif 263.if ${MK_STAGING} == "yes" 264STAGE_ROOT?= ${OBJROOT}/stage 265STAGE_OBJTOP?= ${STAGE_ROOT}/${TARGET_SPEC_VARS_REV:ts/} 266.endif 267.endif 268 269.endif 270