From d6f32a189ae436bf641323ad81bc516b45cf0906 Mon Sep 17 00:00:00 2001 From: Pete Batard Date: Sun, 20 Nov 2011 03:29:08 +0000 Subject: [PATCH] [mingw] added MinGW support * only MinGW-w64 for now * Makefile is called GNUmakefile so as not to conflict with WDK --- .gitattributes | 1 + .gitignore | 1 - GNUmakefile | 23 +++++++++++++++++++++++ rufus.c | 11 ++++++----- rufus.rc | 10 ++++++++++ 5 files changed, 40 insertions(+), 6 deletions(-) create mode 100644 GNUmakefile diff --git a/.gitattributes b/.gitattributes index f98f3971..1372ae86 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,6 +1,7 @@ *.sh eol=lf *.ac eol=lf *.am eol=lf +GNUmakefile eol=lf *.sln eol=crlf *.vcproj eol=crlf *.vcxproj* eol=crlf diff --git a/.gitignore b/.gitignore index 990d8dd4..0f7326be 100644 --- a/.gitignore +++ b/.gitignore @@ -24,7 +24,6 @@ .libs Debug INSTALL -Makefile Makefile.in Release aclocal.m4 diff --git a/GNUmakefile b/GNUmakefile new file mode 100644 index 00000000..f4ccf25c --- /dev/null +++ b/GNUmakefile @@ -0,0 +1,23 @@ +TARGETNAME=rufus + +CC = gcc +RC = windres +STRIP = strip +CFLAGS = -std=gnu99 -Wall -Wundef -Wunused -Wstrict-prototypes -Werror-implicit-function-declaration -Wno-pointer-sign -Wshadow -O2 -Wl,--subsystem,windows +LIBS = -lsetupapi -lole32 + +.PHONY: all clean + +all: $(TARGETNAME) + +$(TARGETNAME): $(TARGETNAME).c $(TARGETNAME)_rc.o + @echo "[CCLD] $@" + @$(CC) -o $@ $(CFLAGS) $^ $(TARGETNAME)_rc.o $(LIBS) + @$(STRIP) $(TARGETNAME).exe + +$(TARGETNAME)_rc.o: $(TARGETNAME).rc + @echo "[RC] $@" + @$(RC) -i $< -o $@ + +clean: + rm -f *.exe *.o diff --git a/rufus.c b/rufus.c index 33b54cbd..496a2763 100644 --- a/rufus.c +++ b/rufus.c @@ -189,6 +189,7 @@ static BOOL GetDriveInfo(DWORD num, LONGLONG* DriveSize, char* FSType, DWORD FST HANDLE hDrive; DWORD size; BYTE geometry[128]; + void* disk_geometry = (void*)geometry; char DrivePath[] = "#:\\"; *DriveSize = 0; @@ -203,7 +204,7 @@ static BOOL GetDriveInfo(DWORD num, LONGLONG* DriveSize, char* FSType, DWORD FST safe_closehandle(hDrive); return FALSE; } - *DriveSize = ((PDISK_GEOMETRY_EX)geometry)->DiskSize.QuadPart; + *DriveSize = ((PDISK_GEOMETRY_EX)(disk_geometry))->DiskSize.QuadPart; safe_closehandle(hDrive); @@ -400,7 +401,7 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA /* * Center a dialog with regards to the main application Window or the desktop */ -void CenterDialog(HWND hDialog) +void CenterDialog(HWND hDlg) { POINT Point; HWND hParent; @@ -410,10 +411,10 @@ void CenterDialog(HWND hDialog) int nHeight; // Get the size of the dialog box. - GetWindowRect(hDialog, &DialogRect); + GetWindowRect(hDlg, &DialogRect); // Get the parent - hParent = GetParent(hDialog); + hParent = GetParent(hDlg); if (hParent == NULL) { hParent = GetDesktopWindow(); } @@ -433,7 +434,7 @@ void CenterDialog(HWND hDialog) Point.y -= nHeight / 2 + 35; // Move the window. - MoveWindow(hDialog, Point.x, Point.y, nWidth, nHeight, FALSE); + MoveWindow(hDlg, Point.x, Point.y, nWidth, nHeight, FALSE); } /* diff --git a/rufus.rc b/rufus.rc index eff3d740..98a808ab 100644 --- a/rufus.rc +++ b/rufus.rc @@ -68,6 +68,11 @@ END 3 TEXTINCLUDE BEGIN "\r\n" + "// Must reference a manifest for visual styles and elevation\r\n" + "// Oh, and it must happen at the end, or MinGW will ignore it!\r\n" + "#if defined(__GNUC__)\r\n" + "CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST ""common_controls_and_elevation.manifest""\r\n" + "#endif\r\n" "\0" END @@ -148,6 +153,11 @@ IDI_ICON ICON "rufus.ico" // Generated from the TEXTINCLUDE 3 resource. // +// Must reference a manifest for visual styles and elevation +// Oh, and it must happen at the end, or MinGW will ignore it! +#if defined(__GNUC__) +CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "common_controls_and_elevation.manifest" +#endif ///////////////////////////////////////////////////////////////////////////// #endif // not APSTUDIO_INVOKED