Skip to content

Commit

Permalink
Don't build+use wart if the target arch is incompatible
Browse files Browse the repository at this point in the history
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
  • Loading branch information
davidrg committed Feb 15, 2024
1 parent 5ef2a15 commit 83def61
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 5 deletions.
34 changes: 29 additions & 5 deletions kermit/k95/ckoker.mak
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand All @@ -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
Expand Down
33 changes: 33 additions & 0 deletions kermit/k95/compiler_detect.mak
Original file line number Diff line number Diff line change
Expand Up @@ -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
26 changes: 26 additions & 0 deletions kermit/k95/feature_flags.mak
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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.
#
Expand Down

0 comments on commit 83def61

Please sign in to comment.