aboutsummaryrefslogtreecommitdiffstats
path: root/Mk/Uses/objc.mk
blob: 41ec8914a4ce514a615db17f65cad8380317de19 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# $FreeBSD$
#
# Objective C support
#
# Feature:  objc
# Usage:    USES=objc
#
# MAINTAINER:   objc@FreeBSD.org

.if !defined(_INCLUDE_USES_OBJC_MK)
_INCLUDE_USES_OBJC_MK=  yes

.if !empty(objc_ARGS)
IGNORE= USES=objc takes no arguments
.endif

_CCVERSION!=    ${CC} --version
COMPILER_VERSION=   ${_CCVERSION:M[0-9].[0-9]*:C/([0-9]).([0-9]).*/\1\2/g}
.if ${_CCVERSION:Mclang}
COMPILER_TYPE=  clang
.else
COMPILER_TYPE=  gcc
.endif

ALT_COMPILER_VERSION=   0
ALT_COMPILER_TYPE=  none
_ALTCCVERSION=  
.if ${COMPILER_TYPE} == gcc && exists(/usr/bin/clang)
_ALTCCVERSION!= /usr/bin/clang --version
.elif ${COMPILER_TYPE} == clang && exists(/usr/bin/gcc)
_ALTCCVERSION!= /usr/bin/gcc --version
.endif

ALT_COMPILER_VERSION=   ${_ALTCCVERSION:M[0-9].[0-9]*:C/([0-9]).([0-9]).*/\1\2/g}
.if ${_ALTCCVERSION:Mclang}
ALT_COMPILER_TYPE=  clang
.elif !empty(_ALTCCVERSION)
ALT_COMPILER_TYPE=  gcc
.endif

# We do always need clang
.if (${COMPILER_TYPE} == clang && ${COMPILER_VERSION} < 34) || ${COMPILER_TYPE} != clang
.if ${ALT_COMPILER_TYPE} == clang && ${ALT_COMPILER_VERSION} >= 34
CC= /usr/bin/clang
CPP=    /usr/bin/clang-cpp
CXX=    /usr/bin/clang++
.else
BUILD_DEPENDS+= ${LOCALBASE}/bin/clang34:${PORTSDIR}/lang/clang34
CPP=    ${LOCALBASE}/bin/clang-cpp34
CC= ${LOCALBASE}/bin/clang34
CXX=    ${LOCALBASE}/bin/clang++34
.if ${OSVERSION} < 900033
USE_BINUTILS=   yes
LDFLAGS+=   -B${LOCALBASE}/bin
.endif
.endif
.endif

LIB_DEPENDS+=   libobjc.so.4.6:${PORTSDIR}/lang/libobjc2
OBJCFLAGS+= -I${LOCALBASE}/include
LDFLAGS+=   -L${LOCALBASE}/lib
CONFIGURE_ENV+= OBJC="${CC}" OBJCFLAGS="${OBJCFLAGS}"
MAKE_ENV+=  OBJC="${CC}" OBJCFLAGS="${OBJCFLAGS}"

.endif