@@ -381,11 +381,14 @@ ifneq ($(CLANG), 0)
381381 ifeq ($(CCACHE), 1)
382382 CXX = CCACHE_CPP2=1 $(CCACHEBIN ) $(CROSS )$(CLANGCMD )
383383 LD = CCACHE_CPP2=1 $(CCACHEBIN ) $(CROSS )$(CLANGCMD )
384+ CC = CCACHE_CPP2=1 $(CCACHEBIN ) $(CROSS )$(subst ++,,$(CLANGCMD ) )
384385 else
385386 CXX = $(CROSS )$(CLANGCMD )
386387 LD = $(CROSS )$(CLANGCMD )
388+ CC = $(CROSS )$(subst ++,,$(CLANGCMD ) )
387389 endif
388390 CXX_WARNINGS += -Wno-unknown-warning-option
391+ WARNINGS += -Wno-unknown-warning-option
389392else
390393 # Compiler version & target machine - used later for MXE ICE workaround
391394 ifdef CROSS
410413 LD = $(CROSS )$(OS_LINKER )
411414 endif
412415 CXX_WARNINGS += -Wno-unknown-warning
416+ WARNINGS += -Wno-unknown-warning
413417endif
414418
415419STRIP = $(CROSS ) strip
@@ -531,9 +535,9 @@ ifeq ($(PCH), 1)
531535
532536 ifeq ($(CLANG), 0)
533537 PCHFLAGS += -include pch/main-pch.hpp
534- PCH_P = $(PCH_H ) .gch
538+ PCH_P = $(ODIR ) / $( PCH_H ) .gch
535539 else
536- PCH_P = $(PCH_H ) .pch
540+ PCH_P = $(ODIR ) / $( PCH_H ) .pch
537541 PCHFLAGS += -include-pch $(PCH_P )
538542
539543 # FIXME: dirty hack ahead
@@ -612,11 +616,13 @@ endif
612616ifeq ($(NATIVE ) , osx)
613617 DEFINES += -DMACOSX
614618 CXXFLAGS += -mmacosx-version-min=10.15
619+ CFLAGS += -mmacosx-version-min=10.15
615620 LDFLAGS += -mmacosx-version-min=10.15 -framework CoreFoundation -Wl,-headerpad_max_install_names
616621 # doesn't use GNU ar
617622 THIN_AR =0
618623 ifeq ($(UNIVERSAL_BINARY), 1)
619624 CXXFLAGS += -arch x86_64 -arch arm64
625+ CFLAGS += -arch x86_64 -arch arm64
620626 LDFLAGS += -arch x86_64 -arch arm64
621627 endif
622628 ifdef FRAMEWORK
@@ -964,8 +970,7 @@ ifeq ($(MSYS2),1)
964970 DEFINES += -DMSYS2 -D_GLIBCXX_USE_C99_MATH_TR1
965971endif
966972
967- CFLAGS := $(CXXFLAGS )
968- CFLAGS += $(C_STD )
973+ CFLAGS += $(C_STD ) $(WARNINGS )
969974CXXFLAGS += $(CXX_STD ) $(CXX_WARNINGS )
970975
971976# Enumerations of all the source files and headers.
@@ -1130,14 +1135,14 @@ prefix:
11301135 )
11311136
11321137# Unconditionally create the object dirs on every invocation.
1133- DIRS = $(sort $(dir $(OBJS ) ) )
1138+ DIRS = $(sort $(dir $(OBJS ) $( PCH_P ) ) )
11341139$(shell mkdir -p $(DIRS))
11351140
11361141$(ODIR ) /% .inc : $(SRC_DIR ) /% .cpp
11371142 $(COMPILE.cc ) -o /dev/null -Wno-error -H -E $< 2> $@
11381143
11391144$(ODIR ) /% .inc : $(SRC_DIR ) /% .c
1140- $(CXX ) -x c $( CPPFLAGS ) $( DEFINES ) $( CFLAGS ) -Wno-error -H -E $< -o /dev/null 2> $@
1145+ $(COMPILE.c ) -o /dev/null -Wno-error -H -E $< 2> $@
11411146
11421147.PHONY : includes
11431148includes : $(OBJS:.o=.inc )
@@ -1147,7 +1152,7 @@ $(ODIR)/third-party/%.o: $(SRC_DIR)/third-party/%.cpp
11471152 $(COMPILE.cc ) $(OUTPUT_OPTION ) -w -MMD -MP $<
11481153
11491154$(ODIR ) /third-party/% .o : $(SRC_DIR ) /third-party/% .c
1150- $(COMPILE.cc ) $(OUTPUT_OPTION ) -x c $(CFLAGS ) -w -MMD -MP -c $<
1155+ $(COMPILE.c ) $(OUTPUT_OPTION ) -x c $(CFLAGS ) -w -MMD -MP $<
11511156
11521157$(ODIR ) /% .o : $(SRC_DIR ) /% .cpp $(PCH_P )
11531158 $(COMPILE.cc ) $(OUTPUT_OPTION ) $(PCHFLAGS ) -MMD -MP $<
@@ -1183,7 +1188,7 @@ $(CHKJSON_BIN): $(CHKJSON_SOURCES)
11831188json-check : $(CHKJSON_BIN )
11841189 ./$(CHKJSON_BIN )
11851190
1186- clean : clean-tests clean-pch clean- lang
1191+ clean : clean-tests clean-lang
11871192 rm -rf * $(TARGET_NAME ) * $(TILES_TARGET_NAME )
11881193 rm -rf * $(TILES_TARGET_NAME ) .exe * $(TARGET_NAME ) .exe * $(TARGET_NAME ) .a
11891194 rm -rf * obj * objwin
@@ -1441,7 +1446,8 @@ $(BUILD_PREFIX)zstd.a: $(filter $(ODIR)/third-party/zstd/%.o,$(OBJS))
14411446 $(AR ) rcs $(AR_FLAGS ) $(BUILD_PREFIX ) zstd.a $^
14421447
14431448$(ZZIP_BIN ) : $(ZZIP_SOURCES ) $(BUILD_PREFIX ) zstd.a
1444- $(LINK.cc ) $(OUTPUT_OPTION ) -MMD -MP -isystem src/third-party $^
1449+ # Remove SDL libraries used by cataclysm
1450+ $(subst $(LDFLAGS),,$(LINK.cc)) $(OUTPUT_OPTION) -MMD -MP -isystem src/third-party $^
14451451
14461452python-check :
14471453 flake8
@@ -1455,19 +1461,15 @@ check: version $(BUILD_PREFIX)cataclysm.a $(LOCALIZE_TEST_DEPS)
14551461clean-tests :
14561462 $(MAKE ) -C tests clean
14571463
1458- clean-pch :
1459- rm -f pch/* pch.hpp.gch
1460- rm -f pch/* pch.hpp.pch
1461- rm -f pch/* pch.hpp.d
1462- $(MAKE ) -C tests clean-pch
1463-
14641464clean-lang :
14651465 $(MAKE ) -C lang clean
14661466
1467- .PHONY : tests check ctags etags clean-tests clean-pch clean- lang install lint
1467+ .PHONY : tests check ctags etags clean-tests clean-lang install lint
14681468
14691469compile_commands.txt :
14701470 @echo ' COMPILE.cc := $(COMPILE.cc)' > $@
14711471 @echo ' LINK.cc := $(LINK.cc)' >> $@
1472+ @echo ' COMPILE.c := $(COMPILE.c)' >> $@
1473+ @echo ' LINK.c := $(LINK.c)' >> $@
14721474
14731475-include ${OBJS :.o=.d}
0 commit comments