# # Raw Game Engine # Copyright (C) 2023 Ernest Deak # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # PROJECT=rge AS = nasm ASFLAGS = -felf64 -g -Wall -D RG_ANIM_SPRITE_OFFSET=0 ASFLAGS_WIN = -fwin64 -DWIN64 -g -Wall -D RG_ANIM_SPRITE_OFFSET=0 LIBS = -lSDL2 -lSDL2_image -lSDL2_ttf BUILDDIR = ./build AOBJ = $(addprefix ${BUILDDIR}/, img_subsys.o ttf_subsys.o rge.o dummy.o) DISTDIR = dist/${PROJECT}_linux/ W64_DISTDIR = dist/${PROJECT}_win64/ W64_SDL2 = ../w64-SDL2/x86_64-w64-mingw32/bin/ W64_SDL2_Image = ../SDL2_image-2.6.3/x86_64-w64-mingw32/bin/ W64_SDL2_TTF = ../SDL2_ttf-2.20.2/x86_64-w64-mingw32/bin/ CFLAGS = -pie all: prep ${AOBJ} src/base.c gcc ${LIBS} ${CFLAGS} -O3 ${BUILDDIR}/*.o src/*.c -o bin/${PROJECT} prep: mkdir -p build/ ${BUILDDIR}/%.o : src/%.asm inc/generic.inc ${AS} ${ASFLAGS} $< -o $@ ${BUILDDIR}/dummy.o : dummy.asm ${AS} ${ASFLAGS} $< -o $@ doc: mkdir doc_src asmdoc -d doc_src/ src/*.asm inc/*.inc include/* dist: all mkdir -p ${DISTDIR} mv bin/${PROJECT} ${DISTDIR} rsync -a res ${DISTDIR}/ distwin: win mkdir -p ${W64_DISTDIR} mv bin/${PROJECT}.exe ${W64_DISTDIR}/ cp ${W64_SDL2}/SDL2.dll ${W64_DISTDIR} cp ${W64_SDL2_Image}/SDL2_image.dll ${W64_DISTDIR} cp ${W64_SDL2_TTF}/SDL2_ttf.dll ${W64_DISTDIR} rsync -a res ${W64_DISTDIR}/ distall: make clean make dist tar -cvzf ../${PROJECT}_linux.tgz ${DISTDIR} make clean make distwin zip -r ../${PROJECT}_win64.zip ${W64_DISTDIR} make clean distclean: rm -fr dist/ winprep: prep for file in src/*.asm dummy.asm; do \ ${AS} ${ASFLAGS_WIN} $$file -o ${BUILDDIR}/$$(basename -s .asm $$file).o; \ done win: winprep src/base.c x86_64-w64-mingw32-gcc -Wl,-subsystem,windows -lmingw32 ${BUILDDIR}/*.o src/base.c -o bin/${PROJECT}.exe ${LIBS} -lSDL2main # Might be usefull for smaller binary manual_link: ${AS} ${ASFLAGS} dummy.asm -o ${BUILDDIR}/dummy.o ${CC} -c src/base.c -o ${BUILDDIR}/base.o # gcc ${LIBS} -pie -Wl,-pie src/test.o src/base.c ld ${LIBS} -eRG_Main -lc --dynamic-linker=/lib64/ld-linux-x86-64.so.2 -pie ${BUILDDIR}/*.o -o bin/rge windis: objdump -d -Mintel ${W64_DISTDIR}/${PROJECT}.exe lxdis: objdump -d -Mintel ${DISTDIR}/${PROJECT} clean: rm -rf ${BUILDDIR} bin/* doc_src/ .