Skip to content

Commit

Permalink
Limit the use of VPATH for GNU Make (#9332)
Browse files Browse the repository at this point in the history
  • Loading branch information
oleg-derevenetz authored Dec 11, 2024
1 parent 6b8fb08 commit 80d8371
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 30 deletions.
10 changes: 3 additions & 7 deletions src/dist/engine/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,16 @@ ifndef FHEROES2_WITH_SYSTEM_SMACKER
CCFLAGS := $(CCFLAGS) -I../../thirdparty/libsmacker
endif

SOURCEROOT := ../../engine
SOURCEDIRS := $(SOURCEROOT)
SOURCES := $(wildcard $(SOURCEDIRS)/*.cpp)
SOURCEDIR := ../../engine

.PHONY: all clean

all: libengine.a

libengine.a: $(notdir $(patsubst %.cpp, %.o, $(SOURCES)))
libengine.a: $(notdir $(patsubst %.cpp, %.o, $(wildcard $(SOURCEDIR)/*.cpp)))
$(AR) crvs $@ $^

VPATH := $(SOURCEDIRS)

%.o: %.cpp
%.o: $(SOURCEDIR)/%.cpp
$(CXX) -c -MD $< $(CCFLAGS) $(CXXFLAGS) $(CPPFLAGS)

include $(wildcard *.d)
Expand Down
12 changes: 6 additions & 6 deletions src/dist/fheroes2/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,35 +18,35 @@
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #
###########################################################################

LIBENGINE := ../engine/libengine.a
DEPLIBS := ../engine/libengine.a
CCFLAGS := $(CCFLAGS) -I../../engine

ifndef FHEROES2_WITH_SYSTEM_SMACKER
LIBENGINE := $(LIBENGINE) ../thirdparty/libsmacker/libsmacker.a
DEPLIBS := $(DEPLIBS) ../thirdparty/libsmacker/libsmacker.a
CCFLAGS := $(CCFLAGS) -I../../thirdparty/libsmacker
endif

SOURCEROOT := ../../fheroes2
SOURCEDIRS := $(filter %/,$(wildcard $(SOURCEROOT)/*/))
SOURCES := $(wildcard $(SOURCEROOT)/*/*.cpp)

VPATH := $(SOURCEDIRS)

.PHONY: all pot clean

all: fheroes2 pot

pot: fheroes2.pot

fheroes2: $(notdir $(patsubst %.cpp, %.o, $(SOURCES))) $(LIBENGINE)
fheroes2: $(notdir $(patsubst %.cpp, %.o, $(SOURCES))) $(DEPLIBS)
$(CXX) -o $@ $^ $(LIBS) $(LDFLAGS)

fheroes2.pot: $(SOURCES)
xgettext -d fheroes2 -C -F -k_ -k_n:1,2 -o fheroes2.pot $(sort $(SOURCES))
sed -i~ -e 's/, c-format//' fheroes2.pot

VPATH := $(SOURCEDIRS)

%.o: %.cpp
$(CXX) -c -MD $(addprefix -I, $(SOURCEDIRS)) $< $(CCFLAGS) $(CXXFLAGS) $(CPPFLAGS)
$(CXX) -c -MD $< $(addprefix -I, $(SOURCEDIRS)) $(CCFLAGS) $(CXXFLAGS) $(CPPFLAGS)

include $(wildcard *.d)

Expand Down
7 changes: 1 addition & 6 deletions src/dist/thirdparty/libsmacker/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,14 @@
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #
###########################################################################

SOURCEROOT := ../../../thirdparty/libsmacker
SOURCEDIRS := $(SOURCEROOT)

.PHONY: all clean

all: libsmacker.a

libsmacker.a: smacker.o
$(AR) crvs $@ $^

VPATH := $(SOURCEDIRS)

smacker.o: smacker.c
smacker.o: ../../../thirdparty/libsmacker/smacker.c
$(CC) -c -MD $< $(CCFLAGS) $(CFLAGS) $(CPPFLAGS)

include $(wildcard *.d)
Expand Down
14 changes: 3 additions & 11 deletions src/dist/tools/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,15 @@

TARGETS := 82m2wav bin2txt extractor h2dmgr icn2img pal2img til2img xmi2midi

LIBENGINE := ../engine/libengine.a
CCFLAGS := $(CCFLAGS) -I../../engine

SOURCEROOT := ../../tools
SOURCEDIRS := $(SOURCEROOT)

.PHONY: all clean

all: $(TARGETS)

$(TARGETS): %: %.o $(LIBENGINE)
$(TARGETS): %: %.o ../engine/libengine.a
$(CXX) -o $@ $^ $(LIBS) $(LDFLAGS)

VPATH := $(SOURCEDIRS)

%.o: %.cpp
$(CXX) -c -MD $< $(CCFLAGS) $(CXXFLAGS) $(CPPFLAGS)
%.o: ../../tools/%.cpp
$(CXX) -c -MD $< -I../../engine $(CCFLAGS) $(CXXFLAGS) $(CPPFLAGS)

include $(wildcard *.d)

Expand Down

0 comments on commit 80d8371

Please sign in to comment.