Skip to content

Commit

Permalink
Makefile: fix minor issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Rosalie241 committed Nov 28, 2023
1 parent 69a3f4c commit 4fe626b
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 21 deletions.
15 changes: 12 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
# SporeModLoader & SporeModManager Makefile
#

THIRDPARTY_DIR := 3rdParty
# relative to project directories
BINARY_DIR := ../bin
BINARY_DIR := ../bin

CC := gcc
CXX := g++
Expand All @@ -19,13 +20,21 @@ clean:
$(MAKE) -C SporeModManager clean BINARY_DIR=$(BINARY_DIR)/SporeModLoader/SporeModManager
$(MAKE) -C SporeModManager clean MINGW=1 BINARY_DIR=$(BINARY_DIR)/SporeModLoader/SporeModManager

# this is needed due to compiling SporeModLoader twice,
# which, when compiling with multiple threads, will cause
# zconf.h to be generated twice, causing a build failure
# due to a race condition (cp will fail due to the file
# already existing, even with -f)
$(THIRDPARTY_DIR)/zlib/zconf.h: $(THIRDPARTY_DIR)/zlib/zconf.h.in
$(MAKE) -C SporeModManager ../$@

SporeModLoader:
$(MAKE) -C $@ BINARY_DIR=$(BINARY_DIR)/SporebinEP1

SporeModManager:
SporeModManager: $(THIRDPARTY_DIR)/zlib/zconf.h
$(MAKE) -C $@ BINARY_DIR=$(BINARY_DIR)/SporeModLoader/SporeModManager

SporeModManager.exe:
SporeModManager.exe: $(THIRDPARTY_DIR)/zlib/zconf.h
$(MAKE) -C $(basename $@) BINARY_DIR=$(BINARY_DIR)/SporeModLoader/SporeModManager MINGW=1

.PHONY: SporeModLoader SporeModManager SporeModManager.exe all clean
8 changes: 3 additions & 5 deletions SporeModLoader/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,12 @@ endif

all: $(BINARY_DIR)/$(DLL_FILE)

$(BINARY_DIR):
$(QUIET)mkdir -p $@

$(BINARY_DIR)/$(DLL_FILE): $(BINARY_DIR) $(THIRDPARTY_OBJECT_FILES) $(OBJECT_FILES)
$(BINARY_DIR)/$(DLL_FILE): $(THIRDPARTY_OBJECT_FILES) $(OBJECT_FILES)
@echo "MINGW_LD $@"
$(QUIET)mkdir -p $(BINARY_DIR)
$(QUIET)$(MINGW_CXX) $(THIRDPARTY_OBJECT_FILES) $(OBJECT_FILES) -static -shared $(SOURCE_DIR)/dllmain.def -o $@ $(LDFLAGS)

clean:
rm -f $(BINARY_DIR)/$(DLL_FILE) $(OBJECT_FILES) $(THIRDPARTY_OBJECT_FILES) $(THIRDPARTY_HEADER_FILES)

.PHONY: all clean
.PHONY: all clean
25 changes: 12 additions & 13 deletions SporeModManager/Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#
# SporeModManager Makefile
#
THIRDPARTY_DIR ?= ../3rdParty
BINARY_DIR ?= bin
SOURCE_DIR ?= .
EXE_FILE ?= SporeModManager
VERBOSE ?= 0
MINGW ?= 0
THIRDPARTY_DIR := ../3rdParty
BINARY_DIR := bin
SOURCE_DIR := .
EXE_FILE := SporeModManager
VERBOSE := 0
MINGW := 0

CC ?= gcc
CXX ?= g++
Expand All @@ -22,7 +22,7 @@ else
# mingw doesn't like LTO
# and we need to statically link
LDFLAGS := -s -municode -static
OPTFLAGS := -Os
OPTFLAGS := -Os -flto
OBJ := obj
EXE_EXT := .exe
endif
Expand Down Expand Up @@ -90,19 +90,18 @@ endif

all: $(BINARY_DIR)/$(EXE_FILE)$(EXE_EXT)

$(BINARY_DIR):
$(QUIET)mkdir -p $@

$(THIRDPARTY_DIR)/zlib/zconf.h:
$(THIRDPARTY_DIR)/zlib/zconf.h: $(THIRDPARTY_DIR)/zlib/zconf.h.in
@echo "GEN $@"
$(QUIET)cp -f $@.in $@

$(BINARY_DIR)/$(EXE_FILE): $(BINARY_DIR) $(THIRDPARTY_OBJECT_FILES) $(OBJECT_FILES)
$(BINARY_DIR)/$(EXE_FILE): $(THIRDPARTY_OBJECT_FILES) $(OBJECT_FILES)
@echo "LD $@"
$(QUIET)mkdir -p $(BINARY_DIR)
$(QUIET)$(CXX) $(OBJECT_FILES) $(THIRDPARTY_OBJECT_FILES) -o $@ $(LDFLAGS)

$(BINARY_DIR)/$(EXE_FILE).exe: $(BINARY_DIR) $(THIRDPARTY_OBJECT_FILES) $(OBJECT_FILES)
$(BINARY_DIR)/$(EXE_FILE).exe: $(THIRDPARTY_OBJECT_FILES) $(OBJECT_FILES)
@echo "MINGW_LD $@"
$(QUIET)mkdir -p $(BINARY_DIR)
$(QUIET)$(MINGW_CXX) $(OBJECT_FILES) $(THIRDPARTY_OBJECT_FILES) -o $@ $(LDFLAGS)

clean:
Expand Down

0 comments on commit 4fe626b

Please sign in to comment.