diff --git a/.gitignore b/.gitignore index 94e36205a..23a5179e8 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,7 @@ /include/ /templates/ /configure/*.local +/configure/os/CONFIG_TOOLCHAIN.* /modules/RELEASE.*.local /modules/Makefile.local O.*/ diff --git a/configure/CONFIG b/configure/CONFIG index fab3c245f..320ee8200 100644 --- a/configure/CONFIG +++ b/configure/CONFIG @@ -71,6 +71,7 @@ ifdef T_A # Target architecture specific definitions # + -include $(CONFIG)/os/CONFIG_TOOLCHAIN.Common.$(T_A) -include $(CONFIG)/os/CONFIG.Common.$(T_A) # Host-Target architecture specific definitions diff --git a/configure/Makefile b/configure/Makefile index f48278dd3..157dde0ea 100644 --- a/configure/Makefile +++ b/configure/Makefile @@ -15,7 +15,8 @@ include $(TOP)/configure/CONFIG TOOLS = $(TOP)/src/tools CONFIGS += $(subst ../,,$(wildcard ../CONFIG*)) -CONFIGS += $(subst ../,,$(wildcard ../os/CONFIG*)) +CONFIGS += $(subst ../,,$(wildcard ../os/CONFIG.*)) +CONFIGS += $(subst ../,,$(wildcard ../os/CONFIG_SITE.*)) CONFIGS += $(subst ../,,$(wildcard ../RELEASE*)) CONFIGS += $(subst ../,,$(wildcard ../RULES*)) @@ -31,3 +32,21 @@ CFG += CONFIG_DATABASE_VERSION include $(TOP)/configure/RULES +ifdef T_A + +install: $(TOP)/configure/os/CONFIG_TOOLCHAIN.Common.$(T_A) + +$(TOP)/configure/os/CONFIG_TOOLCHAIN.Common.$(T_A): toolchain.c + $(PREPROCESS.cpp) + +else + +realclean: clean_toolchain +clean: clean_toolchain + +clean_toolchain: + $(RM) $(wildcard os/CONFIG_TOOLCHAIN.Common.*) + +.PHONY: clean_toolchain + +endif # T_A diff --git a/configure/os/CONFIG.Common.RTEMS b/configure/os/CONFIG.Common.RTEMS index 8425e6ef9..7a2a616a2 100644 --- a/configure/os/CONFIG.Common.RTEMS +++ b/configure/os/CONFIG.Common.RTEMS @@ -41,7 +41,7 @@ include $(CONFIG.CC) # RTEMS cross-development tools CC = $(RTEMS_TOOLS)/bin/$(CC_FOR_TARGET) $(GCCSPECS) -fasm CCC = $(RTEMS_TOOLS)/bin/$(CXX) -CPP = $(RTEMS_TOOLS)/bin/$(CC_FOR_TARGET) -x c -E +CPP = $(RTEMS_TOOLS)/bin/$(CC_FOR_TARGET) -x c -E $(GCCSPECS) AR = $(RTEMS_TOOLS)/bin/$(AR_FOR_TARGET) LD = $(RTEMS_TOOLS)/bin/$(LD_FOR_TARGET) -r diff --git a/configure/toolchain.c b/configure/toolchain.c new file mode 100644 index 000000000..c19d1049d --- /dev/null +++ b/configure/toolchain.c @@ -0,0 +1,37 @@ +#ifdef _COMMENT_ +/* Extract compiler pre-defined macros as Make variables + * + * Expanded as configure/os/CONFIG_TOOLCHAIN.Common.$(T_A) + * + * Must be careful not to #include any C definitions + * into what is really a Makefile snippet + * + * cf. https://sourceforge.net/p/predef/wiki/Home/ + */ +/* GCC preprocessor drops C comments from output. + * MSVC preprocessor emits C comments in output + */ +#endif + +#if defined(__GNUC__) && !defined(__clang__) +GCC_MAJOR = __GNUC__ +GCC_MINOR = __GNUC_MINOR__ +GCC_PATCH = __GNUC_PATCHLEVEL__ + +#elif defined(__clang__) +CLANG_MAJOR = __clang_major__ +CLANG_MINOR = __clang_minor__ +CLANG_PATCH = __clang_patchlevel__ + +#elif defined(_MSC_VER) +MSVC_VER = _MSC_VER +#endif + +#ifdef __rtems__ +#include +# if __RTEMS_MAJOR__>=5 +OS_API = posix +# else +OS_API = kernel +# endif +#endif