diff --git a/.gitignore b/.gitignore index dd68893..387a4ff 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ *.lib *.dll *.exe +*.d diff --git a/3rdParty/PKWare/objs.mak b/3rdParty/PKWare/objs.mak new file mode 100644 index 0000000..b6e34a1 --- /dev/null +++ b/3rdParty/PKWare/objs.mak @@ -0,0 +1,4 @@ +PKWARE_OBJS=3rdParty/PKWare/explode.o \ + 3rdParty/PKWare/implode.o + +-include *.d diff --git a/Makefile b/Makefile index 53d74c7..8e942d2 100644 --- a/Makefile +++ b/Makefile @@ -1,30 +1,46 @@ -DIABLO_SRC=$(wildcard Source/*.cpp) -DIABLO_OBJ=$(DIABLO_SRC:.cpp=.o) +# For 32-bit build systems, the executable is just mingw32 +MINGW32 ?= i686-w64-mingw32 +# Used s.t. we can try to use clang to compile code +_CXX ?= g++ -PKWARE_SRC=$(wildcard 3rdParty/PKWare/*.cpp) -PKWARE_OBJ=$(PKWARE_SRC:.cpp=.o) +CXX=$(MINGW32)-$(_CXX) +ifeq ($(MINGW32), "mingw32") + DLLTOOL=dlltool +else + DLLTOOL=$(MINGW32)-dlltool +endif + +# Clang doesn't understand permissive compilation, we need to "fix" invalid +# casts from a pointer type there using +# static_cast(reinterpret_cast(ptr)) +# instead of +# (NEW_TYPE)(ptr) +CXXFLAGS=-std=c++98 -fpermissive -Wno-write-strings +CPPFLAGS=-MMD -MF $*.d +LDLIBS=-lgdi32 -lversion -ldiabloui -lstorm +LDFLAGS=-L./ all: devilution.exe -devilution.exe: $(DIABLO_OBJ) $(PKWARE_OBJ) diabloui.lib storm.lib - i686-w64-mingw32-gcc -L./ -o $@ $^ -lgdi32 -lversion -ldiabloui -lstorm +include 3rdParty/PKWare/objs.mak +include Source/objs.mak -%.o: %.cpp - i686-w64-mingw32-gcc -c -fpermissive -Wno-write-strings -o $@ $< +devilution.exe: $(OBJS) $(PKWARE_OBJS) diabloui.lib storm.lib + $(CXX) $(LDFLAGS) -o $@ $^ $(LDLIBS) diabloui.lib: diabloui.dll DiabloUI/diabloui_gcc.def - i686-w64-mingw32-dlltool -d DiabloUI/diabloui_gcc.def -D diabloui.dll -l diabloui.lib + $(DLLTOOL) -d DiabloUI/diabloui_gcc.def -D $< -l $@ diabloui.dll: - echo "Please copy diabloui.dll (version 1.09b) here." + $(error Please copy diabloui.dll (version 1.09b) here) storm.lib: storm.dll 3rdParty/Storm/Source/storm_gcc.def - i686-w64-mingw32-dlltool -d 3rdParty/Storm/Source/storm_gcc.def -D storm.dll -l storm.lib + $(DLLTOOL) -d 3rdParty/Storm/Source/storm_gcc.def -D $< -l $@ storm.dll: - echo "Please copy storm.dll (version 1.09b) here." + $(error Please copy storm.dll (version 1.09b) here) clean: - rm -f $(DIABLO_OBJ) $(PKWARE_OBJ) + @$(RM) -v $(OBJS) $(OBJS:.o=.d) $(PKWARE_OBJS) $(PKWARE_OBJS:.o=d) .PHONY: clean all diff --git a/Makefile32 b/Makefile32 deleted file mode 100644 index 54378da..0000000 --- a/Makefile32 +++ /dev/null @@ -1,30 +0,0 @@ -DIABLO_SRC=$(wildcard Source/*.cpp) -DIABLO_OBJ=$(DIABLO_SRC:.cpp=.o) - -PKWARE_SRC=$(wildcard 3rdParty/PKWare/*.cpp) -PKWARE_OBJ=$(PKWARE_SRC:.cpp=.o) - -all: devilution.exe - -devilution.exe: $(DIABLO_OBJ) $(PKWARE_OBJ) diabloui.lib storm.lib - mingw32-gcc -L./ -o $@ $^ -lgdi32 -lversion -ldiabloui -lstorm - -%.o: %.cpp - mingw32-gcc -c -fpermissive -Wno-write-strings -o $@ $< - -diabloui.lib: diabloui.dll DiabloUI/diabloui_gcc.def - dlltool -d DiabloUI/diabloui_gcc.def -D diabloui.dll -l diabloui.lib - -diabloui.dll: - echo "Please copy diabloui.dll (version 1.09b) here." - -storm.lib: storm.dll 3rdParty/Storm/Source/storm_gcc.def - dlltool -d 3rdParty/Storm/Source/storm_gcc.def -D storm.dll -l storm.lib - -storm.dll: - echo "Please copy storm.dll (version 1.09b) here." - -clean: - rm -f $(DIABLO_OBJ) $(PKWARE_OBJ) - -.PHONY: clean all diff --git a/README.md b/README.md index 1828482..6c3d2c6 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ Building with Visual C++ 5.10 Building with MinGW(32/64) - Ensure that the MinGW binary paths have been added to the command line. -- For MinGW32, navigate to the project root and execute `mingw32-make -f Makefile32`. The process will take longer than Visual Studio. +- For MinGW32, navigate to the project root and execute `make MINGW32=mingw32`. The process will take longer than Visual Studio. - For MinGW64, refer to the respective documentation: [Linux](Support/INSTALL_linux.md) | [Windows](Support/INSTALL_windows.md). Note that only x86 systems may be targeted for the time being. Compiling Definitions diff --git a/Source/objs.mak b/Source/objs.mak new file mode 100644 index 0000000..3a7c893 --- /dev/null +++ b/Source/objs.mak @@ -0,0 +1,70 @@ +OBJS=Source/path.o \ + Source/monster.o \ + Source/engine.o \ + Source/world.o \ + Source/help.o \ + Source/interfac.o \ + Source/effects.o \ + Source/towners.o \ + Source/gendung.o \ + Source/sound.o \ + Source/sha.o \ + Source/dead.o \ + Source/multi.o \ + Source/items.o \ + Source/drlg_l2.o \ + Source/codec.o \ + Source/pfile.o \ + Source/drlg_l4.o \ + Source/gamemenu.o \ + Source/appfat.o \ + Source/error.o \ + Source/restrict.o \ + Source/player.o \ + Source/capture.o \ + Source/mpqapi.o \ + Source/nthread.o \ + Source/setmaps.o \ + Source/trigs.o \ + Source/diablo.o \ + Source/dx.o \ + Source/portal.o \ + Source/msgcmd.o \ + Source/plrmsg.o \ + Source/themes.o \ + Source/control.o \ + Source/doom.o \ + Source/init.o \ + Source/cursor.o \ + Source/debug.o \ + Source/pack.o \ + Source/stores.o \ + Source/msg.o \ + Source/loadsave.o \ + Source/objects.o \ + Source/palette.o \ + Source/quests.o \ + Source/wave.o \ + Source/tmsg.o \ + Source/minitext.o \ + Source/scrollrt.o \ + Source/sync.o \ + Source/missiles.o \ + Source/gmenu.o \ + Source/town.o \ + Source/dthread.o \ + Source/logging.o \ + Source/textdat.o \ + Source/lighting.o \ + Source/automap.o \ + Source/inv.o \ + Source/drlg_l1.o \ + Source/spells.o \ + Source/encrypt.o \ + Source/fault.o \ + Source/track.o \ + Source/movie.o \ + Source/drlg_l3.o \ + Source/mainmenu.o + +-include *.d diff --git a/Support/INSTALL_linux.md b/Support/INSTALL_linux.md index 5add5c2..a2ab628 100644 --- a/Support/INSTALL_linux.md +++ b/Support/INSTALL_linux.md @@ -2,9 +2,9 @@ ## Dependencies -Arch Linux: +Arch Linux ```bash -pacman -Sy mingw-w64-gcc mingw-w64-binutils +pacman -S mingw-w64-gcc mingw-w64-binutils ``` ## Building @@ -17,6 +17,9 @@ cp /path/to/diablo_game_dir/storm.dll . make ``` +On a 32-bit host, `$ make MINGW32=mingw32` should be used, to specify the 32-bit +toolchain. + ## Install ```bash