Skip to content

Commit cf770ad

Browse files
committed
clang has different PCH invocation
suppress include dependency files error for clean build
1 parent 5a68726 commit cf770ad

File tree

6 files changed

+35
-16
lines changed

6 files changed

+35
-16
lines changed

cmd/makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,4 @@ clean:
4646
rm -rf $(CMD_INTDIR)
4747
rm -rf $(dir $(TARGET))
4848

49-
include $(DEPS)
49+
-include $(DEPS)

core/makefile

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,26 +13,34 @@ OBJS = $(addprefix $(CORE_INTDIR)/,$(SRCS:.cpp=.o))
1313
DEPS = $(addprefix $(CORE_INTDIR)/,$(SRCS:.cpp=.d))
1414
CXXFLAGS_ALL = $(CXXFLAGS) $(CXXFLAGS_EXTRA) $(INC_COMMON)
1515

16+
# precompiled header
17+
1618
PCH_H = core.h
1719
PCH_BUILD = pch.cpp
1820
PCH_DECOY = $(CORE_INTDIR)/$(CORE_NAME).h
19-
PCH = $(PCH_DECOY).gch
20-
PCHFLAGS = -Winvalid-pch -include $(PCH_DECOY)
21-
22-
$(TARGET): $(OBJS) | $(dir $(TARGET))
23-
rm -f $(TARGET)
24-
$(AR) rcs $(TARGET) $(OBJS)
21+
PCH = $(PCH_DECOY)$(PCH_SUFFIX)
22+
PCHFLAGS = $(PCH_USE) $(PCH_DECOY)$(PCH_USE_SUFFIX)
2523

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

29-
$(PCH): $(PCH_BUILD) $(PCH_DECOY) $(PCH_H) | $(CORE_INTDIR)/
30-
$(CXX) -x c++-header -o $(PCH) $(CXXFLAGS_ALL) -c $(PCH_BUILD)
27+
$(PCH).d: $(PCH_BUILD) | $(CORE_INTDIR)/
28+
$(CXX) -M -MM -MF $@ -MT $(PCH) $(CXXFLAGS_ALL) -c $<
29+
30+
$(PCH): $(PCH_BUILD) $(PCH_DECOY) $(PCH).d | $(CORE_INTDIR)/
31+
$(CXX) $(PCH_COMPILE) -o $(PCH) $(CXXFLAGS_ALL) -c $(PCH_BUILD)
32+
33+
# target build
34+
35+
$(TARGET): $(OBJS) | $(dir $(TARGET))
36+
rm -f $(TARGET)
37+
$(AR) rcs $(TARGET) $(OBJS)
3138

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

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

3846
$(CORE_INTDIR)/:
@@ -45,4 +53,4 @@ clean:
4553
rm -rf $(CORE_INTDIR)
4654
rm -rf $(dir $(TARGET))
4755

48-
include $(DEPS)
56+
-include $(PCH).d $(DEPS)

gui/makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@ clean:
3333
rm -rf $(GUI_INTDIR)
3434
rm -rf $(dir $(TARGET))
3535

36-
include $(DEPS)
36+
-include $(DEPS)

makefile.common

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ ifeq ($(OS),Windows_NT)
4545
LDFLAGS_GUI ?=
4646
LDFLAGS_NSFPLAY ?= -mwindows
4747
LDFLAGS_DLL ?= -mdll
48+
PCH_COMPILE ?= -x c++-header
49+
PCH_USE ?= -Winvalid-pch --include
50+
PCH_USE_SUFFIX ?=
51+
PCH_SUFFIX ?= .gch
4852
LIB_SUFFIX ?= .a
4953
EXE_SUFFIX ?= .exe
5054
DLL_SUFFIX ?= .dll
@@ -67,7 +71,7 @@ ifeq ($(OS),Windows_NT)
6771
-luuid -lole32 -loleacc -loleaut32 \
6872
-lversion -lshlwapi -luxtheme -lwinspool
6973
endif
70-
# wxWidgets props files include:
74+
# wxWidgets props files included:
7175
# kernel32.lib, user32.lib, gdi32.lib, comdlg32.lib, winspool.lib, shell32.lib
7276
# shlwapi.lib, ole32.lib, oleaut32.lib, uuid.lib, advapi32.lib, version.lib
7377
# comctl32.lib, rpcrt4.lib, ws2_32.lib, wininet.lib, winmm.lib
@@ -79,6 +83,10 @@ else ifeq ($(shell uname),Darwin)
7983
LDFLAGS_GUI ?=
8084
LDFLAGS_NSFPLAY ?=
8185
LDFLAGS_DLL ?= -shared
86+
PCH_COMPILE ?= -x c++-header
87+
PCH_USE ?= -include-pch
88+
PCH_USE_SUFFIX ?= .pch
89+
PCH_SUFFIX ?= .pch
8290
LIB_SUFFIX ?= .a
8391
EXE_SUFFIC ?=
8492
DLL_SUFFIX ?= .so
@@ -92,6 +100,10 @@ else
92100
LDFLAGS_GUI ?=
93101
LDFLAGS_NSFPLAY ?=
94102
LDFLAGS_DLL ?= -shared
103+
PCH_COMPILE ?= -x c++-header
104+
PCH_USE ?= -Winvalid-pch --include
105+
PCH_USE_SUFFIX ?=
106+
PCH_SUFFIX ?= .gch
95107
LIB_SUFFIX ?= .a
96108
EXE_SUFFIX ?=
97109
DLL_SUFFIX ?= .so

nsfplay/makefile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,5 +76,4 @@ mac: $(ICON_INTDIR)/nsfplay.icns Info.plist ../version.txt
7676
$(ICON_INTDIR)/nsfplay.icns:
7777
make -C ../icons mac
7878

79-
80-
include $(DEPS)
79+
-include $(DEPS)

winamp/makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,4 @@ clean:
4343
rm -rf $(WINAMP_INTDIR)
4444
rm -rf $(dir $(TARGET))
4545

46-
include $(DEPS)
46+
-include $(DEPS)

0 commit comments

Comments
 (0)