xref: /minix3/share/mk/bsd.host.mk (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*0a6a1f1dSLionel Sambuc#	$NetBSD: bsd.host.mk,v 1.2 2014/04/10 19:02:18 plunky Exp $
2*0a6a1f1dSLionel Sambuc
3*0a6a1f1dSLionel Sambuc.if !defined(_BSD_HOST_MK_)
4*0a6a1f1dSLionel Sambuc_BSD_HOST_MK_=1
5*0a6a1f1dSLionel Sambuc
6*0a6a1f1dSLionel Sambuc.if ${HOST_OSTYPE:C/\-.*//:U} == "Minix"
7*0a6a1f1dSLionel SambucHOST_LDFLAGS?=	-static
8*0a6a1f1dSLionel Sambuc
9*0a6a1f1dSLionel Sambuc#LSC: Be a bit smarter about the default compiler
10*0a6a1f1dSLionel Sambuc.if exists(/usr/pkg/bin/clang) || exists(/usr/bin/clang)
11*0a6a1f1dSLionel SambucHOST_CC?=   clang
12*0a6a1f1dSLionel Sambuc.endif
13*0a6a1f1dSLionel Sambuc
14*0a6a1f1dSLionel Sambuc.if exists(/usr/pkg/bin/gcc) || exists(/usr/bin/gcc)
15*0a6a1f1dSLionel SambucHOST_CC?=   gcc
16*0a6a1f1dSLionel Sambuc.endif
17*0a6a1f1dSLionel Sambuc.endif # ${HOST_OSTYPE:C/\-.*//:U} == "Minix"
18*0a6a1f1dSLionel Sambuc
19*0a6a1f1dSLionel Sambuc# Helpers for cross-compiling
20*0a6a1f1dSLionel SambucHOST_CC?=	cc
21*0a6a1f1dSLionel SambucHOST_CFLAGS?=	-O
22*0a6a1f1dSLionel SambucHOST_COMPILE.c?=${HOST_CC} ${HOST_CFLAGS} ${HOST_CPPFLAGS} -c
23*0a6a1f1dSLionel SambucHOST_COMPILE.cc?=      ${HOST_CXX} ${HOST_CXXFLAGS} ${HOST_CPPFLAGS} -c
24*0a6a1f1dSLionel SambucHOST_LINK.cc?=  ${HOST_CXX} ${HOST_CXXFLAGS} ${HOST_CPPFLAGS} ${HOST_LDFLAGS}
25*0a6a1f1dSLionel Sambuc.if defined(HOSTPROG_CXX)
26*0a6a1f1dSLionel SambucHOST_LINK.c?=   ${HOST_LINK.cc}
27*0a6a1f1dSLionel Sambuc.else
28*0a6a1f1dSLionel SambucHOST_LINK.c?=	${HOST_CC} ${HOST_CFLAGS} ${HOST_CPPFLAGS} ${HOST_LDFLAGS}
29*0a6a1f1dSLionel Sambuc.endif
30*0a6a1f1dSLionel Sambuc
31*0a6a1f1dSLionel SambucHOST_CXX?=	c++
32*0a6a1f1dSLionel SambucHOST_CXXFLAGS?=	-O
33*0a6a1f1dSLionel Sambuc
34*0a6a1f1dSLionel SambucHOST_CPP?=	cpp
35*0a6a1f1dSLionel SambucHOST_CPPFLAGS?=
36*0a6a1f1dSLionel Sambuc
37*0a6a1f1dSLionel SambucHOST_LD?=	ld
38*0a6a1f1dSLionel SambucHOST_LDFLAGS?=
39*0a6a1f1dSLionel Sambuc
40*0a6a1f1dSLionel SambucHOST_AR?=	ar
41*0a6a1f1dSLionel SambucHOST_RANLIB?=	ranlib
42*0a6a1f1dSLionel Sambuc
43*0a6a1f1dSLionel SambucHOST_LN?=	ln
44*0a6a1f1dSLionel Sambuc
45*0a6a1f1dSLionel Sambuc# HOST_SH must be an absolute path
46*0a6a1f1dSLionel SambucHOST_SH?=	/bin/sh
47*0a6a1f1dSLionel Sambuc
48*0a6a1f1dSLionel Sambuc.if !defined(HOST_OSTYPE)
49*0a6a1f1dSLionel Sambuc_HOST_OSNAME!=	uname -s
50*0a6a1f1dSLionel Sambuc_HOST_OSREL!=	uname -r
51*0a6a1f1dSLionel Sambuc# For _HOST_ARCH, if uname -p fails, or prints "unknown", or prints
52*0a6a1f1dSLionel Sambuc# something that does not look like an identifier, then use uname -m.
53*0a6a1f1dSLionel Sambuc_HOST_ARCH!=	uname -p 2>/dev/null
54*0a6a1f1dSLionel Sambuc_HOST_ARCH:=	${HOST_ARCH:tW:C/.*[^-_A-Za-z0-9].*//:S/unknown//}
55*0a6a1f1dSLionel Sambuc.if empty(_HOST_ARCH)
56*0a6a1f1dSLionel Sambuc_HOST_ARCH!=	uname -m
57*0a6a1f1dSLionel Sambuc.endif
58*0a6a1f1dSLionel SambucHOST_OSTYPE:=	${_HOST_OSNAME}-${_HOST_OSREL:C/\([^\)]*\)//g:[*]:C/ /_/g}-${_HOST_ARCH:C/\([^\)]*\)//g:[*]:C/ /_/g}
59*0a6a1f1dSLionel Sambuc.MAKEOVERRIDES+= HOST_OSTYPE
60*0a6a1f1dSLionel Sambuc.endif # !defined(HOST_OSTYPE)
61*0a6a1f1dSLionel Sambuc
62*0a6a1f1dSLionel Sambuc.if ${USETOOLS} == "yes"
63*0a6a1f1dSLionel SambucHOST_MKDEP?=	${TOOLDIR}/bin/${_TOOL_PREFIX}host-mkdep
64*0a6a1f1dSLionel SambucHOST_MKDEPCXX?=	${TOOLDIR}/bin/${_TOOL_PREFIX}host-mkdep
65*0a6a1f1dSLionel Sambuc.else
66*0a6a1f1dSLionel SambucHOST_MKDEP?=	CC=${HOST_CC:Q} mkdep
67*0a6a1f1dSLionel SambucHOST_MKDEPCXX?=	CC=${HOST_CXX:Q} mkdep
68*0a6a1f1dSLionel Sambuc.endif
69*0a6a1f1dSLionel Sambuc
70*0a6a1f1dSLionel Sambuc.if ${NEED_OWN_INSTALL_TARGET} != "no"
71*0a6a1f1dSLionel SambucHOST_INSTALL_FILE?=	${INSTALL} ${COPY} ${PRESERVE} ${RENAME}
72*0a6a1f1dSLionel SambucHOST_INSTALL_DIR?=	${INSTALL} -d
73*0a6a1f1dSLionel SambucHOST_INSTALL_SYMLINK?=	${INSTALL} ${SYMLINK} ${RENAME}
74*0a6a1f1dSLionel Sambuc.endif
75*0a6a1f1dSLionel Sambuc
76*0a6a1f1dSLionel Sambuc.endif
77