From e4e80b4d3d2b1af2e747437ae48ece8a09396dcb Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Sat, 23 Jun 2012 17:22:08 +0000 Subject: [PATCH] Add a configure check for the pch flags as clang doesn't support -fpch-deps Originally committed to SVN as r6918. --- aegisub/Makefile.target | 2 +- aegisub/configure.in | 3 +++ aegisub/m4macros/ac_flag.m4 | 21 +++++++++++++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/aegisub/Makefile.target b/aegisub/Makefile.target index 61fce79ca..bccfe9838 100644 --- a/aegisub/Makefile.target +++ b/aegisub/Makefile.target @@ -147,7 +147,7 @@ OBJCXXFLAGS := $(CXXFLAGS) #################### ifeq (yes, $(PRECOMPILED_HEADER)) ifdef PRECOMPILED_HEADER_NAME - CXXFLAGS += -include $(PRECOMPILED_HEADER_NAME) -Winvalid-pch -fpch-deps -fpch-preprocess + CXXFLAGS += -include $(PRECOMPILED_HEADER_NAME) $(PCHFLAGS) # This hack is required until we can use the 'private' keyword (gmake 3.82) to avoid all the # per-object CXXFLAGS being triggered by the ($OBJ) line. CXXFLAGS_GNU_MAKE_SUCKS := $(CXXFLAGS) diff --git a/aegisub/configure.in b/aegisub/configure.in index 76b9258f5..592132e40 100644 --- a/aegisub/configure.in +++ b/aegisub/configure.in @@ -532,6 +532,9 @@ AC_MSG_CHECKING([whether to use precompiled headers]) AC_ARG_ENABLE(gcc-prec, AS_HELP_STRING([--disable-gcc-prec],[disable GCC precompiled headers])) AC_MSG_RESULT([${enable_gcc_prec:=yes}]) AC_SUBST(enable_gcc_prec) +AC_PCH_FLAG([-Winvalid-pch]) +AC_PCH_FLAG([-fpch-deps]) +AC_PCH_FLAG([-fpch-preprocess]) ########### # Profiling diff --git a/aegisub/m4macros/ac_flag.m4 b/aegisub/m4macros/ac_flag.m4 index 8702d7805..cf3248a4e 100644 --- a/aegisub/m4macros/ac_flag.m4 +++ b/aegisub/m4macros/ac_flag.m4 @@ -28,3 +28,24 @@ AC_DEFUN([AC_CXX_FLAG], [{ ]) AC_LANG_POP(C++) }]) +AC_DEFUN([AC_PCH_FLAG], [{ + AC_LANG_PUSH(C++) + ac_cxx_flag_save="$CXXFLAGS" + ac_cxx_werror_flag_save="$ac_cxx_werror_flag" + ac_cxx_werror_flag=yes + CXXFLAGS="$CXXFLAGS -Werror $1" + AC_MSG_CHECKING([[whether $CXX supports $1]]) + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[]])], + [ + PCHFLAGS="$PCHFLAGS $1" + AC_MSG_RESULT([yes]) + ], + [ + AC_MSG_RESULT([no]) + $2 + ]) + CXXFLAGS="$ac_cxx_flag_save" + ac_cxx_werror_flag="$ac_cxx_werror_flag_save" + AC_LANG_POP(C++) + }])