From 2d5339fc51498d43424a932981381a754f045703 Mon Sep 17 00:00:00 2001 From: Landon Curt Noll Date: Mon, 21 Aug 2023 20:18:30 -0700 Subject: [PATCH] update make chk_c rule to form status.chk_c.h The make chk_c file also forms status.chk_c.h which either defines CHK_C when the C compiler and select include files appear to meet calc requirements, or undefines CHK_C when it does not. --- .gitignore | 1 + CHANGES | 5 +++++ Makefile | 45 ++++++++++++++++++++++++++++++++------------- chk_c.c | 2 +- 4 files changed, 39 insertions(+), 14 deletions(-) diff --git a/.gitignore b/.gitignore index 15a5918..c147e78 100644 --- a/.gitignore +++ b/.gitignore @@ -110,6 +110,7 @@ sample_many sample_many-static sample_rand sample_rand-static +status.chk_c.h tags terminal.h ver_calc diff --git a/CHANGES b/CHANGES index a624dee..81a4d59 100644 --- a/CHANGES +++ b/CHANGES @@ -67,6 +67,11 @@ The following are the changes from calc version 2.14.3.5 to date: Currently failure to compile cc_chk.c or c_chk exiting non-0 will just print "WARNING!!" strings to stderr. + The make chk_c file also forms status.chk_c.h which either + defines CHK_C when the C compiler and select include files + appear to meet calc requirements, or undefines CHK_C + when it does not. + The following are the changes from calc version 2.14.3.4 to 2.14.3.5: diff --git a/Makefile b/Makefile index 1ac2641..0646d24 100644 --- a/Makefile +++ b/Makefile @@ -180,7 +180,7 @@ BUILD_H_SRC= align32.h args.h calcerr.h conf.h endian_calc.h \ have_ustat.h longbits.h terminal.h have_environ.h \ have_arc4random.h have_limits.h charbit.h have_sys_vfs.h \ have_sys_param.h have_sys_mount.h have_statfs.h have_stdbool.h \ - have_stdint.h + have_stdint.h status.chk_c.h # we build these .c files during the make # @@ -2386,28 +2386,47 @@ have_strlcat.h: have_strlcat.c banned.h have_ban_pragma.h have_string.h \ ${TRUE}; \ fi -bool.h: have_stdbool.h - -chk_c${EXT}: chk_c.c have_stdint.h have_inttypes.h have_stdlib.h bool.h have_ban_pragma.h banned.h +chk_c${EXT}: chk_c.c have_stdint.h have_inttypes.h have_stdlib.h bool.h have_ban_pragma.h banned.h have_stdbool.h ${V} echo '=-=-=-=-= ${MAKE_FILE} start of $@ rule =-=-=-=-=' - ${Q} ${RM} -f chk_c.o chk_c${EXT} + ${Q} ${RM} -f chk_c.o $@ status.chk_c.h + ${H} echo 'forming status.chk_c.h' + ${Q} echo '/*' > status.chk_c.h + ${Q} echo ' * DO NOT EDIT -- generated by the Makefile rule $@' >> status.chk_c.h + ${Q} echo ' */' >> status.chk_c.h + ${Q} echo '' >> status.chk_c.h + ${Q} echo '' >> status.chk_c.h + ${Q} echo '#if !defined(CALC_STATUS_CHK_C_H)' >> status.chk_c.h + ${Q} echo '#define CALC_STATUS_CHK_C_H' >> status.chk_c.h + ${Q} echo '' >> status.chk_c.h + ${Q} echo '' >> status.chk_c.h + ${Q} echo '/* Does the C compiler and select include files appear to meet calc requirements? */' >> status.chk_c.h -${Q} ${LCC} ${ICFLAGS} chk_c.c -c ${S} \ - || echo "WARNING!! failed to compile chk_c.c" 1>&2 - -${Q} ${LCC} ${ILDFLAGS} chk_c.o -o chk_c${EXT} ${S} \ - || echo "WARNING!! failed to form chk_c${EXT} executable" 1>&2 - -${Q}if [ ! -x chk_c${EXT} ]; then \ - echo "WARNING!! Your C compiler and/or C include does not meet calc requirements" 1>&2; \ + || echo "WARNING!! failed to form the chk_c.o file." 1>&2 + -${Q} ${LCC} ${ILDFLAGS} chk_c.o -o $@ ${S} \ + || echo "WARNING!! failed to link the $@ executable." 1>&2 + -${Q}if [ ! -x $@ ]; then \ + echo "WARNING!! Your C compiler and/or C include does not meet calc requirements." 1>&2; \ + echo "#undef CHK_C /* failed to form chk_c executable */" >> status.chk_c.h; \ else \ echo "formed $@ executable"; \ - echo 'about to run $@'; \ + echo 'about to execute: ./$@'; \ if ! ./$@; then \ - echo "WARNING!! $@ failed to validate C compiler and/or C include for calc requirements" 1>&2; \ + echo "WARNING!! ./$@ failed to validate C compiler and/or include files for calc requirements." 1>&2; \ + echo "#undef CHK_C /* chk_c failed to validate C compiler and/or include files */" >> status.chk_c.h; \ else \ - echo "Good news everyone! :-) The C compiler and C include appears to meet calc requirements" 1>&2; \ + echo "Good news everyone! :-)" \ + "The C compiler and select include files appear to meet calc requirements." 1>&2; \ + echo "#define CHK_C" \ + "/* C compiler and select include files appear to meet calc requirements */" >> status.chk_c.h; \ fi; \ fi + ${Q} echo '' >> status.chk_c.h + ${Q} echo '' >> status.chk_c.h + ${Q} echo '#endif /* !CALC_STATUS_CHK_C_H */' >> status.chk_c.h ${V} echo '=-=-=-=-= ${MAKE_FILE} end of $@ rule =-=-=-=-=' +status.chk_c.h: chk_c${EXT} + ### # # These two .all rules are used to determine of the lower level diff --git a/chk_c.c b/chk_c.c index 3177dab..9c54d6c 100644 --- a/chk_c.c +++ b/chk_c.c @@ -327,7 +327,7 @@ main(int argc, char *argv[]) * All Done!! -- Jessica Noll, age 2 */ if (c_flag == true) { - printf("\nC compiler and C include appears to support calc\n"); + printf("\nC compiler and select include files appear to support calc.\n"); } exit(0); #endif /* HAVE_INTTYPES_H */