build/omj.pri
changeset 21 2a9601315dfc
child 48 e0d6e9bd3ca7
equal deleted inserted replaced
18:e8e63152f320 21:2a9601315dfc
       
     1 #
       
     2 # Copyright (c) 2009,2010 Nokia Corporation and/or its subsidiary(-ies).
       
     3 # All rights reserved.
       
     4 # This component and the accompanying materials are made available
       
     5 # under the terms of "Eclipse Public License v1.0"
       
     6 # which accompanies this distribution, and is available
       
     7 # at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 #
       
     9 # Initial Contributors:
       
    10 # Nokia Corporation - initial contribution.
       
    11 #
       
    12 # Contributors:
       
    13 #
       
    14 # Description: 
       
    15 #
       
    16 
       
    17 
       
    18 omj {
       
    19 
       
    20   # Load project defines (if not already loaded). Fail if can not loaded.
       
    21   !include(../inc/build_defines.pri):error(Could not load build_defines.pri)
       
    22 
       
    23   # Allow JAVATARGET to be used for defining the Java project name (java artifacts)
       
    24   isEmpty(JAVATARGET): JAVATARGET = $${TARGET}
       
    25 
       
    26   !contains(TARGET, javautils): LIBS += -ljavautils
       
    27 
       
    28   # Add general project defines
       
    29   DEFINES += $${PROJECT_DEFINES}
       
    30 
       
    31   !symbian {
       
    32 
       
    33      # Check release/debug
       
    34      !debug:!release:error(Define either debug or release configuration)
       
    35 
       
    36       contains(TEMPLATE,app) {
       
    37           DESTDIR = $$(JAVA_BIN_ROOT)/bin
       
    38       } else {
       
    39           DESTDIR = $$(JAVA_BIN_ROOT)/lib
       
    40       }
       
    41       LIBS += -lpthread
       
    42       LIBS += -L$$(JAVA_BIN_ROOT)/lib -L$$(JAVA_BIN_ROOT)/jsr/lib
       
    43 
       
    44       JAVA_ARTIFACTS = $$(JAVA_BIN_ROOT)/javabuild/$${JAVATARGET}
       
    45       JAVAH_ARTIFACTS = $$(JAVA_BIN_ROOT)/javabuild/inc.javah
       
    46 
       
    47       debug {
       
    48           DEFINES += LOGGING_ON NGJAVA_LOGGER_ON
       
    49       }
       
    50   }
       
    51 
       
    52   symbian {
       
    53 
       
    54       # If core is not in QT, there is no QT. If there is no QT, there is no 
       
    55       # core/gui
       
    56       !contains(QT, core): CONFIG -= qt
       
    57       !contains(CONFIG, qt): QT -= core gui
       
    58 
       
    59       # If we are building for QT, then use simple QT (enables 
       
    60       # changes in qt configuraiton)
       
    61       contains(PROJECT_DEFINES,RD_JAVA_UI_QT): CONFIG *= qt
       
    62 
       
    63       # Set correct UID2 for DLLs
       
    64       isEmpty(TARGET.UID2): contains(TEMPLATE,lib) {
       
    65 
       
    66          # UID2 0x1000008d is KSharedLibraryUidValue from e32uid.h, 
       
    67          # but stddlls have 0x20004c45
       
    68          stdbinary: TARGET.UID2 = 0x20004c45
       
    69          else: TARGET.UID2 = 0x1000008d
       
    70       }       
       
    71 
       
    72       # Load UID3s for Symbian
       
    73       include(symbian_uids.pri)
       
    74 
       
    75       DEFINES += __SYMBIAN32__
       
    76       DEFINES += J9EPOC32 RD_JAVA_OMJ_FSERVER
       
    77 
       
    78       LIBS += -llibpthread
       
    79 
       
    80       # Include platform paths so that MMP macros work in below
       
    81       MMP_RULES += \
       
    82         "$${LITERAL_HASH}include <platform_paths.hrh>" \
       
    83 
       
    84       # Use QT defined includes only when really compiling for QT. Otherwise
       
    85       # use the S60 platform paths
       
    86       contains(QT, core) {
       
    87         INCLUDEPATH *= $$APP_LAYER_SYSTEMINCLUDE
       
    88         INCLUDEPATH *= $$OS_LAYER_LIBC_SYSTEMINCLUDE
       
    89         INCLUDEPATH *= $$OS_LAYER_SSL_SYSTEMINCLUDE
       
    90       } else {
       
    91         INCLUDEPATH -= $$APP_LAYER_SYSTEMINCLUDE \
       
    92                        $$OS_LAYER_LIBC_SYSTEMINCLUDE \
       
    93                        $$OS_LAYER_SSL_SYSTEMINCLUDE \
       
    94                        $${EPOCROOT}epoc32/include
       
    95         MMP_RULES += \
       
    96           " APP_LAYER_SYSTEMINCLUDE" \
       
    97           " OS_LAYER_LIBC_SYSTEMINCLUDE"\
       
    98           " OS_LAYER_SSL_SYSTEMINCLUDE"
       
    99       }
       
   100 
       
   101       !contains(TEMPLATE,app) {
       
   102           # DLLs have by default these capabilities
       
   103           TARGET.CAPABILITY = all -tcb
       
   104       }
       
   105 
       
   106       JAVA_ARTIFACTS = /epoc32/build/jrt/javabuild/$${JAVATARGET}
       
   107       JAVAH_ARTIFACTS = /epoc32/build/jrt/javabuild/inc.javah
       
   108 
       
   109       # Specify defblock always. Qmake revisions have diffent variants of
       
   110       # this, so we have to make sure that we define a deffile ourselves
       
   111       !contains(TEMPLATE,app): !contains(CONFIG,stdbinary) {
       
   112           MMP_RULES -= EXPORTUNFROZEN
       
   113           isEmpty(defBlock): defBlock = "deffile ./~/$${TARGET}.def"
       
   114           MMP_RULES += $${defBlock}
       
   115       }
       
   116       MMP_RULES *= "PAGED"
       
   117 
       
   118       # By default Symbian toolchain exports all classes on a DLL, unless
       
   119       # NONSHARABLE_CLASS macro is used. Qt exports only classes which
       
   120       # __declspec(dllexport), which is usually made defining
       
   121       # "MYSHAREDLIB_LIB" (see http://doc.trolltech.com/4.6/sharedlibrary.html)
       
   122       # This reverts the exporting to Symbian's convention
       
   123 
       
   124       MMP_RULES -= $$MMP_RULES_DONT_EXPORT_ALL_CLASS_IMPEDIMENTA
       
   125 
       
   126       stl {
       
   127         # If STL is configured and not full qt, add the corresponding
       
   128         # platform macro
       
   129         contains(DEFINES, RD_JAVA_STDCPPV5) {
       
   130           MMP_RULES += " SYSTEMINCLUDE OS_LAYER_PUBLIC_EXPORT_PATH(stdapis/stlportv5)"
       
   131         } else {
       
   132           MMP_RULES += " OS_LAYER_STDCPP_SYSTEMINCLUDE"
       
   133         }
       
   134       }
       
   135   }
       
   136 
       
   137   # Define generated paths
       
   138   JXE_SOURCE_PATH    = $${JAVA_ARTIFACTS}
       
   139   LOOKUP_SOURCE_PATH = $${JAVA_ARTIFACTS}
       
   140   JAVAH_INCLUDE_PATH = $${JAVAH_ARTIFACTS}
       
   141 
       
   142   # Setup local include directories
       
   143   INC_DIRS = 
       
   144 
       
   145   # Platform incs
       
   146   symbian: exists($${_PRO_FILE_PWD_}/../inc.s60): INC_DIRS += ../inc.s60
       
   147   !symbian: exists($${_PRO_FILE_PWD_}/../inc.linux): INC_DIRS += ../inc.linux
       
   148 
       
   149   # Find the project depth
       
   150   TRY_DIR=$${_PRO_FILE_PWD_}
       
   151   for(a, 1..10): {
       
   152      TRY_DIR = $$join(TRY_DIR,,,/..)
       
   153      exists($${TRY_DIR}/build/Makefile.comp) DEPTH=$${a}
       
   154   }
       
   155 
       
   156   # Make include paths
       
   157   INC_DIR = inc
       
   158   for(a, 1..$${DEPTH}) {
       
   159      INC_DIR = $$join(INC_DIR,,../,)
       
   160      exists($${_PRO_FILE_PWD_}/$${INC_DIR}): INC_DIRS += $${INC_DIR}
       
   161   }
       
   162 
       
   163   # Add javah path. 
       
   164   # Symbian: Use MMP_RULES, as the path does not exist yet there
       
   165   # Linux: Java is built before qmake, so path does exist
       
   166   !symbian: INC_DIRS += $${JAVAH_INCLUDE_PATH}
       
   167   symbian: MMP_RULES += "SYSTEMINCLUDE $${JAVAH_INCLUDE_PATH}"
       
   168 
       
   169 
       
   170   # Define function "findfiles(path, wildcard)", which will find wildcard
       
   171   # files from the path, and from one subdirectory beneath it.
       
   172   defineReplace(findfiles) {
       
   173      # Note that the "files" function is undocumented qmake
       
   174      foundfiles = $$files($${1}/$${2})
       
   175      foundall = $$files($${1}/*)
       
   176      for(d, foundall) : exists($${d}/$${2}): foundfiles += $$files($${d}/$${2})
       
   177      return($$foundfiles)   
       
   178   }
       
   179 
       
   180 
       
   181   !javaonly: isEmpty(SOURCES) {
       
   182      # Make source paths if not defined
       
   183      SOURCES += $$findfiles($${_PRO_FILE_PWD_}/../src, *.cpp)
       
   184      symbian: SOURCES += $$findfiles($${_PRO_FILE_PWD_}/../src.s60, *.cpp)
       
   185      !symbian: SOURCES += $$findfiles($${_PRO_FILE_PWD_}/../src.linux, *.cpp)
       
   186   } else {
       
   187      # Expand also explicit sources, as Qmake fails to expand if CONFIG has no qt
       
   188      EXPANDED_SOURCES=
       
   189      for(s,SOURCES) {
       
   190         EXPANDED_SOURCE = $$files($${_PRO_FILE_PWD_}/$${s})
       
   191         isEmpty(EXPANDED_SOURCE): EXPANDED_SOURCES += $${s}
       
   192         else:                     EXPANDED_SOURCES += $${EXPANDED_SOURCE}
       
   193      }
       
   194      SOURCES = $${EXPANDED_SOURCES}
       
   195   }
       
   196 
       
   197   # Find source directories
       
   198   SRCDIRS = $$dirname(SOURCES)
       
   199   SRCDIRS = $$unique(SRCDIRS)
       
   200   INC_DIRS += $${SRCDIRS}
       
   201 
       
   202   # Append and make unique
       
   203   INCLUDEPATH += $${INC_DIRS}
       
   204   INCLUDEPATH = $$unique(INCLUDEPATH)
       
   205   DEPENDPATH += $${INC_DIRS}
       
   206   DEPENDPATH =$$unique(DEPENDPATH)
       
   207 
       
   208   # Remove explicitly marked "system" libs
       
   209   LIBS -= $${REMOVELIBS}
       
   210 
       
   211   javaonly {
       
   212     symbian {
       
   213       # Setup all required for romization
       
   214       INCLUDEPATH += $$(JAVA_SRC_ROOT)/inc
       
   215     } else {
       
   216       # Nothing to be done for Linux
       
   217       TEMPLATE=subdirs
       
   218       SUBDIRS=
       
   219     }
       
   220   }
       
   221 
       
   222   java|javaonly:symbian {
       
   223      MMP_RULES += \
       
   224        "SOURCEPATH $${LOOKUP_SOURCE_PATH}" \
       
   225        "SOURCE lookup.cpp" \
       
   226        "SOURCEPATH $${JXE_SOURCE_PATH}" \
       
   227        "SOURCE jxe.c"
       
   228   }
       
   229 
       
   230   symbian:exists($${_PRO_FILE_PWD_}/exports.inf) {
       
   231     # Set exports when the file exists
       
   232     BLD_INF_RULES.prj_exports += "$${LITERAL_HASH}include \"exports.inf\""
       
   233   }
       
   234 
       
   235   staticdata|contains(PROJECT_DEFINES, RD_JAVA_EPOCALLOWDLLDATA_FIX) {
       
   236      # If project has static data, we need define following on symbian
       
   237      # targets, to ensure that accidental static data additions are caught
       
   238      # by arm linker
       
   239 
       
   240      MMP_RULES += \
       
   241          "$${LITERAL_HASH}ifdef WINSCW" \
       
   242          "LIBRARY ewsd.lib" \
       
   243          "$${LITERAL_HASH}endif"
       
   244      contains(PROJECT_DEFINES, RD_JAVA_S60_RELEASE_5_0) {
       
   245        # S60 5.0 does not allow static data on DLLs to be loaded to multiple
       
   246        # processes, therefore this must be variable between armv5 and
       
   247        # winscw. It generates qmake warning on later QTs, but don't be
       
   248        # offended.
       
   249        MMP_RULES += \
       
   250            "$${LITERAL_HASH}ifndef WINSCW" \
       
   251            "EPOCALLOWDLLDATA" \      
       
   252            "$${LITERAL_HASH}endif"
       
   253      } else {
       
   254        TARGET.EPOCALLOWDLLDATA = 1
       
   255      }
       
   256    }
       
   257 }