xref: /freebsd/contrib/bmake/mk/host-target.mk (revision af23369a6deaaeb612ab266eb88b8bb8d560c322)
1# RCSid:
2#	$Id: host-target.mk,v 1.14 2022/02/04 18:05:22 sjg Exp $
3
4# Host platform information; may be overridden
5.if !defined(_HOST_OSNAME)
6# use .MAKE.OS if available
7_HOST_OSNAME := ${.MAKE.OS:U${uname -s:L:sh}}
8.export _HOST_OSNAME
9.endif
10.if !defined(_HOST_OSREL)
11_HOST_OSREL  !=	uname -r
12.export _HOST_OSREL
13.endif
14.if !defined(_HOST_MACHINE)
15_HOST_MACHINE != uname -m
16.export _HOST_MACHINE
17.endif
18.if !defined(_HOST_ARCH)
19# for Darwin and NetBSD prefer $MACHINE (amd64 rather than x86_64)
20.if ${_HOST_OSNAME:NDarwin:NNetBSD} == ""
21_HOST_ARCH := ${_HOST_MACHINE}
22.else
23_HOST_ARCH != uname -p 2> /dev/null || uname -m
24# uname -p may produce garbage on linux
25.if ${_HOST_ARCH:[\#]} > 1 || ${_HOST_ARCH:Nunknown} == ""
26_HOST_ARCH := ${_HOST_MACHINE}
27.endif
28.endif
29.export _HOST_ARCH
30.endif
31.if !defined(HOST_MACHINE)
32HOST_MACHINE := ${_HOST_MACHINE}
33.export HOST_MACHINE
34.endif
35
36HOST_OSMAJOR := ${_HOST_OSREL:C/[^0-9].*//}
37HOST_OSTYPE  :=	${_HOST_OSNAME:S,/,,g}-${_HOST_OSREL:C/\([^\)]*\)//}-${_HOST_ARCH}
38HOST_OS      :=	${_HOST_OSNAME}
39host_os      :=	${_HOST_OSNAME:tl}
40HOST_TARGET  := ${host_os:S,/,,g}${HOST_OSMAJOR}-${_HOST_ARCH}
41# sometimes we want HOST_TARGET32
42MACHINE32.amd64 = i386
43MACHINE32.x86_64 = i386
44_HOST_ARCH32 := ${MACHINE32.${_HOST_ARCH}:U${_HOST_ARCH:S,64$,,}}
45HOST_TARGET32 := ${host_os:S,/,,g}${HOST_OSMAJOR}-${_HOST_ARCH32}
46
47# tr is insanely non-portable, accommodate the lowest common denominator
48TR ?= tr
49toLower = ${TR} 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'
50toUpper = ${TR} 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
51