diff --git a/Makefile b/Makefile index 1bb3f6b90..2a1639c17 100644 --- a/Makefile +++ b/Makefile @@ -387,11 +387,11 @@ clean :: @$(MAKE) -C kernel clean #endif @$(MAKE) -C reference clean - @rm -f *.$(LIBSUFFIX) *.so *~ *.exe getarch getarch_2nd *.dll *.lib *.$(SUFFIX) *.dwf $(LIBPREFIX).$(LIBSUFFIX) $(LIBPREFIX)_p.$(LIBSUFFIX) $(LIBPREFIX).so.$(MAJOR_VERSION) *.lnk myconfig.h *.so.renamed *.a.renamed *.so.0 + @rm -f *.$(LIBSUFFIX) *.so *~ *.exe getarch getarch-* getarch_2nd getarch_2nd-* *.dll *.lib *.$(SUFFIX) *.dwf $(LIBPREFIX).$(LIBSUFFIX) $(LIBPREFIX)_p.$(LIBSUFFIX) $(LIBPREFIX).so.$(MAJOR_VERSION) *.lnk myconfig.h *.so.renamed *.a.renamed *.so.0 ifeq ($(OSNAME), Darwin) @rm -rf getarch.dSYM getarch_2nd.dSYM endif - @rm -f Makefile.conf config.h Makefile_kernel.conf config_kernel.h st* *.dylib + @rm -f Makefile.conf config.h Makefile_kernel*.conf config_kernel*.h st* *.dylib @rm -f cblas.tmp cblas.tmp2 @touch $(NETLIB_LAPACK_DIR)/make.inc @$(MAKE) -C $(NETLIB_LAPACK_DIR) clean diff --git a/Makefile.prebuild b/Makefile.prebuild index 399db956f..c9eb8e03d 100644 --- a/Makefile.prebuild +++ b/Makefile.prebuild @@ -8,11 +8,19 @@ override HOST_CFLAGS += -DDYNAMIC_ARCH endif ifdef TARGET_CORE +ifdef DYNAMIC_ARCH +TARGET_MAKE = Makefile_kernel_$(TARGET_CORE).conf +TARGET_CONF = config_kernel_$(TARGET_CORE).h +GETARCH_FLAVOR = -$(TARGET_CORE) +else TARGET_MAKE = Makefile_kernel.conf TARGET_CONF = config_kernel.h +GETARCH_FLAVOR = -$(TARGET_CORE) +endif else TARGET_MAKE = Makefile.conf TARGET_CONF = config.h +GETARCH_FLAVOR = endif # CPUIDEMU = ../../cpuid/table.o @@ -49,11 +57,11 @@ ifeq ($(TARGET), C910V) TARGET_FLAGS = -march=rv64gcvxthead -mabi=lp64v endif -all: getarch_2nd - ./getarch_2nd 0 >> $(TARGET_MAKE) - ./getarch_2nd 1 >> $(TARGET_CONF) +all: getarch_2nd$(GETARCH_FLAVOR) + ./getarch_2nd$(GETARCH_FLAVOR) 0 >> $(TARGET_MAKE) + ./getarch_2nd$(GETARCH_FLAVOR) 1 >> $(TARGET_CONF) -config.h : c_check f_check getarch +config.h : c_check f_check getarch$(GETARCH_FLAVOR) perl ./c_check $(TARGET_MAKE) $(TARGET_CONF) $(CC) $(TARGET_FLAGS) $(CFLAGS) ifneq ($(ONLY_CBLAS), 1) perl ./f_check $(TARGET_MAKE) $(TARGET_CONF) $(FC) $(TARGET_FLAGS) @@ -66,18 +74,18 @@ else echo "#define BUNDERSCORE _" >> $(TARGET_CONF) echo "#define NEEDBUNDERSCORE 1" >> $(TARGET_CONF) endif - ./getarch 0 >> $(TARGET_MAKE) - ./getarch 1 >> $(TARGET_CONF) + ./getarch$(GETARCH_FLAVOR) 0 >> $(TARGET_MAKE) + ./getarch$(GETARCH_FLAVOR) 1 >> $(TARGET_CONF) -getarch : getarch.c cpuid.S dummy $(CPUIDEMU) +getarch$(GETARCH_FLAVOR) : getarch.c cpuid.S dummy $(CPUIDEMU) $(HOSTCC) $(HOST_CFLAGS) $(EXFLAGS) -o $(@F) getarch.c cpuid.S $(CPUIDEMU) -getarch_2nd : getarch_2nd.c config.h dummy +getarch_2nd$(GETARCH_FLAVOR) : getarch_2nd.c config.h dummy ifndef TARGET_CORE $(HOSTCC) -I. $(HOST_CFLAGS) -o $(@F) getarch_2nd.c else - $(HOSTCC) -I. $(HOST_CFLAGS) -DBUILD_KERNEL -o $(@F) getarch_2nd.c + $(HOSTCC) -I. $(HOST_CFLAGS) -DBUILD_KERNEL -DKERNEL_CONFIG=\"$(TARGET_CONF)\" -o $(@F) getarch_2nd.c endif dummy: diff --git a/Makefile.system b/Makefile.system index 438a8148a..ff15b6400 100644 --- a/Makefile.system +++ b/Makefile.system @@ -298,8 +298,12 @@ HAVE_SSE5= HAVE_AVX= HAVE_AVX2= HAVE_FMA3= +ifeq ($(DYNAMIC_ARCH), 1) +include $(TOPDIR)/Makefile_kernel_$(TARGET_CORE).conf +else include $(TOPDIR)/Makefile_kernel.conf endif +endif endif diff --git a/cmake/prebuild.cmake b/cmake/prebuild.cmake index 4ef0ce93a..2f5d47229 100644 --- a/cmake/prebuild.cmake +++ b/cmake/prebuild.cmake @@ -629,7 +629,11 @@ else(NOT CMAKE_CROSSCOMPILING) endif () set(GETARCH_DIR "${PROJECT_BINARY_DIR}/getarch_build") - set(GETARCH_BIN "getarch${CMAKE_EXECUTABLE_SUFFIX}") + if (DEFINED TARGET_CORE) + set(GETARCH_BIN "getarch-${TARGET_CORE}${CMAKE_EXECUTABLE_SUFFIX}") + else () + set(GETARCH_BIN "getarch${CMAKE_EXECUTABLE_SUFFIX}") + endif () file(MAKE_DIRECTORY ${GETARCH_DIR}) configure_file(${TARGET_CONF_TEMP} ${GETARCH_DIR}/${TARGET_CONF} COPYONLY) if (NOT "${CMAKE_SYSTEM_NAME}" STREQUAL "WindowsStore") diff --git a/common.h b/common.h index 00d1d0baf..d563e3b0f 100644 --- a/common.h +++ b/common.h @@ -57,7 +57,11 @@ extern "C" { #endif #ifdef BUILD_KERNEL +#ifdef KERNEL_CONFIG +#include KERNEL_CONFIG +#else #include "config_kernel.h" +#endif #else #include "config.h" #endif diff --git a/getarch_2nd.c b/getarch_2nd.c index dd1f83089..2abeee696 100644 --- a/getarch_2nd.c +++ b/getarch_2nd.c @@ -2,8 +2,12 @@ #ifndef BUILD_KERNEL #include "config.h" #else +#ifdef KERNEL_CONFIG +#include KERNEL_CONFIG +#else #include "config_kernel.h" #endif +#endif #if (defined(__WIN32__) || defined(__WIN64__) || defined(__CYGWIN32__) || defined(__CYGWIN64__) || defined(_WIN32) || defined(_WIN64)) && defined(__64BIT__) typedef long long BLASLONG; typedef unsigned long long BLASULONG; diff --git a/kernel/Makefile b/kernel/Makefile index cbe4cde6e..94a718bbd 100644 --- a/kernel/Makefile +++ b/kernel/Makefile @@ -124,7 +124,7 @@ COMMONOBJS += lsame.$(SUFFIX) scabs1.$(SUFFIX) dcabs1.$(SUFFIX) ifeq ($(DYNAMIC_ARCH), 1) SBLASOBJS += setparam$(TSUFFIX).$(SUFFIX) -CCOMMON_OPT += -DTS=$(TSUFFIX) +CCOMMON_OPT += -DTS=$(TSUFFIX) -DKERNEL_CONFIG=\"config_kernel$(TSUFFIX).h\" endif KERNEL_INTERFACE = ../common_level1.h ../common_level2.h ../common_level3.h