From 83def6101a917d4c5fb0cc451e8af8699dfbaa40 Mon Sep 17 00:00:00 2001 From: David Goodwin Date: Fri, 16 Feb 2024 12:36:20 +1300 Subject: [PATCH] Don't build+use wart if the target arch is incompatible If the target CPU architecture is incompatible with the host, don't try to build and use wart to generate ckcpro.c from ckcpro.w - either rely on ckcpro.c already being up-to-date or the user supplying a compatible wart and setting WART and CKB_USE_WART=yes --- kermit/k95/ckoker.mak | 34 +++++++++++++++++++++++++++++----- kermit/k95/compiler_detect.mak | 33 +++++++++++++++++++++++++++++++++ kermit/k95/feature_flags.mak | 26 ++++++++++++++++++++++++++ 3 files changed, 88 insertions(+), 5 deletions(-) diff --git a/kermit/k95/ckoker.mak b/kermit/k95/ckoker.mak index 8e695c4f..849dfa9f 100644 --- a/kermit/k95/ckoker.mak +++ b/kermit/k95/ckoker.mak @@ -137,6 +137,15 @@ CL = wcl386 !message Platform: $(PLATFORM) !message Build: $(K95BUILD) !message Architecture: $(TARGET_CPU) +!if "$(CROSS_BUILD)" == "yes" +!if "$(CROSS_BUILD_COMPATIBLE)" == "yes" +!message Host Architecture: $(HOST_CPU) (cross-compiling to compatible architecture) +!else +!message Host Architecture: $(HOST_CPU) (cross-compiling) +!endif +!else +!message Host Architecture: $(HOST_CPU) +!endif !message Compiler: $(COMPILER) !message Compiler Version: $(COMPILER_VERSION) !message Compiler Target Platform: $(TARGET_PLATFORM) @@ -1103,9 +1112,6 @@ k2crypt.dll: ck_crp.obj ck_des.obj ckclib.obj k2crypt.def ckoker.mak /out:$@ ck_crp.obj ck_des.obj ckclib.obj libdes.lib dllrname $@ CPPRMI36=CKO32RTL -ckwart.exe: ckwart.obj $(DEF) - $(CC) ckwart.obj - docs: ckermit.inf # ckotel.def @@ -1358,12 +1364,32 @@ p_tl$(O): ckcdeb.h ckoker.h ckclib.h ckocon.h p_tl.c p_type.h p_tl.h p_ p_omalloc$(O): ckcdeb.h ckoker.h ckclib.h p_omalloc.c p_type.h p_error.h p.h !endif +# We're not always able to build and use WART so only do it if we're told to. +!if "$(CKB_BUILD_WART)" == "yes" ckcpro.c: ckcpro.w ckwart.exe # $(MAKE) -f ckoker.mak ckwart.exe \ # CC="$(CC) $(CC2)" OUT="$(OUT)" O="$(O)" OPT="$(OPT)" \ # DEBUG="$(DEBUG)" CFLAGS="-DCK_ANSIC $(CFLAGS)" LDFLAGS="$(LDFLAGS)" ckwart ckcpro.w ckcpro.c +ckwart$(O): ckwart.c + $(CC) -c ckwart.c + + +ckwart.exe: ckwart.obj $(DEF) + $(CC) ckwart.obj + +!elseif "$(CKB_USE_WART)" == "yes" + +!if "$(WART)" == "" +WART=ckwart +!endif + +ckcpro.c: ckcpro.w + $(WART) ckcpro.w ckcpro.c + +!endif + ckopcf$(O): ckopcf.c ckopcf.h $(CC) $(CC2) $(CFLAGS) $(DEBUG) $(OPT) $(DLL) -c ckopcf.c @@ -1373,8 +1399,6 @@ ckotel$(O): ckotel.c ckoclip$(O): ckoclip.c $(CC) $(CC2) $(CFLAGS) $(DEBUG) $(OPT) /Gn- -c ckoclip.c -ckwart$(O): ckwart.c - $(CC) -c ckwart.c #cko32rt$(O): cko32rt.c # /Gd+ /Ge- $(DLL) -c cko32rt.c diff --git a/kermit/k95/compiler_detect.mak b/kermit/k95/compiler_detect.mak index 62ce7e50..56f8fc31 100644 --- a/kermit/k95/compiler_detect.mak +++ b/kermit/k95/compiler_detect.mak @@ -287,4 +287,37 @@ TARGET_CPU = x86 !ENDIF +# Figure out the host CPU Architecture +HOST_CPU = $(PROCESSOR_ARCHITECTURE) +!if "$(HOST_CPU)" == "AMD64" +HOST_CPU = x86-64 +!endif + +# And if we're cross-compiling from a CPU architecture +# other than the target. +CROSS_BUILD = no +!if "$(HOST_CPU)" != "$(TARGET_CPU)" +CROSS_BUILD = yes +!endif + +# And if we're cross-compiling, can we +CROSS_BUILD_COMPATIBLE = yes +!if "$(CROSS_BUILD)" == "yes" +# We're cross-compiling. + +!if "$(HOST_CPU)" == "x86-64" && "$(TARGET_CPU)" == "x86" +CROSS_BUILD_COMPATIBLE = yes + +!elseif "$(HOST_CPU)" == "ARM64" && "$(TARGET_CPU)" == "ARM" +# TODO: Is this actually true? Do the compilers even run on these architectures? +CROSS_BUILD_COMPATIBLE = yes + +!else +# x86 can't run x86-64 code for example. +CROSS_BUILD_COMPATIBLE = no + +!endif + +!endif + !endif \ No newline at end of file diff --git a/kermit/k95/feature_flags.mak b/kermit/k95/feature_flags.mak index d9c4daee..67d8771c 100644 --- a/kermit/k95/feature_flags.mak +++ b/kermit/k95/feature_flags.mak @@ -188,6 +188,9 @@ CKF_XYZ=no CKF_SRP=no # TODO: Figure out SRP support on OS/2 with OpenWatcom +!message Turning Kerberos off - no Watcom support yet. +CKF_K4W=no + !endif !if "$(CKF_SSH)" == "yes" @@ -224,6 +227,29 @@ CKF_DECNET=yes CKF_DECNET=no !endif +# Build and use wart to generate ckcpro.c from ckcpro.w unless we're told +# not to +!if "$(CKB_BUILD_WART)" != "no" +CKB_BUILD_WART=yes +!endif + +# ... or unless we're targeting a CPU architecture incompatible with that of +# the host machine. +!if "$(CROSS_BUILD_COMPATIBLE)" == "no" +!message Forcing build of WART off - target CPU architecture is incompatible +!message with host architecture. To generate ckcpro.c from ckcpro.w, supply +!message a version of ckwart.exe compatible with the host architecture and +!message set CKB_USE_WART=yes +CKB_BUILD_WART=no +!endif + +!if "$(CBK_BUILD_WART)" == "yes" +CKB_USE_WART=yes +WART=ckwart +!endif + + + # Other features that should one day be turned on via feature flags once we # figure out how to build them and get any dependencies sorted out. #