summaryrefslogtreecommitdiffstats
path: root/mkspecs/features/symbian/symbian_building.prf
blob: 802adde5135fbea6b4632b203646416ca0e23a7a (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
# we have some module specific options (defined in qt.prf) lets add them
!contains(TARGET, ".*[ -].*"):eval(TMPVAR = \$\$QMAKE_$${TARGET}_CXXFLAGS)
!isEmpty(TMPVAR):QMAKE_CXXFLAGS += $$TMPVAR
!contains(TARGET, ".*[ -].*"):eval(TMPVAR = \$\$QMAKE_$${TARGET}_LFLAGS)
!isEmpty(TMPVAR) {
    QMAKE_LFLAGS += $$TMPVAR
} else :linux-gcce {  # lets provide a simple default. Without elf2e32 complains
    QMAKE_LFLAGS += -Ttext 0x80000 -Tdata 0x400000
}

symbianObjdir=$$OBJECTS_DIR
isEmpty(symbianObjdir) {
    symbianObjdir = .
}
symbianDestdir=$$DESTDIR
isEmpty(symbianDestdir) {
    symbianDestdir = .
}

contains(QMAKE_CFLAGS, "--thumb")|contains(QMAKE_CXXFLAGS, "--thumb")|contains(QMAKE_CFLAGS, "-mthumb")|contains(QMAKE_CXXFLAGS, "-mthumb") {
    DEFINES += __MARM_THUMB__
}

defineReplace(processSymbianLibraries) {
    library = $$replace(1, "\.dll$", ".dso")
    library = $$replace(library, "^-l", "")
    isFullName = $$find(library, \.)
    isEmpty(isFullName):library="$${library}.dso"
    linux-gcce {
        newLIB = "-l:$${library}"
    } else {
        newLIB = "$${library}"
    }
    contains(library, "\.dso$")|contains(library, ".lib$"):PRE_TARGETDEPS += $$library
    return($$newLIB)
}

for(libraries, LIBS) {
    newLIBS += $$processSymbianLibraries($$libraries)
}
LIBS = $$newLIBS
newLIBS =
for(libraries, QMAKE_LIBS) {
    newLIBS += $$processSymbianLibraries($$libraries)
}
QMAKE_LIBS = $$newLIBS

elf2e32_LIBPATH =
for(libPath, QMAKE_LIBDIR) {
    elf2e32_LIBPATH += "--libpath=$$libPath"
}

isEmpty(VERSION) {
    VERSION = $$QT_VERSION
}

# Check for version validity.
!isEmpty(VERSION):!contains(VERSION, "[0-9]+"):!contains(VERSION, "[0-9]+\.[0-9]+")!contains(VERSION, "[0-9]+(\.[0-9]+){2}") {
    error("Invalid VERSION for Symbian: $$VERSION")
}

splitVersion = $$split(VERSION, ".")
count(splitVersion, 0) {
    # Default Symbian version if none is specified.
    hexVersion = "000a0000"
    decVersion = "10.0"
} else {
    count(splitVersion, 3) {
        hexVersion = $$system("sh -c 'printf %02x $$member(splitVersion, 0)'")
        hexPart2 = $$system("sh -c 'printf %02x $$member(splitVersion, 1)'")"
        hexPart2 = $$hexPart2$$system("sh -c 'printf %02x $$member(splitVersion, 2)'")"
        decVersion = $$system("sh -c 'printf %1d 0x$$hexVersion'").
        hexVersion = $$hexVersion$$hexPart2
        decVersion = $$decVersion$$system("sh -c 'printf %d 0x$$hexPart2'")
        !contains(hexVersion, "[0-9a-f]{8}"):hexVersion = "00$${hexVersion}"
    } else {  # app code may have different numbering...
        hexVersion = $$VERSION
        decVersion = $$VERSION
    }
}
#error ("hexVersion: $$hexVersion, decVersion: $$decVersion")

intUid3 = $$lower($$replace(TARGET.UID3, "^0x", ""))
isEmpty(TARGET.SID):TARGET.SID = $$TARGET.UID3
isEmpty(TARGET.UID2):TARGET.UID2 = 0x00000000

capability = $$replace(TARGET.CAPABILITY, " ", "+")
capability = $$join(capability, "+")
capability = $$replace(capability, "\+-", "-")
isEmpty(capability): capability = "None"
capability = "--capability=$$capability"

contains(TEMPLATE, lib):!contains(CONFIG, static):!contains(CONFIG, staticlib) {
    !isEmpty(QMAKE_POST_LINK) {
        # No way to honor the '@' :-(
        QMAKE_POST_LINK = $$replace(QMAKE_POST_LINK, "^@", "")
        QMAKE_POST_LINK = && $$QMAKE_POST_LINK
    }
    # The tee and grep at the end work around the issue that elf2e32 doesn't return non-null on error.
    # The comparison of dso files is to avoid extra building of modules that depend on this dso, in
    # case it has not changed.
    QMAKE_POST_LINK = $$QMAKE_MOVE $$symbianDestdir/$${TARGET}.dll $$symbianDestdir/$${TARGET}.sym \
                      && elf2e32  --version=$$decVersion \
                      --sid=$$TARGET.SID \
                      --uid1=0x10000079 \
                      --uid2=$$TARGET.UID2 \
                      --uid3=$$TARGET.UID3 \
                      --targettype=DLL \
                      --elfinput=$${symbianDestdir}/$${TARGET}.sym \
                      --output=$${symbianDestdir}/$${TARGET}.dll \
                      --dso=$$symbianObjdir/$${TARGET}.dso \
                      --defoutput=$$symbianObjdir/$${TARGET}.def \
                      --linkas=$${TARGET}\\{$${hexVersion}\\}\\[$${intUid3}\\].dll \
                      $$elf2e32_LIBPATH \
                      $$capability \
                      $$QMAKE_ELF2E32_FLAGS \
                      | tee elf2e32.log && test `grep -c 'Error:' elf2e32.log` = 0 && rm elf2e32.log \
                      && if ! diff -q $${symbianObjdir}/$${TARGET}.dso $${symbianDestdir}/$${TARGET}.dso \
                      > /dev/null 2>&1; then \
                          $$QMAKE_COPY $${symbianObjdir}/$${TARGET}.dso $${symbianDestdir}/$${TARGET}.dso; \
                      fi \
                      $$QMAKE_POST_LINK
    QMAKE_DISTCLEAN += $${symbianDestdir}/$${TARGET}.sym
    QMAKE_DISTCLEAN += $${symbianDestdir}/$${TARGET}.dso
    QMAKE_CLEAN += $${symbianObjdir}/$${TARGET}.dso
    QMAKE_CLEAN += $${symbianObjdir}/$${TARGET}.def

    linux-armcc: {
        LIBS += usrt2_2.lib dfpaeabi.dso dfprvct2_2.dso drtaeabi.dso scppnwdl.dso drtrvct2_2.dso h_t__uf.l\\(switch8.o\\)
        LIBS += -ledllstub.lib -ledll.lib\\(uc_dll_.o\\)
    } else :linux-gcce {
        LIBS += \
            -l:edll.lib \
            -l:usrt2_2.lib \
            -l:dfpaeabi.dso \
            -l:drtaeabi.dso \
            -l:scppnwdl.dso \
            -lsupc++ \
            -lgcc
    }

    QMAKE_LFLAGS += --soname $${TARGET}\\{$${hexVersion}\\}\\[$${intUid3}\\].dll
    DEFINES += __DLL__
}

contains(TEMPLATE, app):!contains(QMAKE_LINK, "^@.*") {
    !isEmpty(QMAKE_POST_LINK) {
        # No way to honor the '@' :-(
        QMAKE_POST_LINK = $$replace(QMAKE_POST_LINK, "^@", "")
        QMAKE_POST_LINK = && $$QMAKE_POST_LINK
    }
    # the tee and grep at the end work around the issue that elf2e32 doesn't return non-null on error
    QMAKE_POST_LINK = $$QMAKE_MOVE $$symbianDestdir/$${TARGET} $$symbianDestdir/$${TARGET}.sym \
                      && elf2e32  --version $$decVersion \
                      --sid=$$TARGET.SID \
                      --uid1=0x1000007a \
                      --uid2=$$TARGET.UID2 \
                      --uid3=$$TARGET.UID3 \
                      --targettype=EXE \
                      --elfinput=$${symbianDestdir}/$${TARGET}.sym \
                      --output=$${symbianDestdir}/$${TARGET}.exe \
                      --linkas=$${TARGET}\\{$${hexVersion}\\}\\[$${intUid3}\\].exe \
                      $$elf2e32_LIBPATH \
                      $$capability \
                      $$QMAKE_ELF2E32_FLAGS \
                      | tee elf2e32.log && test `grep -c 'Error:' elf2e32.log` = 0 && rm elf2e32.log \
                      && ln "$${symbianDestdir}/$${TARGET}.exe" "$${symbianDestdir}/$$TARGET" \
                      $$QMAKE_POST_LINK
    QMAKE_DISTCLEAN += $${symbianDestdir}/$${TARGET}.sym
    QMAKE_DISTCLEAN += $${symbianDestdir}/$${TARGET}.exe
    QMAKE_CLEAN += $${symbianDestdir}/$${TARGET}

    linux-armcc: {
        QMAKE_LIBS += usrt2_2.lib dfpaeabi.dso dfprvct2_2.dso drtaeabi.dso scppnwdl.dso drtrvct2_2.dso h_t__uf.l\\(switch8.o\\)
        QMAKE_LIBS += -leexe.lib\\(uc_exe_.o\\)
        contains(CONFIG, "qt"):contains(QT, "core") { #if linking with QtCore
            QMAKE_LIBS += -lqtmain$${QT_LIBINFIX}.lib
        } else {
            QMAKE_LIBS += -llibcrt0.lib
        }
    } else :linux-gcce {
        # notice that we can't merge these as ordering of arguments is important.
        QMAKE_LIBS += \
            -l:eexe.lib \
            -l:usrt2_2.lib
        contains(CONFIG, "qt"):contains(QT, "core") { #if linking with QtCore
            QMAKE_LIBS += -l:qtmain$${QT_LIBINFIX}.lib
        } else {
            QMAKE_LIBS += -l:libcrt0_gcce.lib
        }
        QMAKE_LIBS += \
            -l:dfpaeabi.dso \
            -l:drtaeabi.dso \
            -l:scppnwdl.dso \
            -lsupc++ \
            -lgcc
        QMAKE_LFLAGS += --shared
    }

    QMAKE_LFLAGS += --soname $${TARGET}\\{$${hexVersion}\\}\\[$${intUid3}\\].exe
    DEFINES += __EXE__
}

# Symbian resource files
linux-armcc: {
    SYMBIAN_RVCT22INC=$$(RVCT22INC)
    !isEmpty(SYMBIAN_RVCT22INC):symbian_resources_INCLUDES = -I$${SYMBIAN_RVCT22INC}
}
symbian_resources_INCLUDES = $$replace(symbian_resources_INCLUDES, ",", " -I")
symbian_resources_INCLUDES += $$join(INCLUDEPATH, " -I", "-I")
symbian_resources_DEFINES = $$join(DEFINES, " -D", "-D")
symbian_resources_RCC_DIR = $$replace(RCC_DIR, "/$", "")
symbian_resources_INCLUDES += "-I $$symbian_resources_RCC_DIR"

for(symbian_resource, SYMBIAN_RESOURCES) {
    symbian_resource = $$basename(symbian_resource)
    symbian_resource_clean = $$replace(symbian_resource, "\.rss$", ".rsc")
    QMAKE_DISTCLEAN += $${symbianDestdir}/$${symbian_resource_clean}
    symbian_resource_clean = $$replace(symbian_resource, "\.rss$", ".rpp")
    QMAKE_CLEAN += $${symbian_resources_RCC_DIR}/$${symbian_resource_clean}
}

symbianresources.input = SYMBIAN_RESOURCES
symbianresources.output = $$symbian_resources_RCC_DIR/${QMAKE_FILE_BASE}$${QT_LIBINFIX}.rsg
symbianresources.commands = cpp -nostdinc -undef \
                            $$symbian_resources_INCLUDES \
                            $$symbian_resources_DEFINES \
                            ${QMAKE_FILE_NAME} \
                            -o $${symbian_resources_RCC_DIR}/${QMAKE_FILE_BASE}.rpp \
                            && rcomp -u -m045,046,047 \
                            -s$${symbian_resources_RCC_DIR}/${QMAKE_FILE_BASE}.rpp \
                            -o$${symbianDestdir}/${QMAKE_FILE_BASE}$${QT_LIBINFIX}.rsc \
                            -h$${symbian_resources_RCC_DIR}/${QMAKE_FILE_BASE}$${QT_LIBINFIX}.rsg \
                            -i${QMAKE_FILE_NAME}
symbianresources.dependency_type = TYPE_C
symbianresources.CONFIG = no_link target_predeps

QMAKE_EXTRA_COMPILERS += symbianresources

contains(TEMPLATE, "app"):!contains(CONFIG, "no_icon") {
    baseTarget = $$basename(TARGET)
    # If you change this, also see application_icon.prf
    baseTarget = $$replace(baseTarget, " ",_)

    # Make our own extra target in order to get dependencies for generated
    # files right. This also avoids the warning about files not found.
    symbianGenResource.target = $${symbian_resources_RCC_DIR}/$${baseTarget}.rsg
    symbianGenResource.commands = cpp -nostdinc -undef \
                                  $$symbian_resources_INCLUDES \
                                  $$symbian_resources_DEFINES \
                                  $${baseTarget}.rss \
                                  -o $${symbian_resources_RCC_DIR}/$${baseTarget}.rpp \
                                  && rcomp -u -m045,046,047 \
                                  -s$${symbian_resources_RCC_DIR}/$${baseTarget}.rpp \
                                  -o$${symbianDestdir}/$${baseTarget}.rsc \
                                  -h$${symbian_resources_RCC_DIR}/$${baseTarget}.rsg \
                                  -i$${baseTarget}.rss
    symbianGenResource.depends = $${baseTarget}.rss
    PRE_TARGETDEPS += $${symbian_resources_RCC_DIR}/$${baseTarget}.rsg
    QMAKE_CLEAN += $${symbian_resources_RCC_DIR}/$${baseTarget}.rsg
    QMAKE_CLEAN += $${symbian_resources_RCC_DIR}/$${baseTarget}.rpp
    QMAKE_DISTCLEAN += $${baseTarget}.rss
    QMAKE_DISTCLEAN += $${symbianDestdir}/$${baseTarget}.rsc

    symbianGenRegResource.target = $${symbian_resources_RCC_DIR}/$${baseTarget}_reg.rsg
    symbianGenRegResource.commands = cpp -nostdinc -undef \
                                     $$symbian_resources_INCLUDES \
                                     $$symbian_resources_DEFINES \
                                     $${baseTarget}_reg.rss \
                                     -o $${symbian_resources_RCC_DIR}/$${baseTarget}_reg.rpp \
                                     && rcomp -u -m045,046,047 \
                                     -s$${symbian_resources_RCC_DIR}/$${baseTarget}_reg.rpp \
                                     -o$${symbianDestdir}/$${baseTarget}_reg.rsc \
                                     -h$${symbian_resources_RCC_DIR}/$${baseTarget}_reg.rsg \
                                     -i$${baseTarget}_reg.rss
    symbianGenRegResource.depends = $${baseTarget}_reg.rss $${symbian_resources_RCC_DIR}/$${baseTarget}.rsg
    PRE_TARGETDEPS += $${symbian_resources_RCC_DIR}/$${baseTarget}_reg.rsg
    QMAKE_CLEAN += $${symbian_resources_RCC_DIR}/$${baseTarget}_reg.rsg
    QMAKE_CLEAN += $${symbian_resources_RCC_DIR}/$${baseTarget}_reg.rpp
    QMAKE_DISTCLEAN += $${TARGET}_reg.rss
    QMAKE_DISTCLEAN += $${symbianDestdir}/$${TARGET}_reg.rsc

    # Trick to get qmake to create the RCC_DIR for us.
    symbianRccDirCreation.input = SOURCES
    symbianRccDirCreation.commands =
    symbianRccDirCreation.output = $${symbian_resources_RCC_DIR}/symbian_resource_dummy
    symbianRccDirCreation.CONFIG = no_link combine

    QMAKE_EXTRA_TARGETS += symbianGenResource symbianGenRegResource
    QMAKE_EXTRA_COMPILERS += symbianRccDirCreation

    QMAKE_DISTCLEAN += $${TARGET}.loc
}

# Generated pkg files

QMAKE_DISTCLEAN += $${TARGET}_template.pkg