summaryrefslogtreecommitdiffstats
path: root/rbutil/rbutilqt/rbutilqt.pro
blob: 589774319934b2d2740058d9acaf1f47189e5f55 (plain)
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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
#
#             __________               __   ___.
#   Open      \______   \ ____   ____ |  | _\_ |__   _______  ___
#   Source     |       _//  _ \_/ ___\|  |/ /| __ \ /  _ \  \/  /
#   Jukebox    |    |   (  <_> )  \___|    < | \_\ (  <_> > <  <
#   Firmware   |____|_  /\____/ \___  >__|_ \|___  /\____/__/\_ \
#                     \/            \/     \/    \/            \/
#
# All files in this archive are subject to the GNU General Public License.
# See the file COPYING in the source tree root for full license agreement.
#
# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
# KIND, either express or implied.
#

# The external Makefiles use ar to create libs. To allow cross-compiling pass
# the ar that matches the current gcc. Since qmake doesn't provide a variable
# holding the correct ar without any additions we need to figure it ourselves
# here.
# Only do this if CC is gcc. Also, do this before ccache support is enabled.
contains(QMAKE_CC,($$find(QMAKE_CC,.*gcc.*))) {
    EXTRALIBS_OPTS = "EXTRALIBS_AR=\""$$replace(QMAKE_CC,gcc.*,ar)\"
}
# ccache
unix:!mac:!noccache {
    CCACHE = $$system(which ccache)
    !isEmpty(CCACHE) {
        message("using ccache at $$CCACHE")
        QMAKE_CXX = ccache $$QMAKE_CXX
        QMAKE_CC = ccache $$QMAKE_CC
    }
}
MACHINEFLAGS = $$find(QMAKE_CFLAGS, -m[63][42])
EXTRALIBS_OPTS += EXTRALIBS_CC=\"$$QMAKE_CC\"
EXTRALIBS_OPTS += EXTRALIBS_CXX=\"$$QMAKE_CXX\"
EXTRALIBS_OPTS += EXTRALIB_CFLAGS=\"$$MACHINEFLAGS\"
EXTRALIBS_OPTS += EXTRALIB_CXXFLAGS=\"$$MACHINEFLAGS\"

MYBUILDDIR = $$OUT_PWD/build/
MYLIBBUILDDIR = $$MYBUILDDIR/libs/
OBJECTS_DIR = $$MYBUILDDIR/o
UI_DIR = $$MYBUILDDIR/ui
MOC_DIR = $$MYBUILDDIR/moc
RCC_DIR = $$MYBUILDDIR/rcc

!silent {
    VERBOSE = "V=1"
} else {
    VERBOSE =
}

# check version of Qt installation
!contains(QT_MAJOR_VERSION, 5) {
    VER = $$find(QT_VERSION, ^4\\.[5-9]+.*)
    isEmpty(VER) {
        message("Qt >= 4.5 required!")
        !isEmpty(QT_VERSION) error("Qt found:" $$[QT_VERSION])
    }
message("using Qt version $$VER at $$[QT_INSTALL_PREFIX]")
}

RBBASE_DIR = $$_PRO_FILE_PWD_
RBBASE_DIR = $$replace(RBBASE_DIR,/rbutil/rbutilqt,)

message("using Rockbox basedir $$RBBASE_DIR")

# check for system speex. Add a custom rule for pre-building librbspeex if not
# found. Newer versions of speex are split up into libspeex and libspeexdsp,
# and some distributions package them separately. Check for both and fall back
# to librbspeex if not found.
# NOTE: keep adding the linker option after -lrbspeex, otherwise linker errors
# occur if the linker defaults to --as-needed
# (see http://www.gentoo.org/proj/en/qa/asneeded.xml)
#
# Always use our own copy when building statically. Don't search for libspeex
# on Mac, since we don't deploy statically there.
!static:unix:!mac {
    LIBSPEEX = $$system(pkg-config --silence-errors --libs speex speexdsp)
}

extralibs.commands = $$SILENT \
        $(MAKE) -f $$RBBASE_DIR/rbutil/rbutilqt/Makefile.libs \
        $$VERBOSE \
        SYS_SPEEX=\"$$LIBSPEEX\" \
        BUILD_DIR=$$MYLIBBUILDDIR/ \
        TARGET_DIR=$$MYLIBBUILDDIR \
        RBBASE_DIR=$$RBBASE_DIR \
        $$EXTRALIBS_OPTS \
        libs
# Note: order is important for RBLIBS! The libs are appended to the linker
# flags in this order, put libucl at the end.
RBLIBS = rbspeex ipodpatcher sansapatcher mkamsboot mktccboot \
         mkmpioboot chinachippatcher mkimxboot mks5lboot bspatch ucl
# NOTE: Linking bzip2 causes problems on Windows (Qt seems to export those
# symbols as well, similar to what we have with zlib.) Only link that on
# non-Windows for now.
!win32 {
    RBLIBS += bzip2
}
!win32-msvc* {
    QMAKE_EXTRA_TARGETS += extralibs
    PRE_TARGETDEPS += extralibs
}
win32-msvc* {
    INCLUDEPATH += msvc
    LIBS += -L$$_PRO_FILE_PWD_/msvc
    LIBS += -ladvapi32 # required for MSVC / Qt Creator combination
}

# rule for creating ctags file
tags.commands = ctags -R --c++-kinds=+p --fields=+iaS --extra=+q $(SOURCES)
tags.depends = $(SOURCES)
QMAKE_EXTRA_TARGETS += tags

# add a custom rule for making the translations
LRELEASE = $$[QT_INSTALL_BINS]/lrelease

win32:!cross:!exists($$LRELEASE) {
    LRELEASE = $$[QT_INSTALL_BINS]/lrelease.exe
}
lrelease.commands = $$LRELEASE -silent $$_PRO_FILE_
QMAKE_EXTRA_TARGETS += lrelease
exists($$LRELEASE) {
    message("using lrelease at $$LRELEASE")
    PRE_TARGETDEPS += lrelease
}
!exists($$LRELEASE) {
    warning("could not find lrelease. Skipping translations.")
}

# Needed by QT on Win
INCLUDEPATH += $$_PRO_FILE_PWD_ $$_PRO_FILE_PWD_/irivertools \
            $$_PRO_FILE_PWD_/zlib $$_PRO_FILE_PWD_/base \
            $$_PRO_FILE_PWD_/zlib $$_PRO_FILE_PWD_/gui
INCLUDEPATH += $$RBBASE_DIR/rbutil/ipodpatcher $$RBBASE_DIR/rbutil/sansapatcher \
            $$RBBASE_DIR/tools/rbspeex $$RBBASE_DIR/tools
INCLUDEPATH += logger

DEPENDPATH = $$INCLUDEPATH

LIBS += -L$$OUT_PWD -L$$MYLIBBUILDDIR
# append all RBLIBS to LIBS
for(rblib, RBLIBS) {
    LIBS += -l$$rblib
}

# We need libcrypto++
LIBS += -lcryptopp

# on win32 libz is linked implicitly.
!win32 {
    LIBS += -lz
}

# Add a (possibly found) libspeex now, don't do this before -lrbspeex!
!static:!isEmpty(LIBSPEEX) {
    LIBS += $$LIBSPEEX
}

TEMPLATE = app
TARGET = RockboxUtility
QT += network

contains(QT_MAJOR_VERSION, 5) {
    message("Qt5 found")
    QT += widgets multimedia
}

CONFIG += c++11

dbg {
    CONFIG += debug thread qt warn_on
    DEFINES += DBG
    message("creating debug version")
}
!dbg {
    CONFIG += release thread qt
    DEFINES += NODEBUG
    message("creating release version")
}

DEFINES += RBUTIL _LARGEFILE64_SOURCE

# check version of Qt installation
!contains(QT_MAJOR_VERSION, 5):!macx:linux-g++* {
    # suppress warnings in Qt 4.8 shown by gcc 4.8
    QMAKE_CXXFLAGS += -Wno-unused-local-typedefs
}
# platform specific
win32 {
    # use MinGW's implementation of stdio functions for extended format string
    # support.
    DEFINES += __USE_MINGW_ANSI_STDIO=1
    DEFINES += _CRT_SECURE_NO_WARNINGS
    DEFINES += UNICODE
    LIBS += -lsetupapi -lnetapi32
}
win32:static {
    QMAKE_LFLAGS += -static-libgcc -static-libstdc++
}
unix:!static:!libusb0:!macx {
    DEFINES += LIBUSB1
    LIBS += -lusb-1.0
}
unix:!static:libusb0:!macx {
    LIBS += -lusb
}

unix:!macx:static {
    # force statically linking of libusb. Libraries that are appended
    # later will get linked dynamically again.
    LIBS += -Wl,-Bstatic -lusb -Wl,-Bdynamic
}

# if -config intel is specified use 10.5 SDK and don't build for PPC
contains(QT_MAJOR_VERSION, 5) {
    macx {
        CONFIG += intel
        message("Qt5 doesn't support PPC anymore, building x86 only")
    }
}
macx:!intel {
    CONFIG += ppc
    QMAKE_LFLAGS_PPC=-mmacosx-version-min=10.4 -arch ppc
    QMAKE_LFLAGS_X86=-mmacosx-version-min=10.4 -arch i386
    QMAKE_MAC_SDK=/Developer/SDKs/MacOSX10.4u.sdk
}
macx:intel {
    contains(QT_MAJOR_VERSION, 5) {
        QMAKE_MAC_SDK=macosx
        greaterThan(QT_MINOR_VERSION, 5) {
            QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.7
            message("Qt 5.6+ detected: setting deploy target to 10.7")
        }
        !greaterThan(QT_MINOR_VERSION, 5) {
            QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.6
            message("Qt up to 5.5 detected: setting deploy target to 10.6")
        }
    }
    !contains(QT_MAJOR_VERSION, 5) {
        QMAKE_MAC_SDK=/Developer/SDKs/MacOSX10.5.sdk
        QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.5
        QMAKE_LFLAGS_X86=-mmacosx-version-min=10.5 -arch i386
    }
}
macx {
    CONFIG += x86
    LIBS += -L/usr/local/lib \
            -framework IOKit -framework CoreFoundation -framework Carbon \
            -framework SystemConfiguration -framework CoreServices
    INCLUDEPATH += /usr/local/include

    # rule for creating a dmg file
    dmg.commands = hdiutil create -ov -srcfolder RockboxUtility.app/ RockboxUtility.dmg
    QMAKE_EXTRA_TARGETS += dmg
}

static {
    if(equals(QT_MAJOR_VERSION, 5) : lessThan(QT_MINOR_VERSION, 4)) | lessThan(QT_MAJOR_VERSION, 5) {
            QTPLUGIN += qtaccessiblewidgets
            LIBS += -L$$(QT_BUILD_TREE)/plugins/accessible -lqtaccessiblewidgets
    }
    LIBS += -L.
    DEFINES += STATIC
    message("using static plugin")
}

unix {
    target.path = /usr/local/bin
    INSTALLS += target
}

unix:!macx {
    LINUXDEPLOYQTURL = https://github.com/linuxdeploy/linuxdeploy-plugin-qt/releases/download/continuous/linuxdeploy-plugin-qt-x86_64.AppImage
    LINUXDEPLOYURL = https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage

    appimage_dl.commands = \
        curl -C- -fLO $$LINUXDEPLOYQTURL -fLO $$LINUXDEPLOYURL ; \
        chmod +x *.AppImage; \
        touch appimage_dl

    appimage_prepare.commands = \
        mkdir -p AppImage/usr/bin; \
        cp ${TARGET} AppImage/usr/bin
    appimage_prepare.depends = ${TARGET} appimage_dl

    appimage.commands = \
        ./linuxdeploy-x86_64.AppImage \
        --appdir AppImage \
        --verbosity 2 --plugin qt --output appimage \
        -e AppImage/usr/bin/${TARGET} \
        -d $$_PRO_FILE_PWD_/RockboxUtility.desktop \
        -i $$RBBASE_DIR/docs/logo/rockbox-clef.svg
    appimage.depends = appimage_prepare

    QMAKE_EXTRA_TARGETS += appimage_dl appimage_prepare appimage
}


# source files are separate.
include(rbutilqt.pri)
include(quazip/quazip.pri)
include(logger/logger.pri)