Extract compiler pre-defined macros as Make variables

This commit is contained in:
Michael Davidsaver
2020-08-30 18:36:18 -07:00
committed by Brendan Chandler
parent 4e81eaa7e8
commit 077b41e6c1
5 changed files with 60 additions and 2 deletions

1
.gitignore vendored
View File

@@ -7,6 +7,7 @@
/include/
/templates/
/configure/*.local
/configure/os/CONFIG_TOOLCHAIN.*
/modules/RELEASE.*.local
/modules/Makefile.local
O.*/

View File

@@ -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

View File

@@ -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

View File

@@ -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

37
configure/toolchain.c Normal file
View File

@@ -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 <rtems/score/cpuopts.h>
# if __RTEMS_MAJOR__>=5
OS_API = posix
# else
OS_API = kernel
# endif
#endif