mkspecs/features/symbian/symbian_building.prf
changeset 30 5dc02b23752f
child 33 3e2da88830cd
equal deleted inserted replaced
29:b72c6db6890b 30:5dc02b23752f
       
     1 # we have some module specific options (defined in qt.prf) lets add them
       
     2 !contains(TARGET, ".*[ -].*"):eval(TMPVAR = \$\$QMAKE_$${TARGET}_CXXFLAGS)
       
     3 !isEmpty(TMPVAR):QMAKE_CXXFLAGS += $$TMPVAR
       
     4 !contains(TARGET, ".*[ -].*"):eval(TMPVAR = \$\$QMAKE_$${TARGET}_LFLAGS)
       
     5 !isEmpty(TMPVAR) {
       
     6     QMAKE_LFLAGS += $$TMPVAR
       
     7 } else :linux-gcce {  # lets provide a simple default. Without elf2e32 complains
       
     8     QMAKE_LFLAGS += -Ttext 0x80000 -Tdata 0x400000
       
     9 }
       
    10 
       
    11 symbianObjdir=$$OBJECTS_DIR
       
    12 isEmpty(symbianObjdir) {
       
    13     symbianObjdir = .
       
    14 }
       
    15 symbianDestdir=$$DESTDIR
       
    16 isEmpty(symbianDestdir) {
       
    17     symbianDestdir = .
       
    18 }
       
    19 
       
    20 contains(QMAKE_CFLAGS, "--thumb")|contains(QMAKE_CXXFLAGS, "--thumb")|contains(QMAKE_CFLAGS, "-mthumb")|contains(QMAKE_CXXFLAGS, "-mthumb") {
       
    21     DEFINES += __MARM_THUMB__
       
    22 }
       
    23 
       
    24 defineReplace(processSymbianLibraries) {
       
    25     library = $$replace(1, "\.dll$", ".dso")
       
    26     library = $$replace(library, "^-l", "")
       
    27     isFullName = $$find(library, \.)
       
    28     isEmpty(isFullName):library="$${library}.dso"
       
    29     linux-gcce {
       
    30         newLIB = "-l:$${library}"
       
    31     } else {
       
    32         newLIB = "$${library}"
       
    33     }
       
    34     contains(library, "\.dso$")|contains(library, ".lib$"):PRE_TARGETDEPS += $$library
       
    35     return($$newLIB)
       
    36 }
       
    37 
       
    38 for(libraries, LIBS) {
       
    39     newLIBS += $$processSymbianLibraries($$libraries)
       
    40 }
       
    41 LIBS = $$newLIBS
       
    42 newLIBS =
       
    43 for(libraries, QMAKE_LIBS) {
       
    44     newLIBS += $$processSymbianLibraries($$libraries)
       
    45 }
       
    46 QMAKE_LIBS = $$newLIBS
       
    47 
       
    48 elf2e32_LIBPATH =
       
    49 for(libPath, QMAKE_LIBDIR) {
       
    50     elf2e32_LIBPATH += "--libpath=$$libPath"
       
    51 }
       
    52 
       
    53 isEmpty(VERSION) {
       
    54     VERSION = $$QT_VERSION
       
    55 }
       
    56 
       
    57 # Check for version validity.
       
    58 !isEmpty(VERSION):!contains(VERSION, "[0-9]+"):!contains(VERSION, "[0-9]+\.[0-9]+")!contains(VERSION, "[0-9]+(\.[0-9]+){2}") {
       
    59     error("Invalid VERSION for Symbian: $$VERSION")
       
    60 }
       
    61 
       
    62 splitVersion = $$split(VERSION, ".")
       
    63 count(splitVersion, 0) {
       
    64     # Default Symbian version if none is specified.
       
    65     hexVersion = "000a0000"
       
    66     decVersion = "10.0"
       
    67 } else {
       
    68     count(splitVersion, 3) {
       
    69         hexVersion = $$system("sh -c 'printf %02x $$member(splitVersion, 0)'")
       
    70         hexPart2 = $$system("sh -c 'printf %02x $$member(splitVersion, 1)'")"
       
    71         hexPart2 = $$hexPart2$$system("sh -c 'printf %02x $$member(splitVersion, 2)'")"
       
    72         decVersion = $$system("sh -c 'printf %1d 0x$$hexVersion'").
       
    73         hexVersion = $$hexVersion$$hexPart2
       
    74         decVersion = $$decVersion$$system("sh -c 'printf %d 0x$$hexPart2'")
       
    75         !contains(hexVersion, "[0-9a-f]{8}"):hexVersion = "00$${hexVersion}"
       
    76     } else {  # app code may have different numbering...
       
    77         hexVersion = $$VERSION
       
    78         decVersion = $$VERSION
       
    79     }
       
    80 }
       
    81 #error ("hexVersion: $$hexVersion, decVersion: $$decVersion")
       
    82 
       
    83 intUid3 = $$lower($$replace(TARGET.UID3, "^0x", ""))
       
    84 isEmpty(TARGET.SID):TARGET.SID = $$TARGET.UID3
       
    85 isEmpty(TARGET.UID2):TARGET.UID2 = 0x00000000
       
    86 
       
    87 capability = $$replace(TARGET.CAPABILITY, " ", "+")
       
    88 capability = $$join(capability, "+")
       
    89 capability = $$replace(capability, "\+-", "-")
       
    90 isEmpty(capability): capability = "None"
       
    91 capability = "--capability=$$capability"
       
    92 
       
    93 contains(TEMPLATE, lib):!contains(CONFIG, static):!contains(CONFIG, staticlib) {
       
    94     !isEmpty(QMAKE_POST_LINK) {
       
    95         # No way to honor the '@' :-(
       
    96         QMAKE_POST_LINK = $$replace(QMAKE_POST_LINK, "^@", "")
       
    97         QMAKE_POST_LINK = && $$QMAKE_POST_LINK
       
    98     }
       
    99     # The tee and grep at the end work around the issue that elf2e32 doesn't return non-null on error.
       
   100     # The comparison of dso files is to avoid extra building of modules that depend on this dso, in
       
   101     # case it has not changed.
       
   102     QMAKE_POST_LINK = $$QMAKE_MOVE $$symbianDestdir/$${TARGET}.dll $$symbianDestdir/$${TARGET}.sym \
       
   103                       && elf2e32  --version=$$decVersion \
       
   104                       --sid=$$TARGET.SID \
       
   105                       --uid1=0x10000079 \
       
   106                       --uid2=$$TARGET.UID2 \
       
   107                       --uid3=$$TARGET.UID3 \
       
   108                       --targettype=DLL \
       
   109                       --elfinput=$${symbianDestdir}/$${TARGET}.sym \
       
   110                       --output=$${symbianDestdir}/$${TARGET}.dll \
       
   111                       --dso=$$symbianObjdir/$${TARGET}.dso \
       
   112                       --defoutput=$$symbianObjdir/$${TARGET}.def \
       
   113                       --linkas=$${TARGET}\\{$${hexVersion}\\}\\[$${intUid3}\\].dll \
       
   114                       $$elf2e32_LIBPATH \
       
   115                       $$capability \
       
   116                       $$QMAKE_ELF2E32_FLAGS \
       
   117                       | tee elf2e32.log && test `grep -c 'Error:' elf2e32.log` = 0 && rm elf2e32.log \
       
   118                       && if ! diff -q $${symbianObjdir}/$${TARGET}.dso $${symbianDestdir}/$${TARGET}.dso \
       
   119                       > /dev/null 2>&1; then \
       
   120                           $$QMAKE_COPY $${symbianObjdir}/$${TARGET}.dso $${symbianDestdir}/$${TARGET}.dso; \
       
   121                       fi \
       
   122                       $$QMAKE_POST_LINK
       
   123     QMAKE_DISTCLEAN += $${symbianDestdir}/$${TARGET}.sym
       
   124     QMAKE_DISTCLEAN += $${symbianDestdir}/$${TARGET}.dso
       
   125     QMAKE_CLEAN += $${symbianObjdir}/$${TARGET}.dso
       
   126     QMAKE_CLEAN += $${symbianObjdir}/$${TARGET}.def
       
   127 
       
   128     linux-armcc: {
       
   129         LIBS += usrt2_2.lib dfpaeabi.dso dfprvct2_2.dso drtaeabi.dso scppnwdl.dso drtrvct2_2.dso h_t__uf.l\\(switch8.o\\)
       
   130         LIBS += -ledllstub.lib -ledll.lib\\(uc_dll_.o\\)
       
   131     } else :linux-gcce {
       
   132         LIBS += \
       
   133             -l:edll.lib \
       
   134             -l:usrt2_2.lib \
       
   135             -l:dfpaeabi.dso \
       
   136             -l:drtaeabi.dso \
       
   137             -l:scppnwdl.dso \
       
   138             -lsupc++ \
       
   139             -lgcc
       
   140     }
       
   141 
       
   142     QMAKE_LFLAGS += --soname $${TARGET}\\{$${hexVersion}\\}\\[$${intUid3}\\].dll
       
   143     DEFINES += __DLL__
       
   144 }
       
   145 
       
   146 contains(TEMPLATE, app):!contains(QMAKE_LINK, "^@.*") {
       
   147     !isEmpty(QMAKE_POST_LINK) {
       
   148         # No way to honor the '@' :-(
       
   149         QMAKE_POST_LINK = $$replace(QMAKE_POST_LINK, "^@", "")
       
   150         QMAKE_POST_LINK = && $$QMAKE_POST_LINK
       
   151     }
       
   152     # the tee and grep at the end work around the issue that elf2e32 doesn't return non-null on error
       
   153     QMAKE_POST_LINK = $$QMAKE_MOVE $$symbianDestdir/$${TARGET} $$symbianDestdir/$${TARGET}.sym \
       
   154                       && elf2e32  --version $$decVersion \
       
   155                       --sid=$$TARGET.SID \
       
   156                       --uid1=0x1000007a \
       
   157                       --uid2=$$TARGET.UID2 \
       
   158                       --uid3=$$TARGET.UID3 \
       
   159                       --targettype=EXE \
       
   160                       --elfinput=$${symbianDestdir}/$${TARGET}.sym \
       
   161                       --output=$${symbianDestdir}/$${TARGET}.exe \
       
   162                       --linkas=$${TARGET}\\{$${hexVersion}\\}\\[$${intUid3}\\].exe \
       
   163                       $$elf2e32_LIBPATH \
       
   164                       $$capability \
       
   165                       $$QMAKE_ELF2E32_FLAGS \
       
   166                       | tee elf2e32.log && test `grep -c 'Error:' elf2e32.log` = 0 && rm elf2e32.log \
       
   167                       && ln "$${symbianDestdir}/$${TARGET}.exe" "$${symbianDestdir}/$$TARGET" \
       
   168                       $$QMAKE_POST_LINK
       
   169     QMAKE_DISTCLEAN += $${symbianDestdir}/$${TARGET}.sym
       
   170     QMAKE_DISTCLEAN += $${symbianDestdir}/$${TARGET}.exe
       
   171     QMAKE_CLEAN += $${symbianDestdir}/$${TARGET}
       
   172 
       
   173     linux-armcc: {
       
   174         QMAKE_LIBS += usrt2_2.lib dfpaeabi.dso dfprvct2_2.dso drtaeabi.dso scppnwdl.dso drtrvct2_2.dso h_t__uf.l\\(switch8.o\\)
       
   175         QMAKE_LIBS += -leexe.lib\\(uc_exe_.o\\)
       
   176         contains(CONFIG, "qt"):contains(QT, "core") { #if linking with QtCore
       
   177             QMAKE_LIBS += -lqtmain$${QT_LIBINFIX}.lib
       
   178         } else {
       
   179             QMAKE_LIBS += -llibcrt0.lib
       
   180         }
       
   181     } else :linux-gcce {
       
   182         # notice that we can't merge these as ordering of arguments is important.
       
   183         QMAKE_LIBS += \
       
   184             -l:eexe.lib \
       
   185             -l:usrt2_2.lib
       
   186         contains(CONFIG, "qt"):contains(QT, "core") { #if linking with QtCore
       
   187             QMAKE_LIBS += -l:qtmain$${QT_LIBINFIX}.lib
       
   188         } else {
       
   189             QMAKE_LIBS += -l:libcrt0_gcce.lib
       
   190         }
       
   191         QMAKE_LIBS += \
       
   192             -l:dfpaeabi.dso \
       
   193             -l:drtaeabi.dso \
       
   194             -l:scppnwdl.dso \
       
   195             -lsupc++ \
       
   196             -lgcc
       
   197         QMAKE_LFLAGS += --shared
       
   198     }
       
   199 
       
   200     QMAKE_LFLAGS += --soname $${TARGET}\\{$${hexVersion}\\}\\[$${intUid3}\\].exe
       
   201     DEFINES += __EXE__
       
   202 }
       
   203 
       
   204 # Symbian resource files
       
   205 linux-armcc: {
       
   206     SYMBIAN_RVCT22INC=$$(RVCT22INC)
       
   207     !isEmpty(SYMBIAN_RVCT22INC):symbian_resources_INCLUDES = -I$${SYMBIAN_RVCT22INC}
       
   208 }
       
   209 symbian_resources_INCLUDES = $$replace(symbian_resources_INCLUDES, ",", " -I")
       
   210 symbian_resources_INCLUDES += $$join(INCLUDEPATH, " -I", "-I")
       
   211 symbian_resources_DEFINES = $$join(DEFINES, " -D", "-D")
       
   212 symbian_resources_RCC_DIR = $$replace(RCC_DIR, "/$", "")
       
   213 symbian_resources_INCLUDES += "-I $$symbian_resources_RCC_DIR"
       
   214 
       
   215 for(symbian_resource, SYMBIAN_RESOURCES) {
       
   216     symbian_resource = $$basename(symbian_resource)
       
   217     symbian_resource_clean = $$replace(symbian_resource, "\.rss$", ".rsc")
       
   218     QMAKE_DISTCLEAN += $${symbianDestdir}/$${symbian_resource_clean}
       
   219     symbian_resource_clean = $$replace(symbian_resource, "\.rss$", ".rpp")
       
   220     QMAKE_CLEAN += $${symbian_resources_RCC_DIR}/$${symbian_resource_clean}
       
   221 }
       
   222 
       
   223 symbianresources.input = SYMBIAN_RESOURCES
       
   224 symbianresources.output = $$symbian_resources_RCC_DIR/${QMAKE_FILE_BASE}$${QT_LIBINFIX}.rsg
       
   225 symbianresources.commands = cpp -nostdinc -undef \
       
   226                             $$symbian_resources_INCLUDES \
       
   227                             $$symbian_resources_DEFINES \
       
   228                             ${QMAKE_FILE_NAME} \
       
   229                             -o $${symbian_resources_RCC_DIR}/${QMAKE_FILE_BASE}.rpp \
       
   230                             && rcomp -u -m045,046,047 \
       
   231                             -s$${symbian_resources_RCC_DIR}/${QMAKE_FILE_BASE}.rpp \
       
   232                             -o$${symbianDestdir}/${QMAKE_FILE_BASE}$${QT_LIBINFIX}.rsc \
       
   233                             -h$${symbian_resources_RCC_DIR}/${QMAKE_FILE_BASE}$${QT_LIBINFIX}.rsg \
       
   234                             -i${QMAKE_FILE_NAME}
       
   235 symbianresources.dependency_type = TYPE_C
       
   236 symbianresources.CONFIG = no_link target_predeps
       
   237 
       
   238 QMAKE_EXTRA_COMPILERS += symbianresources
       
   239 
       
   240 contains(TEMPLATE, "app"):!contains(CONFIG, "no_icon") {
       
   241     baseTarget = $$basename(TARGET)
       
   242     # If you change this, also see application_icon.prf
       
   243     baseTarget = $$replace(baseTarget, " ",_)
       
   244 
       
   245     # Make our own extra target in order to get dependencies for generated
       
   246     # files right. This also avoids the warning about files not found.
       
   247     symbianGenResource.target = $${symbian_resources_RCC_DIR}/$${baseTarget}.rsg
       
   248     symbianGenResource.commands = cpp -nostdinc -undef \
       
   249                                   $$symbian_resources_INCLUDES \
       
   250                                   $$symbian_resources_DEFINES \
       
   251                                   $${baseTarget}.rss \
       
   252                                   -o $${symbian_resources_RCC_DIR}/$${baseTarget}.rpp \
       
   253                                   && rcomp -u -m045,046,047 \
       
   254                                   -s$${symbian_resources_RCC_DIR}/$${baseTarget}.rpp \
       
   255                                   -o$${symbianDestdir}/$${baseTarget}.rsc \
       
   256                                   -h$${symbian_resources_RCC_DIR}/$${baseTarget}.rsg \
       
   257                                   -i$${baseTarget}.rss
       
   258     symbianGenResource.depends = $${baseTarget}.rss
       
   259     PRE_TARGETDEPS += $${symbian_resources_RCC_DIR}/$${baseTarget}.rsg
       
   260     QMAKE_CLEAN += $${symbian_resources_RCC_DIR}/$${baseTarget}.rsg
       
   261     QMAKE_CLEAN += $${symbian_resources_RCC_DIR}/$${baseTarget}.rpp
       
   262     QMAKE_DISTCLEAN += $${baseTarget}.rss
       
   263     QMAKE_DISTCLEAN += $${symbianDestdir}/$${baseTarget}.rsc
       
   264 
       
   265     symbianGenRegResource.target = $${symbian_resources_RCC_DIR}/$${baseTarget}_reg.rsg
       
   266     symbianGenRegResource.commands = cpp -nostdinc -undef \
       
   267                                      $$symbian_resources_INCLUDES \
       
   268                                      $$symbian_resources_DEFINES \
       
   269                                      $${baseTarget}_reg.rss \
       
   270                                      -o $${symbian_resources_RCC_DIR}/$${baseTarget}_reg.rpp \
       
   271                                      && rcomp -u -m045,046,047 \
       
   272                                      -s$${symbian_resources_RCC_DIR}/$${baseTarget}_reg.rpp \
       
   273                                      -o$${symbianDestdir}/$${baseTarget}_reg.rsc \
       
   274                                      -h$${symbian_resources_RCC_DIR}/$${baseTarget}_reg.rsg \
       
   275                                      -i$${baseTarget}_reg.rss
       
   276     symbianGenRegResource.depends = $${baseTarget}_reg.rss $${symbian_resources_RCC_DIR}/$${baseTarget}.rsg
       
   277     PRE_TARGETDEPS += $${symbian_resources_RCC_DIR}/$${baseTarget}_reg.rsg
       
   278     QMAKE_CLEAN += $${symbian_resources_RCC_DIR}/$${baseTarget}_reg.rsg
       
   279     QMAKE_CLEAN += $${symbian_resources_RCC_DIR}/$${baseTarget}_reg.rpp
       
   280     QMAKE_DISTCLEAN += $${TARGET}_reg.rss
       
   281     QMAKE_DISTCLEAN += $${symbianDestdir}/$${TARGET}_reg.rsc
       
   282 
       
   283     # Trick to get qmake to create the RCC_DIR for us.
       
   284     symbianRccDirCreation.input = SOURCES
       
   285     symbianRccDirCreation.commands =
       
   286     symbianRccDirCreation.output = $${symbian_resources_RCC_DIR}/symbian_resource_dummy
       
   287     symbianRccDirCreation.CONFIG = no_link combine
       
   288 
       
   289     QMAKE_EXTRA_TARGETS += symbianGenResource symbianGenRegResource
       
   290     QMAKE_EXTRA_COMPILERS += symbianRccDirCreation
       
   291 
       
   292     QMAKE_DISTCLEAN += $${TARGET}.loc
       
   293 }
       
   294 
       
   295 # Generated pkg files
       
   296 
       
   297 QMAKE_DISTCLEAN += $${TARGET}_template.pkg