1
0
Fork 0

Makefile: Use just one makefile; improvements (#29)

pull/38/merge
Leonard 2018-06-21 16:21:09 +02:00 committed by galaxyhaxz
parent 5f31783b0c
commit 7e5bed4fb5
7 changed files with 110 additions and 46 deletions

1
.gitignore vendored
View File

@ -2,3 +2,4 @@
*.lib *.lib
*.dll *.dll
*.exe *.exe
*.d

4
3rdParty/PKWare/objs.mak vendored Normal file
View File

@ -0,0 +1,4 @@
PKWARE_OBJS=3rdParty/PKWare/explode.o \
3rdParty/PKWare/implode.o
-include *.d

View File

@ -1,30 +1,46 @@
DIABLO_SRC=$(wildcard Source/*.cpp) # For 32-bit build systems, the executable is just mingw32
DIABLO_OBJ=$(DIABLO_SRC:.cpp=.o) MINGW32 ?= i686-w64-mingw32
# Used s.t. we can try to use clang to compile code
_CXX ?= g++
PKWARE_SRC=$(wildcard 3rdParty/PKWare/*.cpp) CXX=$(MINGW32)-$(_CXX)
PKWARE_OBJ=$(PKWARE_SRC:.cpp=.o) 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<NEW_TYPE>(reinterpret_cast<uintptr_t>(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 all: devilution.exe
devilution.exe: $(DIABLO_OBJ) $(PKWARE_OBJ) diabloui.lib storm.lib include 3rdParty/PKWare/objs.mak
i686-w64-mingw32-gcc -L./ -o $@ $^ -lgdi32 -lversion -ldiabloui -lstorm include Source/objs.mak
%.o: %.cpp devilution.exe: $(OBJS) $(PKWARE_OBJS) diabloui.lib storm.lib
i686-w64-mingw32-gcc -c -fpermissive -Wno-write-strings -o $@ $< $(CXX) $(LDFLAGS) -o $@ $^ $(LDLIBS)
diabloui.lib: diabloui.dll DiabloUI/diabloui_gcc.def 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: 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 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: storm.dll:
echo "Please copy storm.dll (version 1.09b) here." $(error Please copy storm.dll (version 1.09b) here)
clean: clean:
rm -f $(DIABLO_OBJ) $(PKWARE_OBJ) @$(RM) -v $(OBJS) $(OBJS:.o=.d) $(PKWARE_OBJS) $(PKWARE_OBJS:.o=d)
.PHONY: clean all .PHONY: clean all

View File

@ -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

View File

@ -28,7 +28,7 @@ Building with Visual C++ 5.10
Building with MinGW(32/64) Building with MinGW(32/64)
- Ensure that the MinGW binary paths have been added to the command line. - 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. - 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 Compiling Definitions

70
Source/objs.mak Normal file
View File

@ -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

View File

@ -2,9 +2,9 @@
## Dependencies ## Dependencies
Arch Linux: Arch Linux
```bash ```bash
pacman -Sy mingw-w64-gcc mingw-w64-binutils pacman -S mingw-w64-gcc mingw-w64-binutils
``` ```
## Building ## Building
@ -17,6 +17,9 @@ cp /path/to/diablo_game_dir/storm.dll .
make make
``` ```
On a 32-bit host, `$ make MINGW32=mingw32` should be used, to specify the 32-bit
toolchain.
## Install ## Install
```bash ```bash