Mercurial > mxe-octave
diff src/qt.mk @ 3129:d24828818d36
[MSVC] enable Qt compilation
- patch qmake to support DLL prefix/suffix
- patch qmake for proper .pc files generation
- enable .pc files generation for MSVC in .pro files
author | Michael Goffioul <michael.goffioul@gmail.com> |
---|---|
date | Thu, 11 Jul 2013 23:48:28 -0400 |
parents | 23e3e2955cf5 |
children | fae248a5b181 |
line wrap: on
line diff
--- a/src/qt.mk Thu Jul 11 23:47:33 2013 -0400 +++ b/src/qt.mk Thu Jul 11 23:48:28 2013 -0400 @@ -7,43 +7,74 @@ $(PKG)_SUBDIR := $(PKG)-everywhere-opensource-src-$($(PKG)_VERSION) $(PKG)_FILE := $(PKG)-everywhere-opensource-src-$($(PKG)_VERSION).tar.gz $(PKG)_URL := http://releases.qt-project.org/qt4/source/$($(PKG)_FILE) +$(PKG)_DEPS := openssl zlib libpng jpeg libmng tiff dbus -ifeq ($(MXE_SYSTEM),mingw) +$(PKG)_CONFIGURE_CMD := +$(PKG)_CONFIGURE_CROSS_COMPILE_OPTION := +$(PKG)_CONFIGURE_DATABASE_OPTION := +$(PKG)_CONFIGURE_ENV := +$(PKG)_CONFIGURE_EXTRA_OPTION := +$(PKG)_CONFIGURE_INCLUDE_OPTION := +$(PKG)_CONFIGURE_LIBPATH_OPTION := +$(PKG)_CONFIGURE_PLATFORM_OPTION := +$(PKG)_PREFIX := '$(HOST_PREFIX)' +$(PKG)_MKSPECS := '$($(PKG)_PREFIX)' + +ifneq ($(filter mingw msvc,$(MXE_SYSTEM)),) ifeq ($(MXE_NATIVE_BUILD),yes) - $(PKG)_DEPS := openssl zlib libpng jpeg libmng tiff dbus - $(PKG)_CONFIGURE_ENV := \ - OPENSSL_LIBS="`'$(MXE_PKG_CONFIG)' --libs-only-l openssl`" \ - QTDIR='$(HOST_PREFIX)' + PKG_CONFIG_PATH='$(HOST_PREFIX)/lib/pkgconfig' + ifeq ($(MXE_SYSTEM),msvc) + # NMAKE is perturbed by the values of MAKE and MAKEFLAGS defined by GNU + # make. These need to be unset even when running configure script, as + # this will run NMAKE to compile QMAKE. + $(PKG)_CONFIGURE_ENV += MAKE= MAKEFLAGS= + endif else - $(PKG)_DEPS := openssl zlib libpng jpeg libmng tiff dbus - $(PKG)_CONFIGURE_ENV := \ OPENSSL_LIBS="`'$(MXE_PKG_CONFIG)' --libs-only-l openssl`" \ PSQL_LIBS="-lpq -lsecur32 `'$(MXE_PKG_CONFIG)' --libs-only-l openssl` -lws2_32" \ SYBASE_LIBS="-lsybdb `'$(MXE_PKG_CONFIG)' --libs-only-l gnutls` -liconv -lws2_32" - endif - + # compile-in generic ODBC driver under Windows + $(PKG)_CONFIGURE_DATABASE_OPTION += -plugin-sql-odbc else - $(PKG)_DEPS := openssl zlib libpng jpeg libmng tiff dbus - $(PKG)_CONFIGURE_ENV := \ CPPFLAGS='$(HOST_INCDIR)/dbus-1.0' \ LDFLAGS='-Wl,-rpath-link,$(HOST_LIBDIR) -L$(HOST_LIBDIR)' endif ifeq ($(MXE_NATIVE_BUILD),yes) - $(PKG)_CONFIGURE_INCLUDE_OPTION := -I '$(HOST_INCDIR)' - $(PKG)_CONFIGURE_LIBPATH_OPTION := -L '$(HOST_LIBDIR)' + $(PKG)_CONFIGURE_INCLUDE_OPTION += -I '$(HOST_INCDIR)' + $(PKG)_CONFIGURE_LIBPATH_OPTION += -L '$(HOST_LIBDIR)' endif ifeq ($(MXE_NATIVE_MINGW_BUILD),yes) $(PKG)_CONFIGURE_CMD := configure.exe - $(PKG)_CONFIGURE_DATABASE_OPTION := - $(PKG)_CONFIGURE_PLATFORM_OPTION := -platform win32-g++ - $(PKG)_CONFIGURE_EXTRA_OPTION := + ifeq ($(MXE_SYSTEM),msvc) + # FIXME: the "2010" suffix should be computed dynamically + $(PKG)_CONFIGURE_PLATFORM_OPTION := -platform win32-msvc2010 + # mimic typical Linux installation + $(PKG)_CONFIGURE_EXTRA_OPTION += \ + -docdir '$(HOST_LIBDIR)/qt4/doc' \ + -plugindir '$(HOST_LIBDIR)/qt4/plugins' \ + -importdir '$(HOST_LIBDIR)/qt4/imports' \ + -datadir '$(HOST_LIBDIR)/qt4' \ + -translationdir '$(HOST_LIBDIR)/qt4/translations' \ + -examplesdir '$(HOST_LIBDIR)/qt4/examples' \ + -demosdir '$(HOST_LIBDIR)/qt4/demos' + $(PKG)_MKSPECS := '$(HOST_LIBDIR)/qt4' + else + $(PKG)_CONFIGURE_PLATFORM_OPTION := -platform win32-g++ + endif + # OPENSSL_LIBS needs to be specified here, specifying it as environment + # variables *before* "configure.exe" doesn't work. Also compile-in D-BUS + # support, for what it's worth... + $(PKG)_CONFIGURE_EXTRA_OPTION += \ + -openssl-linked \ + OPENSSL_LIBS="`PKG_CONFIG_PATH='$(HOST_PREFIX)/lib/pkgconfig' '$(MXE_PKG_CONFIG)' --libs-only-l openssl`" \ + -dbus-linked else $(PKG)_CONFIGURE_CMD := configure $(PKG)_CONFIGURE_EXTRA_OPTION := \ @@ -77,7 +108,7 @@ define $(PKG)_BUILD ## syncqt needs QTDIR set to find the sources cd '$(1)' && QTDIR='$(1)' ./bin/syncqt - cd '$(1)' && \ + cd '$(1)' && QTDIR='$(1)' \ $($(PKG)_CONFIGURE_ENV) \ ./$($(PKG)_CONFIGURE_CMD) \ $($(PKG)_CONFIGURE_INCLUDE_OPTION) \ @@ -91,7 +122,7 @@ -release \ -exceptions \ -shared \ - -prefix '$(HOST_PREFIX)' \ + -prefix $($(PKG)_PREFIX) \ -script \ -no-iconv \ -opengl desktop \ @@ -110,45 +141,66 @@ -system-libmng \ -no-sse2 + if test x$(MXE_SYSTEM) = xmsvc; then \ + for f in $(1)/mkspecs/win32-msvc*/qmake.conf; do \ + sed -i -e 's/@@LIBRARY_PREFIX@@/$(LIBRARY_PREFIX)/g' \ + -e 's/@@LIBRARY_SUFFIX@@/$(LIBRARY_SUFFIX)/g' $$f; \ + done; \ + fi + # need to 'install' mkspecs for the native mingw to build during its build if [ "$(MXE_NATIVE_MINGW_BUILD)" = yes ]; then \ - cp -r '$(1)/mkspecs' '$(HOST_PREFIX)/'; \ + mkdir -p '$($(PKG)_MKSPECS)'; \ + cp -r '$(1)/mkspecs' '$($(PKG)_MKSPECS)'; \ fi - $(MAKE) -C '$(1)' -j '$(JOBS)' - $(MAKE) -C '$(1)' -j 1 install + # compilation under MSVC requires the use of NMAKE, which does not + # support the -j option flag and is perturbed by GNU make values for + # MAKE and MAKEFLAGS; also remove unnecessary DLL installed in lib/ + if test x$(MXE_SYSTEM) = xmsvc; then \ + cd '$(1)' && \ + env -u MAKE -u MAKEFLAGS PKG_CONFIG_PATH='$(HOST_PREFIX)/lib/pkgconfig' nmake && \ + env -u MAKE -u MAKEFLAGS PKG_CONFIG_PATH='$(HOST_PREFIX)/lib/pkgconfig' nmake install && \ + rm -f $(HOST_PREFIX)/lib/$(LIBRARY_PREFIX)Qt*.dll; \ + else \ + make -C '$(1)' -j '$(JOBS)' && \ + make -C '$(1)' -j 1 install; \ + fi # native build doesnt seem to succeed with installing pkgconfig files to prefix # in addition, .pc files have the wrong paths, mangled lib names - if [ "$(MXE_NATIVE_MINGW_BUILD)" = yes ]; then \ + if [ "$(MXE_NATIVE_MINGW_BUILD)" = yes -a "$(MXE_SYSTEM)" != msvc ]; then \ find $(1)/lib/pkgconfig/*.pc -exec $(SED) -i \ - -e 's,\(.*\)_location=.*,\1_location=$(HOST_BINDIR)/\1,g' \ + -e 's,\(.*\)_location=.*,\1_location=$${prefix}/bin/\1,g' \ -e 's,\(Libs:.* -l\).*[\\/]\([A-Za-z0-9]*\),\1\2,g' \ '{}' ';' ; \ cp -f '$(1)/lib/pkgconfig/'*.pc '$(HOST_LIBDIR)/pkgconfig/'; \ fi - $(LN_SF) '$(HOST_BINDIR)/moc' '$(BUILD_TOOLS_PREFIX)/bin/$(MXE_TOOL_PREFIX)moc' - $(LN_SF) '$(HOST_BINDIR)/rcc' '$(BUILD_TOOLS_PREFIX)/bin/$(MXE_TOOL_PREFIX)rcc' - $(LN_SF) '$(HOST_BINDIR)/uic' '$(BUILD_TOOLS_PREFIX)/bin/$(MXE_TOOL_PREFIX)uic' - $(LN_SF) '$(HOST_BINDIR)/qmake' '$(BUILD_TOOLS_PREFIX)/bin/$(MXE_TOOL_PREFIX)qmake' + # using if-function, this allows to keep the code structure untouched, + # including the comments, however one must make sure there is no comma + $(if $(filter-out msvc,$(MXE_SYSTEM)), + $(LN_SF) '$($(PKG)_PREFIX)/bin/moc' '$(BUILD_TOOLS_PREFIX)/bin/$(MXE_TOOL_PREFIX)moc' + $(LN_SF) '$($(PKG)_PREFIX)/bin/rcc' '$(BUILD_TOOLS_PREFIX)/bin/$(MXE_TOOL_PREFIX)rcc' + $(LN_SF) '$($(PKG)_PREFIX)/bin/uic' '$(BUILD_TOOLS_PREFIX)/bin/$(MXE_TOOL_PREFIX)uic' + $(LN_SF) '$($(PKG)_PREFIX)/bin/qmake' '$(BUILD_TOOLS_PREFIX)/bin/$(MXE_TOOL_PREFIX)qmake' - # cd '$(1)/tools/assistant' && '$(1)/bin/qmake' assistant.pro - # $(MAKE) -C '$(1)/tools/assistant' -j '$(JOBS)' install + # cd '$(1)/tools/assistant' && '$(1)/bin/qmake' assistant.pro + # $(MAKE) -C '$(1)/tools/assistant' -j '$(JOBS)' install - # cd '$(1)/tools/designer' && '$(1)/bin/qmake' designer.pro - # $(MAKE) -C '$(1)/tools/designer' -j '$(JOBS)' install + # cd '$(1)/tools/designer' && '$(1)/bin/qmake' designer.pro + # $(MAKE) -C '$(1)/tools/designer' -j '$(JOBS)' install - # # at least some of the qdbus tools are useful on target - # cd '$(1)/tools/qdbus' && '$(1)/bin/qmake' qdbus.pro - # $(MAKE) -C '$(1)/tools/qdbus' -j '$(JOBS)' install + # # at least some of the qdbus tools are useful on target + # cd '$(1)/tools/qdbus' && '$(1)/bin/qmake' qdbus.pro + # $(MAKE) -C '$(1)/tools/qdbus' -j '$(JOBS)' install - # lrelease (from linguist) needed by octave for GUI build - $(MAKE) -C '$(1)/tools/linguist/lrelease' -j '$(JOBS)' install - $(LN_SF) '$(HOST_BINDIR)/lrelease' '$(BUILD_TOOLS_PREFIX)/bin/$(MXE_TOOL_PREFIX)lrelease' + # lrelease (from linguist) needed by octave for GUI build + $(MAKE) -C '$(1)/tools/linguist/lrelease' -j '$(JOBS)' install + $(LN_SF) '$($(PKG)_PREFIX)/bin/lrelease' '$(BUILD_TOOLS_PREFIX)/bin/$(MXE_TOOL_PREFIX)lrelease' - # mkdir '$(1)/test-qt' - # cd '$(1)/test-qt' && '$(MXE_QMAKE)' '$(PWD)/$(2).pro' - # $(MAKE) -C '$(1)/test-qt' -j '$(JOBS)' - # $(INSTALL) -m755 '$(1)/test-qt/release/test-qt.exe' '$(HOST_BINDIR)' + # mkdir '$(1)/test-qt' + # cd '$(1)/test-qt' && '$(MXE_QMAKE)' '$(PWD)/$(2).pro' + # $(MAKE) -C '$(1)/test-qt' -j '$(JOBS)' + # $(INSTALL) -m755 '$(1)/test-qt/release/test-qt.exe' '$(HOST_BINDIR)') endef