Skip to content

Commit

Permalink
clang has different PCH invocation
Browse files Browse the repository at this point in the history
suppress include dependency files error for clean build
  • Loading branch information
bbbradsmith committed Apr 21, 2024
1 parent 5a68726 commit cf770ad
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 16 deletions.
2 changes: 1 addition & 1 deletion cmd/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@ clean:
rm -rf $(CMD_INTDIR)
rm -rf $(dir $(TARGET))

include $(DEPS)
-include $(DEPS)
28 changes: 18 additions & 10 deletions core/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,34 @@ OBJS = $(addprefix $(CORE_INTDIR)/,$(SRCS:.cpp=.o))
DEPS = $(addprefix $(CORE_INTDIR)/,$(SRCS:.cpp=.d))
CXXFLAGS_ALL = $(CXXFLAGS) $(CXXFLAGS_EXTRA) $(INC_COMMON)

# precompiled header

PCH_H = core.h
PCH_BUILD = pch.cpp
PCH_DECOY = $(CORE_INTDIR)/$(CORE_NAME).h
PCH = $(PCH_DECOY).gch
PCHFLAGS = -Winvalid-pch -include $(PCH_DECOY)

$(TARGET): $(OBJS) | $(dir $(TARGET))
rm -f $(TARGET)
$(AR) rcs $(TARGET) $(OBJS)
PCH = $(PCH_DECOY)$(PCH_SUFFIX)
PCHFLAGS = $(PCH_USE) $(PCH_DECOY)$(PCH_USE_SUFFIX)

$(PCH_DECOY): | $(CORE_INTDIR)/
echo "#error \"Precompiled header decoy $(notdir $(PCH_DECOY)) used instead of $(notdir $(PCH))\"" > $@

$(PCH): $(PCH_BUILD) $(PCH_DECOY) $(PCH_H) | $(CORE_INTDIR)/
$(CXX) -x c++-header -o $(PCH) $(CXXFLAGS_ALL) -c $(PCH_BUILD)
$(PCH).d: $(PCH_BUILD) | $(CORE_INTDIR)/
$(CXX) -M -MM -MF $@ -MT $(PCH) $(CXXFLAGS_ALL) -c $<

$(PCH): $(PCH_BUILD) $(PCH_DECOY) $(PCH).d | $(CORE_INTDIR)/
$(CXX) $(PCH_COMPILE) -o $(PCH) $(CXXFLAGS_ALL) -c $(PCH_BUILD)

# target build

$(TARGET): $(OBJS) | $(dir $(TARGET))
rm -f $(TARGET)
$(AR) rcs $(TARGET) $(OBJS)

# want $(PCHFLAGS) here but gcc does not appear to be able to use precompiled headers for -MF
$(CORE_INTDIR)/%.d: %.cpp $(PCH) | $(CORE_INTDIR)/
$(CXX) -M -MM -MF $@ -MT $(CORE_INTDIR)/$(basename $<).o $(CXXFLAGS_ALL) -c $<

$(CORE_INTDIR)/%.o: %.cpp $(CORE_INTDIR)/%.d | $(CORE_INTDIR)/
$(CORE_INTDIR)/%.o: %.cpp $(CORE_INTDIR)/%.d $(PCH) | $(CORE_INTDIR)/
$(CXX) -o $@ $(PCHFLAGS) $(CXXFLAGS_ALL) -c $<

$(CORE_INTDIR)/:
Expand All @@ -45,4 +53,4 @@ clean:
rm -rf $(CORE_INTDIR)
rm -rf $(dir $(TARGET))

include $(DEPS)
-include $(PCH).d $(DEPS)
2 changes: 1 addition & 1 deletion gui/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ clean:
rm -rf $(GUI_INTDIR)
rm -rf $(dir $(TARGET))

include $(DEPS)
-include $(DEPS)
14 changes: 13 additions & 1 deletion makefile.common
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ ifeq ($(OS),Windows_NT)
LDFLAGS_GUI ?=
LDFLAGS_NSFPLAY ?= -mwindows
LDFLAGS_DLL ?= -mdll
PCH_COMPILE ?= -x c++-header
PCH_USE ?= -Winvalid-pch --include
PCH_USE_SUFFIX ?=
PCH_SUFFIX ?= .gch
LIB_SUFFIX ?= .a
EXE_SUFFIX ?= .exe
DLL_SUFFIX ?= .dll
Expand All @@ -67,7 +71,7 @@ ifeq ($(OS),Windows_NT)
-luuid -lole32 -loleacc -loleaut32 \
-lversion -lshlwapi -luxtheme -lwinspool
endif
# wxWidgets props files include:
# wxWidgets props files included:
# kernel32.lib, user32.lib, gdi32.lib, comdlg32.lib, winspool.lib, shell32.lib
# shlwapi.lib, ole32.lib, oleaut32.lib, uuid.lib, advapi32.lib, version.lib
# comctl32.lib, rpcrt4.lib, ws2_32.lib, wininet.lib, winmm.lib
Expand All @@ -79,6 +83,10 @@ else ifeq ($(shell uname),Darwin)
LDFLAGS_GUI ?=
LDFLAGS_NSFPLAY ?=
LDFLAGS_DLL ?= -shared
PCH_COMPILE ?= -x c++-header
PCH_USE ?= -include-pch
PCH_USE_SUFFIX ?= .pch
PCH_SUFFIX ?= .pch
LIB_SUFFIX ?= .a
EXE_SUFFIC ?=
DLL_SUFFIX ?= .so
Expand All @@ -92,6 +100,10 @@ else
LDFLAGS_GUI ?=
LDFLAGS_NSFPLAY ?=
LDFLAGS_DLL ?= -shared
PCH_COMPILE ?= -x c++-header
PCH_USE ?= -Winvalid-pch --include
PCH_USE_SUFFIX ?=
PCH_SUFFIX ?= .gch
LIB_SUFFIX ?= .a
EXE_SUFFIX ?=
DLL_SUFFIX ?= .so
Expand Down
3 changes: 1 addition & 2 deletions nsfplay/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,4 @@ mac: $(ICON_INTDIR)/nsfplay.icns Info.plist ../version.txt
$(ICON_INTDIR)/nsfplay.icns:
make -C ../icons mac


include $(DEPS)
-include $(DEPS)
2 changes: 1 addition & 1 deletion winamp/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ clean:
rm -rf $(WINAMP_INTDIR)
rm -rf $(dir $(TARGET))

include $(DEPS)
-include $(DEPS)

0 comments on commit cf770ad

Please sign in to comment.