xref: /freebsd/contrib/bmake/mk/host-target.mk (revision f81cdf24ba5436367377f7c8e8f51f6df2a75ca7)
1# RCSid:
2#	$Id: host-target.mk,v 1.19 2023/09/21 06:44:53 sjg Exp $
3
4# Host platform information; may be overridden
5.if !target(__${.PARSEFILE}__)
6__${.PARSEFILE}__: .NOTMAIN
7
8.if !defined(_HOST_OSNAME)
9# use .MAKE.OS if available
10_HOST_OSNAME := ${.MAKE.OS:U${uname -s:L:sh}}
11.export _HOST_OSNAME
12.endif
13.if !defined(_HOST_OSREL)
14_HOST_OSREL  !=	uname -r
15.export _HOST_OSREL
16.endif
17.if !defined(_HOST_ARCH)
18_HOST_ARCH != uname -p 2> /dev/null || uname -m
19# uname -p may produce garbage on linux
20.if ${_HOST_ARCH:[\#]} > 1 || ${_HOST_ARCH:Nunknown} == ""
21_HOST_ARCH = ${_HOST_MACHINE}
22.elif ${_HOST_OSNAME:NDarwin} == "" && ${_HOST_ARCH:Narm:Ni386} == ""
23# _HOST_MACHINE is more explicit/useful
24_HOST_ARCH = ${_HOST_MACHINE}
25.endif
26.export _HOST_ARCH
27.endif
28.if !defined(_HOST_MACHINE)
29_HOST_MACHINE != uname -m
30# just in case
31_HOST_ARCH := ${_HOST_ARCH}
32# uname -m may produce garbage on darwin ppc
33.if ${_HOST_MACHINE:[\#]} > 1
34_HOST_MACHINE := ${_HOST_ARCH}
35.endif
36.export _HOST_MACHINE
37.endif
38.if !defined(HOST_MACHINE)
39HOST_MACHINE := ${_HOST_MACHINE}
40.export HOST_MACHINE
41.endif
42
43HOST_OSMAJOR := ${_HOST_OSREL:C/[^0-9].*//}
44HOST_OSTYPE  :=	${_HOST_OSNAME:S,/,,g}-${_HOST_OSREL:C/\([^\)]*\)//}-${_HOST_ARCH}
45HOST_OS      :=	${_HOST_OSNAME}
46host_os      :=	${_HOST_OSNAME:tl}
47HOST_TARGET  := ${host_os:S,/,,g}${HOST_OSMAJOR}-${_HOST_ARCH}
48# sometimes we want HOST_TARGET32
49MACHINE32.amd64 = i386
50MACHINE32.x86_64 = i386
51.if !defined(_HOST_ARCH32)
52_HOST_ARCH32 := ${MACHINE32.${_HOST_ARCH}:U${_HOST_ARCH:S,64$,,}}
53.export _HOST_ARCH32
54.endif
55HOST_TARGET32 := ${host_os:S,/,,g}${HOST_OSMAJOR}-${_HOST_ARCH32}
56
57.export HOST_TARGET HOST_TARGET32
58
59# tr is insanely non-portable, accommodate the lowest common denominator
60TR ?= tr
61toLower = ${TR} 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'
62toUpper = ${TR} 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
63
64.endif
65