Sync Mk with ports
[dports.git] / Mk / Uses / qmake.mk
1 # $FreeBSD$
2 #
3 # Provide support for qmake-based projects
4 #
5 # Feature:              qmake
6 # Usage:                USES=qmake or USES=qmake:ARGS
7 #                       Must be used along with 'USE_QT*=#'
8 # Valid ARGS:           norecursive outsource
9 # ARGS description:
10 # norecursive           Don't pass -recursive argument to qmake binary
11 # outsource             Perform an out-of-source build
12 #
13 #
14 # Variables for ports:
15 # QMAKE_ENV             - Environment passed to qmake.
16 #                       Default: ${CONFIGURE_ENV}
17 # QMAKE_ARGS            - Arguments passed to qmake.
18 #                       Default: see below
19 # QMAKE_SOURCE_PATH     - Path to qmake project files.
20 #                       Default: ${WRKSRC} if out-of-source build is
21 #                       requested, empty otherwise.
22 #
23 # User defined variables:
24 # QMAKE_VERBOSE         - Enable verbose configure output.
25 #
26 # MAINTAINER: kde@FreeBSD.org
27
28 .if !defined(_INCLUDE_USES_QMAKE_MK)
29 _INCLUDE_USES_QMAKE_MK= yes
30
31 # _QT_VERSION is defined in bsd.qt.mk, only if a correct Qt version was selected
32 # via USE_QT*.
33 .if empty(_QT_VERSION)
34 IGNORE= 'USES+= qmake' must be accompanied with 'USE_QT[${_QT_SUPPORTED:S/ //g}]= #'
35 .endif
36
37 # _env is a private argument used only by bsd.qt.mk to get variables and custom
38 # targets (currently, only qmake-configure), without qmake being added to the
39 # configure stage.
40 _VALID_ARGS=    norecursive outsource _env
41
42 .for arg in ${qmake_ARGS}
43 .  if empty(_VALID_ARGS:M${arg})
44 IGNORE= Incorrect 'USES+= qmake' usage: argument '${arg}' is not recognized
45 .  endif
46 .endfor
47
48 .if ! ${qmake_ARGS:M_env}
49 USE_QT${_QT_VERSION:R:R}+=      qmake_build
50 .endif
51
52 # QMAKESPEC belongs to bsd.qt.mk.
53 QMAKE_ENV?=     ${CONFIGURE_ENV}
54 QMAKE_ARGS+=    -spec ${QMAKESPEC} \
55                 QMAKE_CC="${CC}" QMAKE_CXX="${CXX}" \
56                 QMAKE_LINK_C="${CC}" QMAKE_LINK_C_SHLIB="${CC}" \
57                 QMAKE_LINK="${CXX}" QMAKE_LINK_SHLIB="${CXX}" \
58                 QMAKE_CFLAGS="${CFLAGS}" \
59                 QMAKE_CXXFLAGS="${CXXFLAGS}" \
60                 QMAKE_LFLAGS="${LDFLAGS}" \
61                 QMAKE_LIBS="${LIBS}" \
62                 QMAKE_CFLAGS_DEBUG="" \
63                 QMAKE_CFLAGS_RELEASE="" \
64                 QMAKE_CXXFLAGS_DEBUG="" \
65                 QMAKE_CXXFLAGS_RELEASE="" \
66                 PREFIX="${PREFIX}"
67
68 .if defined(WITH_DEBUG)
69 QMAKE_ARGS+=    CONFIG+="debug" \
70                 CONFIG-="release"
71 .else
72 QMAKE_ARGS+=    CONFIG+="release" \
73                 CONFIG-="debug separate_debug_info"
74 .endif # defined(WITH_DEBUG)
75
76 # We set -recursive by default to keep qmake from running in the build stage.
77 .if ! ${qmake_ARGS:Mnorecursive}
78 QMAKE_ARGS+=    -recursive
79 .endif
80
81 .if defined(QMAKE_VERBOSE)
82 QMAKE_ARGS+=    -d
83 .endif
84
85 # _QMAKE_WRKSRC (and _QMAKE, below) are needed to abstract the qmake target and
86 # use it for both qtbase and USES=qmake ports. They are private, not supposed to
87 # be used anywhere else.
88 _QMAKE_WRKSRC?= ${CONFIGURE_WRKSRC}
89 .if ${qmake_ARGS:Moutsource}
90 CONFIGURE_WRKSRC=       ${WRKDIR}/.build
91 BUILD_WRKSRC=           ${CONFIGURE_WRKSRC}
92 INSTALL_WRKSRC=         ${BUILD_WRKSRC}
93 QMAKE_SOURCE_PATH?=     ${WRKSRC}
94 .else
95 QMAKE_SOURCE_PATH?=     # empty
96 .endif
97
98 .if ! ${qmake_ARGS:M_env}
99 DESTDIRNAME=    INSTALL_ROOT
100 .endif
101
102 # Define a custom target to make it usable by bsd.qt.mk for internal Qt
103 # configuration.
104 qmake-configure:
105         @${MKDIR} ${_QMAKE_WRKSRC}
106         @cd ${_QMAKE_WRKSRC} && \
107                 ${SETENV} ${QMAKE_ENV} ${_QMAKE} ${QMAKE_ARGS} ${QMAKE_SOURCE_PATH}
108
109 .if !target(do-configure) && ! ${qmake_ARGS:M_env}
110 _USES_configure+=       450:qmake-configure
111 .endif
112
113 .endif # !defined(_INCLUDE_USES_QMAKE_MK)