diff options
Diffstat (limited to 'mkspecs/win32-g++')
-rw-r--r-- | mkspecs/win32-g++/qmake.conf | 97 | ||||
-rw-r--r-- | mkspecs/win32-g++/qplatformdefs.h | 96 | ||||
-rw-r--r-- | mkspecs/win32-g++/qtcrtentrypoint.cpp | 231 |
3 files changed, 424 insertions, 0 deletions
diff --git a/mkspecs/win32-g++/qmake.conf b/mkspecs/win32-g++/qmake.conf new file mode 100644 index 000000000..e56f9002d --- /dev/null +++ b/mkspecs/win32-g++/qmake.conf @@ -0,0 +1,97 @@ +# +# +# qmake configuration for win32-g++ +# +# Written for MinGW +# + +MAKEFILE_GENERATOR = MINGW +TEMPLATE = app +CONFIG += qt warn_on release link_prl +DEFINES += UNICODE + +exists( $(QTDIR)\.qtwinconfig ) { + include( $(QTDIR)\.qtwinconfig ) +} + +QMAKE_CC = gcc +QMAKE_LEX = flex +QMAKE_LEXFLAGS = +QMAKE_YACC = byacc +QMAKE_YACCFLAGS = -d +QMAKE_CFLAGS = +QMAKE_CFLAGS_DEPS = -M +QMAKE_CFLAGS_WARN_ON = -Wall +QMAKE_CFLAGS_WARN_OFF = -w +QMAKE_CFLAGS_RELEASE = -O2 +QMAKE_CFLAGS_DEBUG = -g +QMAKE_CFLAGS_YACC = -Wno-unused -Wno-parentheses +QMAKE_CFLAGS_THREAD = -mthreads +QMAKE_CFLAGS_RTTI_ON = -frtti +QMAKE_CFLAGS_RTTI_OFF = -fno-rtti +QMAKE_CFLAGS_EXCEPTIONS_ON = -fexceptions +QMAKE_CFLAGS_EXCEPTIONS_OFF = -fno-exceptions + +QMAKE_CXX = g++ +QMAKE_CXXFLAGS = $$QMAKE_CFLAGS +QMAKE_CXXFLAGS_DEPS = $$QMAKE_CFLAGS_DEPS +QMAKE_CXXFLAGS_WARN_ON = $$QMAKE_CFLAGS_WARN_ON +QMAKE_CXXFLAGS_WARN_OFF = $$QMAKE_CFLAGS_WARN_OFF +QMAKE_CXXFLAGS_RELEASE = $$QMAKE_CFLAGS_RELEASE +QMAKE_CXXFLAGS_DEBUG = $$QMAKE_CFLAGS_DEBUG +QMAKE_CXXFLAGS_YACC = $$QMAKE_CFLAGS_YACC +QMAKE_CXXFLAGS_THREAD = $$QMAKE_CFLAGS_THREAD +QMAKE_CXXFLAGS_RTTI_ON = $$QMAKE_CFLAGS_RTTI_ON +QMAKE_CXXFLAGS_RTTI_OFF = $$QMAKE_CFLAGS_RTTI_OFF +QMAKE_CXXFLAGS_EXCEPTIONS_ON = $$QMAKE_CFLAGS_EXCEPTIONS_ON +QMAKE_CXXFLAGS_EXCEPTIONS_OFF = $$QMAKE_CFLAGS_EXCEPTIONS_OFF + +QMAKE_INCDIR = +QMAKE_INCDIR_QT = $(QTDIR)\include +QMAKE_LIBDIR_QT = $(QTDIR)\lib + +QMAKE_RUN_CC = $(CC) -c $(CFLAGS) $(INCPATH) -o $obj $src +QMAKE_RUN_CC_IMP = $(CC) -c $(CFLAGS) $(INCPATH) -o $@ $< +QMAKE_RUN_CXX = $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $obj $src +QMAKE_RUN_CXX_IMP = $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< + +QMAKE_LINK = g++ +QMAKE_LFLAGS = -Wl,-enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc +QMAKE_LFLAGS_RELEASE = -Wl,-s +QMAKE_LFLAGS_DEBUG = +QMAKE_LFLAGS_THREAD = -mthreads +QMAKE_LFLAGS_CONSOLE = -Wl,-subsystem,console +QMAKE_LFLAGS_WINDOWS = -Wl,-subsystem,windows -e __Z19TQtWinMainCRTStartupv +QMAKE_LFLAGS_CONSOLE_DLL= -Wl,-subsystem,console -shared -Wl,--export-all-symbols +QMAKE_LFLAGS_WINDOWS_DLL= -Wl,-subsystem,windows -shared -Wl,--export-all-symbols +QMAKE_LINK_OBJECT_MAX = 10 +QMAKE_LINK_OBJECT_SCRIPT= object_ld_script +QMAKE_LINK_OBJMOC_SCRIPT= objmoc_ld_script + +QMAKE_LIBS = +QMAKE_LIBS_CONSOLE = +QMAKE_LIBS_WINDOWS = -lkernel32 -luser32 -lgdi32 -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -luuid -limm32 -lwinmm -lwsock32 -lwinspool +QMAKE_LIBS_QT = -lqt +QMAKE_LIBS_QT_THREAD = -ltqt-mt +QMAKE_LIBS_QT_ENTRY = -lqtmain + +QMAKE_LIBS_OPENGL = -lopengl32 -lglu32 + +QMAKE_MOC = $(QTDIR)\bin\moc.exe +QMAKE_UIC = $(QTDIR)\bin\uic.exe +QMAKE_IDC = $(QTDIR)\bin\idc.exe + +QMAKE_IDL = midl +QMAKE_LIB = ar -ru +QMAKE_RC = windres + +QMAKE_ZIP = zip -r -9 + +QMAKE_COPY = copy +QMAKE_MOVE = move +QMAKE_DEL_FILE = del +QMAKE_DEL_DIR = rmdir +QMAKE_STRIP = strip +QMAKE_STRIPFLAGS_LIB += --strip-unneeded +QMAKE_CHK_DIR_EXISTS = if not exist +QMAKE_MKDIR = mkdir diff --git a/mkspecs/win32-g++/qplatformdefs.h b/mkspecs/win32-g++/qplatformdefs.h new file mode 100644 index 000000000..289c4ba37 --- /dev/null +++ b/mkspecs/win32-g++/qplatformdefs.h @@ -0,0 +1,96 @@ +#ifndef TQPLATFORMDEFS_H +#define TQPLATFORMDEFS_H + +#ifdef UNICODE +#ifndef _UNICODE +#define _UNICODE +#endif +#endif + +// Get TQt defines/settings + +#include "qglobal.h" + +#include <tchar.h> +#include <io.h> +#include <direct.h> +#include <stdio.h> +#include <fcntl.h> +#include <errno.h> +#include <sys/stat.h> +#include <stdlib.h> +#include <windows.h> + +#if !defined(_WIN32_WINNT) || (_WIN32_WINNT-0 < 0x0500) +typedef enum { + NameUnknown = 0, + NameFullyQualifiedDN = 1, + NameSamCompatible = 2, + NameDisplay = 3, + NameUniqueId = 6, + NameCanonical = 7, + NameUserPrincipal = 8, + NameCanonicalEx = 9, + NameServicePrincipal = 10, + NameDnsDomain = 12 +} EXTENDED_NAME_FORMAT, *PEXTENDED_NAME_FORMAT; +#endif + +#define Q_FS_FAT +#ifdef QT_LARGEFILE_SUPPORT +#define QT_STATBUF struct _stati64 // non-ANSI defs +#define QT_STATBUF4TSTAT struct _stati64 // non-ANSI defs +#define QT_STAT ::_stati64 +#define QT_FSTAT ::_fstati64 +#else +#define QT_STATBUF struct _stat // non-ANSI defs +#define QT_STATBUF4TSTAT struct _stat // non-ANSI defs +#define QT_STAT ::_stat +#define QT_FSTAT ::_fstat +#endif +#define QT_STAT_REG _S_IFREG +#define QT_STAT_DIR _S_IFDIR +#define QT_STAT_MASK _S_IFMT +#if defined(_S_IFLNK) +# define QT_STAT_LNK _S_IFLNK +#endif +#define QT_FILENO _fileno +#define QT_OPEN ::_open +#define QT_CLOSE ::_close +#ifdef QT_LARGEFILE_SUPPORT +#define QT_LSEEK ::_lseeki64 +#define QT_TSTAT ::_tstati64 +#else +#define QT_LSEEK ::_lseek +#define QT_TSTAT ::_tstat +#endif +#define QT_READ ::_read +#define QT_WRITE ::_write +#define QT_ACCESS ::_access +#define QT_GETCWD ::_getcwd +#define QT_CHDIR ::_chdir +#define QT_MKDIR ::_mkdir +#define QT_RMDIR ::_rmdir +#define QT_OPEN_RDONLY _O_RDONLY +#define QT_OPEN_WRONLY _O_WRONLY +#define QT_OPEN_RDWR _O_RDWR +#define QT_OPEN_CREAT _O_CREAT +#define QT_OPEN_TRUNC _O_TRUNC +#define QT_OPEN_APPEND _O_APPEND +#if defined(O_TEXT) +# define QT_OPEN_TEXT _O_TEXT +# define QT_OPEN_BINARY _O_BINARY +#endif + +#define QT_SIGNAL_ARGS int + +#define QT_VSNPRINTF ::_vsnprintf +#define QT_SNPRINTF ::_snprintf + +# define F_OK 0 +# define X_OK 1 +# define W_OK 2 +# define R_OK 4 + + +#endif // TQPLATFORMDEFS_H diff --git a/mkspecs/win32-g++/qtcrtentrypoint.cpp b/mkspecs/win32-g++/qtcrtentrypoint.cpp new file mode 100644 index 000000000..3d047e8a7 --- /dev/null +++ b/mkspecs/win32-g++/qtcrtentrypoint.cpp @@ -0,0 +1,231 @@ + +//This code is need to get the WinMain function called. Current MinGW runtimes tries to call main +//before WinMain. Untill such time as MinGw runtime has been changed this is need. +//Most of this code is taken from the MinGw runtime sources. + + +#include <signal.h> +#include <process.h> +#include <float.h> +#include <io.h> + + +/* + * Setup the default file handles to have the _CRT_fmode mode, as well as + * any new files created by the user. + */ + +extern int _fmode; +extern "C" int* __p__fmode(void); /* To access the dll _fmode */ +extern int _CRT_fmode; + +static void _mingw32_init_fmode () +{ + /* Don't set the std file mode if the user hasn't set any value for it. */ + if (_CRT_fmode) + { + _fmode = _CRT_fmode; + + /* + * This overrides the default file mode settings for stdin, + * stdout and stderr. At first I thought you would have to + * test with isatty, but it seems that the DOS console at + * least is smart enough to handle _O_BINARY stdout and + * still display correctly. + */ + if (stdin) + { + _setmode (_fileno (stdin), _CRT_fmode); + } + if (stdout) + { + _setmode (_fileno (stdout), _CRT_fmode); + } + if (stderr) + { + _setmode (_fileno (stderr), _CRT_fmode); + } + } + + /* Now sync the dll _fmode to the one for this .exe. */ + *__p__fmode() = _fmode; + +} + +/* This function will be called when a trap occurs. Thanks to Jacob + Navia for his contribution. */ +static CALLBACK long _gnu_exception_handler (EXCEPTION_POINTERS * exception_data) +{ + void (*old_handler) (int); + long action = EXCEPTION_CONTINUE_SEARCH; + int reset_fpu = 0; + + switch (exception_data->ExceptionRecord->ExceptionCode) + { + case EXCEPTION_ACCESS_VIOLATION: + /* test if the user has set SIGSEGV */ + old_handler = signal (SIGSEGV, SIG_DFL); + if (old_handler == SIG_IGN) + { + /* this is undefined if the signal was raised by anything other + than raise (). */ + signal (SIGSEGV, SIG_IGN); + action = EXCEPTION_CONTINUE_EXECUTION; + } + else if (old_handler != SIG_DFL) + { + /* This means 'old' is a user defined function. Call it */ + (*old_handler) (SIGSEGV); + action = EXCEPTION_CONTINUE_EXECUTION; + } + break; + + case EXCEPTION_FLT_INVALID_OPERATION: + case EXCEPTION_FLT_DIVIDE_BY_ZERO: + case EXCEPTION_FLT_DENORMAL_OPERAND: + case EXCEPTION_FLT_OVERFLOW: + case EXCEPTION_FLT_UNDERFLOW: + case EXCEPTION_FLT_INEXACT_RESULT: + reset_fpu = 1; + /* fall through. */ + + case EXCEPTION_INT_DIVIDE_BY_ZERO: + /* test if the user has set SIGFPE */ + old_handler = signal (SIGFPE, SIG_DFL); + if (old_handler == SIG_IGN) + { + signal (SIGFPE, SIG_IGN); + if (reset_fpu) + _fpreset (); + action = EXCEPTION_CONTINUE_EXECUTION; + } + else if (old_handler != SIG_DFL) + { + /* This means 'old' is a user defined function. Call it */ + (*old_handler) (SIGFPE); + action = EXCEPTION_CONTINUE_EXECUTION; + } + break; + + default: + break; + } + return action; +} + + +extern char __RUNTIME_PSEUDO_RELOC_LIST__; +extern char __RUNTIME_PSEUDO_RELOC_LIST_END__; +extern char _image_base__; + +typedef struct { + DWORD addend; + DWORD target; +} runtime_pseudo_reloc; + +static void do_pseudo_reloc (void* start, void* end, void* base) +{ + DWORD reloc_target; + runtime_pseudo_reloc* r; + for (r = (runtime_pseudo_reloc*) start; r < (runtime_pseudo_reloc*) end; r++) { + reloc_target = (DWORD) base + r->target; + *((DWORD*) reloc_target) += r->addend; + } +} + +void _pei386_runtime_relocator () +{ + do_pseudo_reloc (&__RUNTIME_PSEUDO_RELOC_LIST__, + &__RUNTIME_PSEUDO_RELOC_LIST_END__, + &_image_base__); +} + + +#ifdef __MSVCRT__ +#define __UNKNOWN_APP 0 +#define __CONSOLE_APP 1 +#define __GUI_APP 2 +extern "C" void __set_app_type(int); +#endif /* __MSVCRT__ */ + +#define ISSPACE(a) (a == ' ' || a == '\t') + +int TQtWinMainCRTStartup() +{ +#ifdef __MSVCRT__ + __set_app_type (__GUI_APP); +#endif + + SetUnhandledExceptionFilter (_gnu_exception_handler); + + /* + * Initialize floating point unit. + */ + _fpreset (); /* Supplied by the runtime library. */ + + /* + * Sets the default file mode. + * If _CRT_fmode is set, also set mode for stdin, stdout + * and stderr, as well + * NOTE: DLLs don't do this because that would be rude! + */ + _mingw32_init_fmode (); + + /* Adust references to dllimported data that have non-zero offsets. */ + _pei386_runtime_relocator (); + + char *szCmd; + STARTUPINFO startinfo; + int nRet; + + /* Get the command line passed to the process. */ + szCmd = GetCommandLineA (); + GetStartupInfo (&startinfo); + + /* Strip off the name of the application and any leading + * whitespace. */ + if (szCmd) { + + while (ISSPACE (*szCmd)) { + szCmd++; + } + + /* On my system I always get the app name enclosed + * in quotes... */ + if (*szCmd == '\"') { + do { + szCmd++; + } while (*szCmd != '\"' && *szCmd != '\0'); + + if (*szCmd == '\"') { + szCmd++; + } + } else { + /* If no quotes then assume first token is program + * name. */ + while (!ISSPACE (*szCmd) && *szCmd != '\0') { + szCmd++; + } + } + + while (ISSPACE (*szCmd)) { + szCmd++; + } + } + + nRet = WinMain (GetModuleHandle (NULL), NULL, szCmd, + (startinfo.dwFlags & STARTF_USESHOWWINDOW) ? + startinfo.wShowWindow : SW_SHOWDEFAULT); + + /* + * Perform exit processing for the C library. This means + * flushing output and calling 'atexit' registered functions. + */ + _cexit (); + + ExitProcess (nRet); + + return 0; + +} + |