aboutsummaryrefslogtreecommitdiff
path: root/Mk/Uses/qmake.mk
blob: 471d4fdbc0940d521784966d37f0fe61260f3c05 (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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
# There are three Qt related USES files with different access to Qt.
#   - qmake: The port requires Qt's qmake to build -- creates the configure target
#            - auto includes qt.mk
#   - qt-dist: The port is a port for a part of Qt5
#            - auto inclues qt.mk
#   - qt.mk  - Dependency handling. USE_QT=foo bar
#
#
# Provide support for qmake-based projects
#
# Feature:		qmake
# Usage:		USES=qmake or USES=qmake:ARGS
#			Must be used along with	'USE_QT*=#'
# Valid ARGS:		norecursive outsource
# ARGS description:
# norecursive		Don't pass -recursive argument to qmake binary
# outsource		Perform an out-of-source build
# no_env		Suppress modification of configure and make environment.
# no_configure		Don't add the configure target -- this is implied by 
#			HAS_CONFIGURE=yes and GNU_CONFIGURE=yes
#
#
# Variables for ports:
# QMAKE_ENV		- Environment passed to qmake.
#			Default: ${CONFIGURE_ENV}
# QMAKE_ARGS		- Arguments passed to qmake.
#			Default: see below
# QMAKE_CONFIGURE_ARGS  - Extra arguments passed to qmake after everything
#                       else, such as "-foo -no-bar". The arguments are usually
#                       set in configure.json. This variable is specific to
#                       qmake from Qt 5.
#                       Default: empty
# QMAKE_SOURCE_PATH	- Path to qmake project files.
#			Default: ${WRKSRC} if out-of-source build is
#			requested, empty otherwise.
#
# User defined variables:
# QMAKE_VERBOSE		- Enable verbose configure output.
#
# MAINTAINER: kde@FreeBSD.org

.if !defined(_INCLUDE_USES_QMAKE_MK)
_INCLUDE_USES_QMAKE_MK=	yes

# Suck in qt.mk
.include "${USESDIR}/qt.mk"

_VALID_ARGS=		norecursive outsource no_env no_configure

.  for arg in ${qmake_ARGS}
.    if empty(_VALID_ARGS:M${arg})
IGNORE=			Incorrect 'USES+= qmake' usage: argument '${arg}' is not recognized
.    endif
.  endfor

# Check whether we need to add the configure target
_ADD_CONFIGURE_TARGET=	yes
.  if !empty(qmake_ARGS:Mno_configure) || defined(HAS_CONFIGURE) || defined(GNU_CONFIGURE)
_ADD_CONFIGURE_TARGET=	# unset
.  endif

# QMAKESPEC belongs to bsd.qt.mk.
QMAKE_ENV?=		${CONFIGURE_ENV}
QMAKE_ARGS+=		-spec ${QMAKESPEC} \
			QMAKE_CC="${CC}" QMAKE_CXX="${CXX}" \
			QMAKE_LINK_C="${CC}" QMAKE_LINK_C_SHLIB="${CC}" \
			QMAKE_LINK="${CXX}" QMAKE_LINK_SHLIB="${CXX}" \
			QMAKE_CFLAGS="${CFLAGS}" \
			QMAKE_CXXFLAGS="${CXXFLAGS}" \
			QMAKE_LFLAGS="${LDFLAGS}" \
			QMAKE_LIBS="${LIBS}" \
			QMAKE_CFLAGS_DEBUG="" \
			QMAKE_CFLAGS_RELEASE="" \
			QMAKE_CXXFLAGS_DEBUG="" \
			QMAKE_CXXFLAGS_RELEASE="" \
			PREFIX="${PREFIX}"

.  if defined(WITH_DEBUG)
PLIST_SUB+=		DEBUG=""
QMAKE_ARGS+=		CONFIG+="debug" \
			CONFIG-="release"
.  else
PLIST_SUB+=		DEBUG="@comment "
QMAKE_ARGS+=		CONFIG+="release" \
			CONFIG-="debug separate_debug_info"
.  endif # defined(WITH_DEBUG)

# We set -recursive by default to keep qmake from running in the build stage.
.  if ! ${qmake_ARGS:Mnorecursive}
QMAKE_ARGS+=		-recursive
.  endif

.  if defined(QMAKE_VERBOSE)
QMAKE_ARGS+=		-d
.  endif

# _QMAKE_WRKSRC (and _QMAKE, below) are needed to abstract the qmake target and
# use it for both qtbase and USES=qmake ports. They are private, not supposed to
# be used anywhere else.
_QMAKE_WRKSRC?=	${CONFIGURE_WRKSRC}
.  if ${qmake_ARGS:Moutsource}
CONFIGURE_WRKSRC=	${WRKDIR}/.build
BUILD_WRKSRC=		${CONFIGURE_WRKSRC}
INSTALL_WRKSRC=		${BUILD_WRKSRC}
TEST_WRKSRC=		${BUILD_WRKSRC}
QMAKE_SOURCE_PATH?=	${WRKSRC}
.  else
QMAKE_SOURCE_PATH?=	# empty
.  endif

# Add qmake to USE_QT -- unless it's qmake itself
.  if !${PORTNAME} == qmake
USE_QT+=		qmake_build
.  endif

.  if empty(qmake_ARGS:Mno_env)
DESTDIRNAME=		INSTALL_ROOT
CONFIGURE_ENV+=		QTDIR="${QT_ARCHDIR}" QMAKE="${QMAKE}" \
			MOC="${MOC}" RCC="${RCC}" UIC="${UIC}" \
			QMAKESPEC="${QMAKESPEC}"
CONFIGURE_ARGS+=	--with-qt-includes=${QT_INCDIR} \
			--with-qt-libraries=${QT_LIBDIR} \
			--with-extra-includes=${LOCALBASE}/include \
			--with-extra-libs=${LOCALBASE}/lib
.  endif

_USES_POST+=		qmake
.endif # _QMAKE_MK_INCLUDED

# =============================================================================
#
# =============================================================================

.if defined(_POSTMKINCLUDED) && !defined(_QMAKE_MK_POST_INCLUDED)
_QMAKE_MK_POST_INCLUDED=	qmake.mk

# Define a custom target to make it usable by bsd.qt.mk for internal Qt
# configuration.
qmake-configure:
	@${MKDIR} ${_QMAKE_WRKSRC}
	@cd ${_QMAKE_WRKSRC} && \
		${SETENV} ${QMAKE_ENV} ${_QMAKE} ${QMAKE_ARGS} \
			${QMAKE_SOURCE_PATH} \
			${QMAKE_CONFIGURE_ARGS:?--:} ${QMAKE_CONFIGURE_ARGS}

.  if !target(do-configure) && !empty(_ADD_CONFIGURE_TARGET)
_USES_configure+=	450:qmake-configure
.  endif

.endif # !defined(_INCLUDE_USES_QMAKE_MK)