1*6eef5f0cSAntonio Huete Jimenez# $Id: own.mk,v 1.44 2021/12/08 05:56:50 sjg Exp $ 25f1e34d9SAlexandre Perrin 35f1e34d9SAlexandre Perrin.if !target(__${.PARSEFILE}__) 4*6eef5f0cSAntonio Huete Jimenez__${.PARSEFILE}__: .NOTMAIN 55f1e34d9SAlexandre Perrin 65f1e34d9SAlexandre Perrin.if !target(__init.mk__) 75f1e34d9SAlexandre Perrin.include "init.mk" 85f1e34d9SAlexandre Perrin.endif 95f1e34d9SAlexandre Perrin 10ca58f742SDaniel Fojt.if !defined(NOMAKECONF) && !defined(NO_MAKECONF) 115f1e34d9SAlexandre PerrinMAKECONF?= /etc/mk.conf 125f1e34d9SAlexandre Perrin.-include "${MAKECONF}" 135f1e34d9SAlexandre Perrin.endif 145f1e34d9SAlexandre Perrin 155f1e34d9SAlexandre Perrin.include <host-target.mk> 165f1e34d9SAlexandre Perrin 175f1e34d9SAlexandre PerrinTARGET_OSNAME?= ${_HOST_OSNAME} 185f1e34d9SAlexandre PerrinTARGET_OSREL?= ${_HOST_OSREL} 195f1e34d9SAlexandre PerrinTARGET_OSTYPE?= ${HOST_OSTYPE} 205f1e34d9SAlexandre PerrinTARGET_HOST?= ${HOST_TARGET} 215f1e34d9SAlexandre Perrin 225f1e34d9SAlexandre Perrin# these may or may not exist 23f445c897SJohn Marino.-include <${TARGET_HOST}.mk> 24f445c897SJohn Marino.-include <config.mk> 255f1e34d9SAlexandre Perrin 265f1e34d9SAlexandre PerrinRM?= rm 275f1e34d9SAlexandre PerrinLN?= ln 285f1e34d9SAlexandre PerrinINSTALL?= install 295f1e34d9SAlexandre Perrin 305f1e34d9SAlexandre Perrinprefix?= /usr 315f1e34d9SAlexandre Perrin.if exists(${prefix}/lib) 325f1e34d9SAlexandre Perrinlibprefix?= ${prefix} 335f1e34d9SAlexandre Perrin.else 345f1e34d9SAlexandre Perrinlibprefix?= /usr 355f1e34d9SAlexandre Perrin.endif 365f1e34d9SAlexandre Perrin 375f1e34d9SAlexandre Perrin# FreeBSD at least does not set this 385f1e34d9SAlexandre PerrinMACHINE_ARCH?= ${MACHINE} 395f1e34d9SAlexandre Perrin# we need to make sure these are defined too in case sys.mk fails to. 405f1e34d9SAlexandre PerrinCOMPILE.s?= ${CC} ${AFLAGS} -c 415f1e34d9SAlexandre PerrinLINK.s?= ${CC} ${AFLAGS} ${LDFLAGS} 425f1e34d9SAlexandre PerrinCOMPILE.S?= ${CC} ${AFLAGS} ${CPPFLAGS} -c -traditional-cpp 435f1e34d9SAlexandre PerrinLINK.S?= ${CC} ${AFLAGS} ${CPPFLAGS} ${LDFLAGS} 445f1e34d9SAlexandre PerrinCOMPILE.c?= ${CC} ${CFLAGS} ${CPPFLAGS} -c 455f1e34d9SAlexandre PerrinLINK.c?= ${CC} ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} 465f1e34d9SAlexandre PerrinCXXFLAGS?= ${CFLAGS} 475f1e34d9SAlexandre PerrinCOMPILE.cc?= ${CXX} ${CXXFLAGS} ${CPPFLAGS} -c 485f1e34d9SAlexandre PerrinLINK.cc?= ${CXX} ${CXXFLAGS} ${CPPFLAGS} ${LDFLAGS} 495f1e34d9SAlexandre PerrinCOMPILE.m?= ${OBJC} ${OBJCFLAGS} ${CPPFLAGS} -c 505f1e34d9SAlexandre PerrinLINK.m?= ${OBJC} ${OBJCFLAGS} ${CPPFLAGS} ${LDFLAGS} 515f1e34d9SAlexandre PerrinCOMPILE.f?= ${FC} ${FFLAGS} -c 525f1e34d9SAlexandre PerrinLINK.f?= ${FC} ${FFLAGS} ${LDFLAGS} 535f1e34d9SAlexandre PerrinCOMPILE.F?= ${FC} ${FFLAGS} ${CPPFLAGS} -c 545f1e34d9SAlexandre PerrinLINK.F?= ${FC} ${FFLAGS} ${CPPFLAGS} ${LDFLAGS} 555f1e34d9SAlexandre PerrinCOMPILE.r?= ${FC} ${FFLAGS} ${RFLAGS} -c 565f1e34d9SAlexandre PerrinLINK.r?= ${FC} ${FFLAGS} ${RFLAGS} ${LDFLAGS} 575f1e34d9SAlexandre PerrinLEX.l?= ${LEX} ${LFLAGS} 585f1e34d9SAlexandre PerrinCOMPILE.p?= ${PC} ${PFLAGS} ${CPPFLAGS} -c 595f1e34d9SAlexandre PerrinLINK.p?= ${PC} ${PFLAGS} ${CPPFLAGS} ${LDFLAGS} 605f1e34d9SAlexandre PerrinYACC.y?= ${YACC} ${YFLAGS} 615f1e34d9SAlexandre Perrin 625f1e34d9SAlexandre Perrin# for suffix rules 635f1e34d9SAlexandre PerrinIMPFLAGS?= ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} 645f1e34d9SAlexandre Perrin.for s in .c .cc 655f1e34d9SAlexandre PerrinCOMPILE.$s += ${IMPFLAGS} 665f1e34d9SAlexandre PerrinLINK.$s += ${IMPFLAGS} 675f1e34d9SAlexandre Perrin.endfor 685f1e34d9SAlexandre Perrin 695f1e34d9SAlexandre PerrinPRINT.VAR.MAKE = MAKESYSPATH=${MAKESYSPATH:U${.PARSEDIR}} ${.MAKE} 705f1e34d9SAlexandre Perrin.if empty(.MAKEFLAGS:M-V*) 715f1e34d9SAlexandre Perrin.if defined(MAKEOBJDIRPREFIX) || defined(MAKEOBJDIR) 725f1e34d9SAlexandre PerrinPRINTOBJDIR= ${PRINT.VAR.MAKE} -r -V .OBJDIR -f /dev/null xxx 735f1e34d9SAlexandre Perrin.else 745f1e34d9SAlexandre PerrinPRINTOBJDIR= ${PRINT.VAR.MAKE} -V .OBJDIR 755f1e34d9SAlexandre Perrin.endif 765f1e34d9SAlexandre Perrin.else 775f1e34d9SAlexandre PerrinPRINTOBJDIR= echo # prevent infinite recursion 785f1e34d9SAlexandre Perrin.endif 795f1e34d9SAlexandre Perrin 805f1e34d9SAlexandre Perrin# we really like to have SRCTOP and OBJTOP defined... 815f1e34d9SAlexandre Perrin.if !defined(SRCTOP) || !defined(OBJTOP) 82f445c897SJohn Marino.-include <srctop.mk> 835f1e34d9SAlexandre Perrin.endif 845f1e34d9SAlexandre Perrin 855f1e34d9SAlexandre Perrin.if !defined(SRCTOP) || !defined(OBJTOP) 865f1e34d9SAlexandre Perrin# dpadd.mk is rather pointless without these 875f1e34d9SAlexandre PerrinOPTIONS_DEFAULT_NO+= DPADD_MK 885f1e34d9SAlexandre Perrin.endif 895f1e34d9SAlexandre Perrin 905f1e34d9SAlexandre Perrin# process options 915f1e34d9SAlexandre PerrinOPTIONS_DEFAULT_NO+= \ 925f1e34d9SAlexandre Perrin INSTALL_AS_USER \ 935f1e34d9SAlexandre Perrin GPROF \ 94ca58f742SDaniel Fojt PROG_LDORDER_MK \ 955f1e34d9SAlexandre Perrin LIBTOOL \ 965f1e34d9SAlexandre Perrin LINT \ 975f1e34d9SAlexandre Perrin 985f1e34d9SAlexandre PerrinOPTIONS_DEFAULT_YES+= \ 995f1e34d9SAlexandre Perrin ARCHIVE \ 1005f1e34d9SAlexandre Perrin AUTODEP \ 1015f1e34d9SAlexandre Perrin CRYPTO \ 1025f1e34d9SAlexandre Perrin DOC \ 1035f1e34d9SAlexandre Perrin DPADD_MK \ 1045f1e34d9SAlexandre Perrin GDB \ 1055f1e34d9SAlexandre Perrin KERBEROS \ 1065f1e34d9SAlexandre Perrin LINKLIB \ 1075f1e34d9SAlexandre Perrin MAN \ 1085f1e34d9SAlexandre Perrin NLS \ 1095f1e34d9SAlexandre Perrin OBJ \ 1105f1e34d9SAlexandre Perrin PIC \ 1115f1e34d9SAlexandre Perrin SHARE \ 1125f1e34d9SAlexandre Perrin SKEY \ 1135f1e34d9SAlexandre Perrin YP \ 1145f1e34d9SAlexandre Perrin 1155f1e34d9SAlexandre PerrinOPTIONS_DEFAULT_DEPENDENT+= \ 1165f1e34d9SAlexandre Perrin CATPAGES/MAN \ 117ca58f742SDaniel Fojt LDORDER_MK/PROG_LDORDER_MK \ 1185f1e34d9SAlexandre Perrin OBJDIRS/OBJ \ 1195f1e34d9SAlexandre Perrin PICINSTALL/LINKLIB \ 1205f1e34d9SAlexandre Perrin PICLIB/PIC \ 1215f1e34d9SAlexandre Perrin PROFILE/LINKLIB \ 122ca58f742SDaniel Fojt STAGING_PROG/STAGING \ 1235f1e34d9SAlexandre Perrin 1245f1e34d9SAlexandre Perrin.include <options.mk> 1255f1e34d9SAlexandre Perrin 1265f1e34d9SAlexandre Perrin.if ${MK_INSTALL_AS_USER} == "yes" 1275f1e34d9SAlexandre Perrin# We ignore this if user is root. 128a34d5fb1SAntonio Huete Jimenez_uid:= ${.MAKE.UID:U${id -u:L:sh}} 1295f1e34d9SAlexandre Perrin.if ${_uid} != 0 1305f1e34d9SAlexandre Perrin.if !defined(USERGRP) 131a34d5fb1SAntonio Huete JimenezUSERGRP:= ${.MAKE.GID:U${id -g:L:sh}} 1325f1e34d9SAlexandre Perrin.export USERGRP 1335f1e34d9SAlexandre Perrin.endif 134ca58f742SDaniel Fojt.for x in BIN CONF DOC INC INFO FILES KMOD LIB MAN NLS PROG SHARE 1355f1e34d9SAlexandre Perrin$xOWN= ${USER} 1365f1e34d9SAlexandre Perrin$xGRP= ${USERGRP} 137f445c897SJohn Marino$x_INSTALL_OWN= 1385f1e34d9SAlexandre Perrin.endfor 1395f1e34d9SAlexandre Perrin.endif 1405f1e34d9SAlexandre Perrin.endif 1415f1e34d9SAlexandre Perrin 1425f1e34d9SAlexandre Perrin# override this in sys.mk 1435f1e34d9SAlexandre PerrinROOT_GROUP?= wheel 1445f1e34d9SAlexandre PerrinBINGRP?= ${ROOT_GROUP} 1455f1e34d9SAlexandre PerrinBINOWN?= root 1465f1e34d9SAlexandre PerrinBINMODE?= 555 1475f1e34d9SAlexandre PerrinNONBINMODE?= 444 148f445c897SJohn MarinoDIRMODE?= 755 1495f1e34d9SAlexandre Perrin 150ca58f742SDaniel FojtINCLUDEDIR?= ${prefix}/include 151ca58f742SDaniel FojtINCDIR?= ${INCLUDEDIR} 152ca58f742SDaniel Fojt 1535f1e34d9SAlexandre Perrin# Define MANZ to have the man pages compressed (gzip) 1545f1e34d9SAlexandre Perrin#MANZ= 1 1555f1e34d9SAlexandre Perrin 1565f1e34d9SAlexandre PerrinMANTARGET?= cat 1575f1e34d9SAlexandre PerrinMANDIR?= ${prefix}/share/man/${MANTARGET} 1585f1e34d9SAlexandre PerrinMANGRP?= ${BINGRP} 1595f1e34d9SAlexandre PerrinMANOWN?= ${BINOWN} 1605f1e34d9SAlexandre PerrinMANMODE?= ${NONBINMODE} 1615f1e34d9SAlexandre Perrin 162f445c897SJohn MarinoINCLUDEDIR?= ${libprefix}/include 1635f1e34d9SAlexandre PerrinLIBDIR?= ${libprefix}/lib 1645f1e34d9SAlexandre PerrinSHLIBDIR?= ${libprefix}/lib 1655f1e34d9SAlexandre Perrin.if ${USE_SHLIBDIR:Uno} == "yes" 1665f1e34d9SAlexandre Perrin_LIBSODIR?= ${SHLIBDIR} 1675f1e34d9SAlexandre Perrin.else 1685f1e34d9SAlexandre Perrin_LIBSODIR?= ${LIBDIR} 1695f1e34d9SAlexandre Perrin.endif 1705f1e34d9SAlexandre Perrin# this is where ld.*so lives 1715f1e34d9SAlexandre PerrinSHLINKDIR?= /usr/libexec 1725f1e34d9SAlexandre PerrinLINTLIBDIR?= ${libprefix}/libdata/lint 1735f1e34d9SAlexandre PerrinLIBGRP?= ${BINGRP} 1745f1e34d9SAlexandre PerrinLIBOWN?= ${BINOWN} 1755f1e34d9SAlexandre PerrinLIBMODE?= ${NONBINMODE} 1765f1e34d9SAlexandre Perrin 1775f1e34d9SAlexandre PerrinDOCDIR?= ${prefix}/share/doc 1785f1e34d9SAlexandre PerrinDOCGRP?= ${BINGRP} 1795f1e34d9SAlexandre PerrinDOCOWN?= ${BINOWN} 1805f1e34d9SAlexandre PerrinDOCMODE?= ${NONBINMODE} 1815f1e34d9SAlexandre Perrin 1825f1e34d9SAlexandre PerrinNLSDIR?= ${prefix}/share/nls 1835f1e34d9SAlexandre PerrinNLSGRP?= ${BINGRP} 1845f1e34d9SAlexandre PerrinNLSOWN?= ${BINOWN} 1855f1e34d9SAlexandre PerrinNLSMODE?= ${NONBINMODE} 1865f1e34d9SAlexandre Perrin 1875f1e34d9SAlexandre PerrinKMODDIR?= ${prefix}/lkm 1885f1e34d9SAlexandre PerrinKMODGRP?= ${BINGRP} 1895f1e34d9SAlexandre PerrinKMODOWN?= ${BINOWN} 1905f1e34d9SAlexandre PerrinKMODMODE?= ${NONBINMODE} 1915f1e34d9SAlexandre Perrin 192ca58f742SDaniel FojtSHAREGRP?= ${BINGRP} 193ca58f742SDaniel FojtSHAREOWN?= ${BINOWN} 194ca58f742SDaniel FojtSHAREMODE?= ${NONBINMODE} 195ca58f742SDaniel Fojt 1965f1e34d9SAlexandre PerrinCOPY?= -c 1975f1e34d9SAlexandre PerrinSTRIP_FLAG?= -s 1985f1e34d9SAlexandre Perrin 1995f1e34d9SAlexandre Perrin.if ${TARGET_OSNAME} == "NetBSD" 2005f1e34d9SAlexandre Perrin.if exists(/usr/libexec/ld.elf_so) 2015f1e34d9SAlexandre PerrinOBJECT_FMT=ELF 2025f1e34d9SAlexandre Perrin.endif 2035f1e34d9SAlexandre PerrinOBJECT_FMT?=a.out 2045f1e34d9SAlexandre Perrin.endif 2055f1e34d9SAlexandre Perrin# sys.mk should set something appropriate if need be. 2065f1e34d9SAlexandre PerrinOBJECT_FMT?=ELF 2075f1e34d9SAlexandre Perrin 2085f1e34d9SAlexandre Perrin.if (${_HOST_OSNAME} == "FreeBSD") 2095f1e34d9SAlexandre PerrinCFLAGS+= ${CPPFLAGS} 2105f1e34d9SAlexandre Perrin.endif 2115f1e34d9SAlexandre Perrin 2125f1e34d9SAlexandre Perrin# allow for per target flags 2135f1e34d9SAlexandre Perrin# apply the :T:R first, so the more specific :T can override if needed 2145f1e34d9SAlexandre PerrinCPPFLAGS += ${CPPFLAGS_${.TARGET:T:R}} ${CPPFLAGS_${.TARGET:T}} 2155f1e34d9SAlexandre PerrinCFLAGS += ${CFLAGS_${.TARGET:T:R}} ${CFLAGS_${.TARGET:T}} 2165f1e34d9SAlexandre Perrin 2175f1e34d9SAlexandre Perrin# Define SYS_INCLUDE to indicate whether you want symbolic links to the system 2185f1e34d9SAlexandre Perrin# source (``symlinks''), or a separate copy (``copies''); (latter useful 2195f1e34d9SAlexandre Perrin# in environments where it's not possible to keep /sys publicly readable) 2205f1e34d9SAlexandre Perrin#SYS_INCLUDE= symlinks 2215f1e34d9SAlexandre Perrin 2225f1e34d9SAlexandre Perrin# don't try to generate PIC versions of libraries on machines 2235f1e34d9SAlexandre Perrin# which don't support PIC. 2245f1e34d9SAlexandre Perrin.if (${MACHINE_ARCH} == "vax") || \ 2255f1e34d9SAlexandre Perrin ((${MACHINE_ARCH} == "mips") && defined(STATIC_TOOLCHAIN)) || \ 2265f1e34d9SAlexandre Perrin ((${MACHINE_ARCH} == "alpha") && defined(ECOFF_TOOLCHAIN)) 2275f1e34d9SAlexandre PerrinMK_PIC=no 2285f1e34d9SAlexandre Perrin.endif 2295f1e34d9SAlexandre Perrin 2305f1e34d9SAlexandre Perrin# No lint, for now. 2315f1e34d9SAlexandre PerrinNOLINT= 2325f1e34d9SAlexandre Perrin 2335f1e34d9SAlexandre Perrin 2345f1e34d9SAlexandre Perrin.if ${MK_LINKLIB} == "no" 2355f1e34d9SAlexandre PerrinMK_PICINSTALL= no 2365f1e34d9SAlexandre PerrinMK_PROFILE= no 2375f1e34d9SAlexandre Perrin.endif 2385f1e34d9SAlexandre Perrin 2395f1e34d9SAlexandre Perrin.if ${MK_MAN} == "no" 2405f1e34d9SAlexandre PerrinMK_CATPAGES= no 2415f1e34d9SAlexandre Perrin.endif 2425f1e34d9SAlexandre Perrin 2435f1e34d9SAlexandre Perrin.if ${MK_OBJ} == "no" 2445f1e34d9SAlexandre PerrinMK_OBJDIRS= no 2455f1e34d9SAlexandre PerrinMK_AUTO_OBJ= no 2465f1e34d9SAlexandre Perrin.endif 2475f1e34d9SAlexandre Perrin 2485f1e34d9SAlexandre Perrin.if ${MK_SHARE} == "no" 2495f1e34d9SAlexandre PerrinMK_CATPAGES= no 2505f1e34d9SAlexandre PerrinMK_DOC= no 2515f1e34d9SAlexandre PerrinMK_INFO= no 2525f1e34d9SAlexandre PerrinMK_MAN= no 2535f1e34d9SAlexandre PerrinMK_NLS= no 2545f1e34d9SAlexandre Perrin.endif 2555f1e34d9SAlexandre Perrin 256ca58f742SDaniel Fojt# :U incase not using our sys.mk 257ca58f742SDaniel Fojt.if ${MK_META_MODE:Uno} == "yes" 258ca58f742SDaniel Fojt# should all be set by sys.mk if not default 259ca58f742SDaniel FojtTARGET_SPEC_VARS ?= MACHINE 260*6eef5f0cSAntonio Huete Jimenez.if ${MAKE_VERSION} >= 20120325 261ca58f742SDaniel Fojt.if ${TARGET_SPEC_VARS:[#]} > 1 262ca58f742SDaniel FojtTARGET_SPEC_VARS_REV := ${TARGET_SPEC_VARS:[-1..1]} 263ca58f742SDaniel Fojt.else 264ca58f742SDaniel FojtTARGET_SPEC_VARS_REV = ${TARGET_SPEC_VARS} 265ca58f742SDaniel Fojt.endif 266*6eef5f0cSAntonio Huete Jimenez.endif 267ca58f742SDaniel Fojt.if ${MK_STAGING} == "yes" 268ca58f742SDaniel FojtSTAGE_ROOT?= ${OBJROOT}/stage 269ca58f742SDaniel FojtSTAGE_OBJTOP?= ${STAGE_ROOT}/${TARGET_SPEC_VARS_REV:ts/} 270ca58f742SDaniel Fojt.endif 271ca58f742SDaniel Fojt.endif 272ca58f742SDaniel Fojt 2735f1e34d9SAlexandre Perrin.endif 274