Skip to content
This repository has been archived by the owner on Nov 28, 2022. It is now read-only.

Commit

Permalink
Added mingw-w64 makefile and smaller exes
Browse files Browse the repository at this point in the history
  • Loading branch information
vs49688 committed Mar 4, 2019
1 parent 049c2d2 commit 8962048
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 1 deletion.
38 changes: 38 additions & 0 deletions Makefile.mingw-w64
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# In case CMake's being a shit
CC=i686-w64-mingw32-gcc
STRIP=i686-w64-mingw32-strip
WINDRES=i686-w64-mingw32-windres

LAUNCHER_FLAGS=-static -DNDEBUG -Os -mwindows --entry _WinMain@16 -nostdlib -lkernel32 -luser32

all: lotrbfme.exe lotrbfme2.exe lotrbfme2ep1.exe fixinst.exe

lotrbfme-res.o: ../lotrbfme.rc ../lotrbfme.ico
${WINDRES} $< -O coff $@

lotrbfme2-res.o: ../lotrbfme2.rc ../lotrbfme2.ico
${WINDRES} $< -O coff $@

lotrbfme2ep1-res.o: ../lotrbfme2ep1.rc ../lotrbfme2ep1.ico
${WINDRES} $< -O coff $@

lotrbfme.exe: ../launcher.c ../launcher.h lotrbfme-res.o
${CC} -o $@ -DLOTRBFME_GAME=1 $^ ${LAUNCHER_FLAGS}
${STRIP} -s $@

lotrbfme2.exe: ../launcher.c ../launcher.h lotrbfme2-res.o
${CC} -o $@ -DLOTRBFME_GAME=2 $^ ${LAUNCHER_FLAGS}
${STRIP} -s $@

lotrbfme2ep1.exe: ../launcher.c ../launcher.h lotrbfme2ep1-res.o
${CC} -o $@ -DLOTRBFME_GAME=3 $^ ${LAUNCHER_FLAGS}
${STRIP} -s $@

fixinst.exe: ../fixinst.c ../launcher.h
${CC} -o $@ $^ -Os -mconsole -lshlwapi
${STRIP} -s $@

clean:
rm -f lotrbfme.exe lotrbfme2.exe lotrbfme2ep1.exe lotrbfme-res.o lotrbfme2-res.o lotrbfme2ep1-res.o fixinst.exe

.PHONY: all clean
Binary file modified fixinst.exe
Binary file not shown.
11 changes: 10 additions & 1 deletion launcher.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,15 @@ static void show_error_box(LPCWSTR msg)
MessageBoxW(NULL, msg, LOTRBFME_SKUNAME, MB_OK | MB_ICONERROR);
}

static LPWSTR lstrrchrW(LPCWSTR s, WCHAR c)
{
LPCWSTR p;
for(p = s + lstrlenW(s); p >= s && *p != c; p--)
;

return p >= s ? (LPWSTR)p : 0;
}

static LPWSTR get_executable_directory()
{
HMODULE hThis = GetModuleHandleW(NULL);
Expand All @@ -59,7 +68,7 @@ static LPWSTR get_executable_directory()
p = np;
}

LPWSTR end = wcsrchr(p, '\\');
LPWSTR end = lstrrchrW(p, '\\');
if(end)
*end = L'\0';

Expand Down
Binary file modified lotrbfme.exe
Binary file not shown.
Binary file modified lotrbfme2.exe
Binary file not shown.
Binary file modified lotrbfme2ep1.exe
Binary file not shown.

0 comments on commit 8962048

Please # to comment.