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.
This commit is contained in:
Landon Curt Noll
2023-08-21 20:18:30 -07:00
parent 6abdd8ef3f
commit 2d5339fc51
4 changed files with 39 additions and 14 deletions

1
.gitignore vendored
View File

@@ -110,6 +110,7 @@ sample_many
sample_many-static sample_many-static
sample_rand sample_rand
sample_rand-static sample_rand-static
status.chk_c.h
tags tags
terminal.h terminal.h
ver_calc ver_calc

View File

@@ -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 Currently failure to compile cc_chk.c or c_chk exiting non-0
will just print "WARNING!!" strings to stderr. 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: The following are the changes from calc version 2.14.3.4 to 2.14.3.5:

View File

@@ -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_ustat.h longbits.h terminal.h have_environ.h \
have_arc4random.h have_limits.h charbit.h have_sys_vfs.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_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 # 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}; \ ${TRUE}; \
fi 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 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
${V} echo '=-=-=-=-= ${MAKE_FILE} start of $@ rule =-=-=-=-=' ${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} \ -${Q} ${LCC} ${ICFLAGS} chk_c.c -c ${S} \
|| echo "WARNING!! failed to compile chk_c.c" 1>&2 || echo "WARNING!! failed to form the chk_c.o file." 1>&2
-${Q} ${LCC} ${ILDFLAGS} chk_c.o -o chk_c${EXT} ${S} \ -${Q} ${LCC} ${ILDFLAGS} chk_c.o -o $@ ${S} \
|| echo "WARNING!! failed to form chk_c${EXT} executable" 1>&2 || echo "WARNING!! failed to link the $@ executable." 1>&2
-${Q}if [ ! -x chk_c${EXT} ]; then \ -${Q}if [ ! -x $@ ]; then \
echo "WARNING!! Your C compiler and/or C include does not meet calc requirements" 1>&2; \ 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 \ else \
echo "formed $@ executable"; \ echo "formed $@ executable"; \
echo 'about to run $@'; \ echo 'about to execute: ./$@'; \
if ! ./$@; then \ 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 \ 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; \
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 =-=-=-=-=' ${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 # These two .all rules are used to determine of the lower level

View File

@@ -327,7 +327,7 @@ main(int argc, char *argv[])
* All Done!! -- Jessica Noll, age 2 * All Done!! -- Jessica Noll, age 2
*/ */
if (c_flag == true) { 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); exit(0);
#endif /* HAVE_INTTYPES_H */ #endif /* HAVE_INTTYPES_H */