CC=gcc
DIET=diet -Os gcc -m32 -L/usr/lib/gcc/i686-linux-gnu/8
CROSS_CC=i686-w64-mingw32-gcc
CFLAGS=-Wall -Wdeclaration-after-statement -Wpointer-arith -Wredundant-decls -Wcast-qual -Wwrite-strings -g -Os
# is supposedly the default, but obviously not on MinGW-w64
CFLAGS+=-Qn
CFLAGS+=-fomit-frame-pointer
CFLAGS+=-std=c99 -D_XOPEN_SOURCE=500
LDFLAGS=-lm
VERSION=3.3
GUI_VERSION=0.33
all: xwahacker.unsigned.exe xwareplacer.unsigned.exe xwahacker.static xwareplacer.static
%: %.c
$(CC) $(CFLAGS) $^ $(LDFLAGS) -o $@
%.static: %.c
$(DIET) -DNDEBUG $(CFLAGS) $^ $(LDFLAGS) -s -o $@
# Simpler, safer but larger code build command:
#$(CROSS_CC) -static $(CFLAGS) -Wl,--nxcompat -Wl,--no-seh -Wl,--dynamicbase $^ $(LDFLAGS) -o $@
%.unsigned.exe: %.c
$(CROSS_CC) $(CFLAGS) -Wl,--nxcompat -Wl,--no-seh -Wl,--dynamicbase -DNDEBUG -U_XOPEN_SOURCE -D__NO_ISOCEXT -nostdlib maincrtstartup.c $^ -lmsvcrt -lkernel32 -o $@
xwahacker-qt.unsigned.exe: gui/release/xwahacker-qt.exe
cp $< $@
%.exe: %.unsigned.exe
strip $^
if [ -n "$(SIGNKEY)" ] ; then osslsigncode sign -ts http://sha256timestamp.ws.symantec.com/sha256/timestamp -certs $(SIGNKEY).crt -key $(SIGNKEY).key -h sha256 $(SIGNOPTS) -in $^ -out $@ ; chmod +x $@ ; else cp $^ $@ ; fi
%.asc: %
gpg -a -b $^
release: xwahacker-${VERSION}.zip xwahacker-gui-${GUI_VERSION}-win.zip
xwahacker-gui-${GUI_VERSION}-win.zip: xwahacker-qt.exe LICENSE
7z a -mx=9 $@ $^
xwahacker-${VERSION}.zip: *.bat *.reg xwahacker.exe xwareplacer.exe xwahacker.static xwareplacer.static readme.txt readme-linux.txt readme-xwareplacer.txt LICENSE xwahacker.c xwahacker.h xwareplacer.c
7z a -mx=9 $@ $^
upload: xwahacker-${VERSION}.zip xwahacker-${VERSION}.zip.asc readme.txt
scp $^ $(SFUSER),xwahacker@frs.sourceforge.net:/home/frs/project/x/xw/xwahacker
gui_upload: xwahacker-gui-${GUI_VERSION}-win.zip
scp $^ $(SFUSER),xwahacker@frs.sourceforge.net:/home/frs/project/x/xw/xwahacker
clean:
rm -rf xwahacker xwahacker.exe xwahacker.unsigned.exe xwahacker.static xwahacker*.zip xwahacker*.zip.asc xwareplacer xwareplacer.unsigned.exe xwareplacer.exe xwareplacer.static xwahacker-qt.unsigned.exe xwahacker-qt.exe
.PHONY: appx xwahacker-x64.appx xwahacker-x86.appx xwahacker-armv7.appx xwahacker-arm64.appx
appx: xwahacker-x64.appx xwahacker-x86.appx xwahacker-armv7.appx xwahacker-arm64.appx
# Need to fix up the PhoneProductId and remove pointless internetClient capability
MANIFEST_SED=-e 's/PhoneProductId="33893ReimarDffinger.XWAHackerGUI"/PhoneProductId="1C4B560A-04CC-42BC-A0DD-C869CE73A919"/' -e '/Capability Name="internetClient"/d'
xwahacker-x64.appx:
cd build-xwahacker-qt-*_for_UWP_64bit_*-Release/release && sed -i $(MANIFEST_SED) AppxManifest.xml && makeappx.exe pack /f ../../gui/appx-filelist.txt /o /p ../../$@
xwahacker-x86.appx:
cd build-xwahacker-qt-*_for_UWP_32bit_*-Release/release && sed -i $(MANIFEST_SED) AppxManifest.xml && makeappx.exe pack /f ../../gui/appx-filelist.txt /o /p ../../$@
xwahacker-armv7.appx:
cd build-xwahacker-qt-*_for_UWP_ARMv7_*-Release/release && sed -i $(MANIFEST_SED) AppxManifest.xml && makeappx.exe pack /f ../../gui/appx-filelist.txt /o /p ../../$@
xwahacker-arm64.appx:
cd build-xwahacker-qt-*_for_UWP_ARM64*-Release/release && sed -i $(MANIFEST_SED) AppxManifest.xml && makeappx.exe pack /f ../../gui/appx-filelist.txt /o /p ../../$@
# As it's not possible to have the same PublisherID for the store and my own key...
patchkeyid:
for i in build*/release/AppxManifest.xml; do sed -i 's/CN=7FA184CD-E614-4630-8C10-9BC1E1A38DD7/E=Reimar.Doeffinger@gmx.de, CN=\"Open Source Developer, Reimar D\öffinger\", O=Open Source Developer, L=Lund, C=SE/' $$i; done
patchstoreid:
for i in build*/release/AppxManifest.xml; do sed -i 's/E=Reimar.Doeffinger@gmx.de, CN="Open Source Developer, Reimar Döffinger", O=Open Source Developer, L=Lund, C=SE/CN=7FA184CD-E614-4630-8C10-9BC1E1A38DD7/' $$i; done
.PHONY: appxsign
appxsign:
for i in xwahacker-*.appx; do signtool.exe sign /a /fd SHA256 /tr http://time.certum.pl /td SHA256 $$i ; done
.PHONY: all clean release upload