mirror of
https://github.com/lcn2/calc.git
synced 2025-08-19 01:13:27 +03:00
add C compiler and C include checks for calc
Fixed have_statfs optional executable file extension ${EXT{ in the ${UTIL_PROGS} make variable. Prevented the "fake boolean value" when <stdbool.h> is missing, from complicating C compilers post c17 standard. Test if <stdint.h> exists and set HAVE_STDINT_H accordingly in have_stdint.h. Added HAVE_STDINT_H to allow one to force this value. Test if <inttypes.h> exists and set HAVE_INTTYPES_H accordingly in have_inttypes.h. Added HAVE_INTTYPES_H to allow one to force this value. Added c_chk.c to check the compiler and C include for calc requirements. If you are unable to compile this program, or if this program when compiles does not exit 0, then your C compiler and/or C include fails to meet calc requirements. Compilers that are at least c99 MUST be able to compile this program such that when run will exit 0. The "make hsrc" file will attempt to compile and run c_chk and will warn if the C compiler and/or C include fails to meet calc requirements. The "make debug" system will run c_chk -c to print information about the C compiler and C include. Currently failure to compile cc_chk.c or c_chk exiting non-0 will just print "WARNING!!" strings to stderr.
This commit is contained in:
126
Makefile
126
Makefile
@@ -179,7 +179,8 @@ BUILD_H_SRC= align32.h args.h calcerr.h conf.h endian_calc.h \
|
||||
have_uid_t.h have_unistd.h have_unused.h have_urandom.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_sys_param.h have_sys_mount.h have_statfs.h have_stdbool.h \
|
||||
have_stdint.h
|
||||
|
||||
# we build these .c files during the make
|
||||
#
|
||||
@@ -195,7 +196,7 @@ UTIL_C_SRC= align32.c endian.c longbits.c have_newstr.c have_uid_t.c \
|
||||
have_ustat.c have_getsid.c have_getpgid.c have_environ.c \
|
||||
have_gettime.c have_getprid.c have_rusage.c have_strdup.c \
|
||||
have_unused.c have_ban_pragma.c have_strlcpy.c have_strlcat.c \
|
||||
have_arc4random.c charbit.c have_statfs.c
|
||||
have_arc4random.c charbit.c have_statfs.c chk_c.c
|
||||
|
||||
# these awk and sed tools are used in the process of building BUILD_H_SRC
|
||||
# and BUILD_C_SRC
|
||||
@@ -213,7 +214,7 @@ UTIL_OBJS= endian.o longbits.o have_newstr.o have_uid_t.o \
|
||||
have_ustat.o have_getsid.o have_getpgid.o have_environ.o \
|
||||
have_gettime.o have_getprid.o ver_calc.o have_rusage.o have_strdup.o \
|
||||
have_unused.o have_ban_pragma.o have_strlcpy.o have_strlcat.o \
|
||||
have_arc4random.o charbit.o have_statfs.o
|
||||
have_arc4random.o charbit.o have_statfs.o chk_c.o
|
||||
|
||||
# these temp files may be created (and removed) during the build of BUILD_C_SRC
|
||||
#
|
||||
@@ -232,7 +233,7 @@ UTIL_PROGS= align32${EXT} fposval${EXT} have_uid_t${EXT} have_const${EXT} \
|
||||
have_unused${EXT} have_fpos${EXT} have_fpos_pos${EXT} \
|
||||
have_offscl${EXT} have_rusage${EXT} have_ban_pragma${EXT} \
|
||||
have_strlcpy${EXT} have_strlcat${EXT} have_arc4random${EXT} \
|
||||
charbit${EXT} have_statfs${ENT}
|
||||
charbit${EXT} have_statfs${EXT} chk_c${EXT}
|
||||
|
||||
# these utility files and scripts may be created in the process of building
|
||||
# the BUILD_H_SRC file set
|
||||
@@ -569,7 +570,7 @@ file.o: file.c ${MK_SET}
|
||||
#
|
||||
###
|
||||
|
||||
hsrc: ${BUILD_H_SRC} ${BUILD_C_SRC}
|
||||
hsrc: ${BUILD_H_SRC} ${BUILD_C_SRC} chk_c${EXT}
|
||||
|
||||
.hsrc: ${BUILD_H_SRC} ${BUILD_C_SRC}
|
||||
${Q} ${RM} -f .hsrc
|
||||
@@ -962,6 +963,78 @@ have_stdbool.h: ${MK_SET}
|
||||
${TRUE}; \
|
||||
fi
|
||||
|
||||
have_stdint.h: ${MK_SET}
|
||||
${Q} ${RM} -f $@
|
||||
${H} echo 'forming $@'
|
||||
${Q} echo '/*' > $@
|
||||
${Q} echo ' * DO NOT EDIT -- generated by the Makefile rule $@' >> $@
|
||||
${Q} echo ' */' >> $@
|
||||
${Q} echo '' >> $@
|
||||
${Q} echo '' >> $@
|
||||
${Q} echo '#if !defined(CALC_HAVE_STDINT_H)' >> $@
|
||||
${Q} echo '#define CALC_HAVE_STDINT_H' >> $@
|
||||
${Q} echo '' >> $@
|
||||
${Q} echo '' >> $@
|
||||
${Q} echo '/* do we have <stdint.h>? */' >> $@
|
||||
-${Q} if [ X"${HAVE_STDINT_H}" = X"YES" ]; then \
|
||||
echo '#define HAVE_STDINT_H /* yes */' >> $@; \
|
||||
elif [ X"${HAVE_STDINT_H}" = X"NO" ]; then \
|
||||
echo '#undef HAVE_STDINT_H /* no */' >> $@; \
|
||||
elif echo '#include <stdint.h>' | ${CC} -E - ${S}; then \
|
||||
echo '#define HAVE_STDINT_H /* yes */' >> $@; \
|
||||
else \
|
||||
echo '#undef HAVE_STDINT_H /* no */' >> $@; \
|
||||
fi
|
||||
${Q} echo '' >> $@
|
||||
${Q} echo '' >> $@
|
||||
${Q} echo '#endif /* !CALC_HAVE_STDINT_H */' >> $@
|
||||
${H} echo '$@ formed'
|
||||
-@if [ -z "${Q}" ]; then \
|
||||
echo ''; \
|
||||
echo '=-=-= start of $@ =-=-='; \
|
||||
${CAT} $@; \
|
||||
echo '=-=-= end of $@ =-=-='; \
|
||||
echo ''; \
|
||||
else \
|
||||
${TRUE}; \
|
||||
fi
|
||||
|
||||
have_inttypes.h: ${MK_SET}
|
||||
${Q} ${RM} -f $@
|
||||
${H} echo 'forming $@'
|
||||
${Q} echo '/*' > $@
|
||||
${Q} echo ' * DO NOT EDIT -- generated by the Makefile rule $@' >> $@
|
||||
${Q} echo ' */' >> $@
|
||||
${Q} echo '' >> $@
|
||||
${Q} echo '' >> $@
|
||||
${Q} echo '#if !defined(CALC_HAVE_INTTYPES_H)' >> $@
|
||||
${Q} echo '#define CALC_HAVE_INTTYPES_H' >> $@
|
||||
${Q} echo '' >> $@
|
||||
${Q} echo '' >> $@
|
||||
${Q} echo '/* do we have <inttypes.h>? */' >> $@
|
||||
-${Q} if [ X"${HAVE_INTTYPES_H}" = X"YES" ]; then \
|
||||
echo '#define HAVE_INTTYPES_H /* yes */' >> $@; \
|
||||
elif [ X"${HAVE_INTTYPES_H}" = X"NO" ]; then \
|
||||
echo '#undef HAVE_INTTYPES_H /* no */' >> $@; \
|
||||
elif echo '#include <inttypes.h>' | ${CC} -E - ${S}; then \
|
||||
echo '#define HAVE_INTTYPES_H /* yes */' >> $@; \
|
||||
else \
|
||||
echo '#undef HAVE_INTTYPES_H /* no */' >> $@; \
|
||||
fi
|
||||
${Q} echo '' >> $@
|
||||
${Q} echo '' >> $@
|
||||
${Q} echo '#endif /* !CALC_HAVE_INTTYPES_H */' >> $@
|
||||
${H} echo '$@ formed'
|
||||
-@if [ -z "${Q}" ]; then \
|
||||
echo ''; \
|
||||
echo '=-=-= start of $@ =-=-='; \
|
||||
${CAT} $@; \
|
||||
echo '=-=-= end of $@ =-=-='; \
|
||||
echo ''; \
|
||||
else \
|
||||
${TRUE}; \
|
||||
fi
|
||||
|
||||
have_string.h: ${MK_SET}
|
||||
${Q} ${RM} -f $@
|
||||
${H} echo 'forming $@'
|
||||
@@ -2313,6 +2386,26 @@ have_strlcat.h: have_strlcat.c banned.h have_ban_pragma.h have_string.h \
|
||||
${TRUE}; \
|
||||
fi
|
||||
|
||||
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 =-=-=-=-='
|
||||
${Q} ${RM} -f chk_c.o chk_c${EXT}
|
||||
-${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; \
|
||||
else \
|
||||
echo "formed $@ executable"; \
|
||||
echo 'about to run $@'; \
|
||||
if ! ./$@; then \
|
||||
echo "WARNING!! $@ failed to validate C compiler and/or C include for calc requirements" 1>&2; \
|
||||
else \
|
||||
echo "Good news everyone! :-) The C compiler and C include appears to meet calc requirements" 1>&2; \
|
||||
fi; \
|
||||
fi
|
||||
${V} echo '=-=-=-=-= ${MAKE_FILE} end of $@ rule =-=-=-=-='
|
||||
|
||||
###
|
||||
#
|
||||
# These two .all rules are used to determine of the lower level
|
||||
@@ -2780,6 +2873,7 @@ env:
|
||||
@echo 'HAVE_GETRUSAGE=${HAVE_GETRUSAGE}'; echo ''
|
||||
@echo 'HAVE_GETSID=${HAVE_GETSID}'; echo ''
|
||||
@echo 'HAVE_GETTIME=${HAVE_GETTIME}'; echo ''
|
||||
@echo 'HAVE_INTTYPES_H=${HAVE_INTTYPES_H}'; echo ''
|
||||
@echo 'HAVE_LIMITS_H=${HAVE_LIMITS_H}'; echo ''
|
||||
@echo 'HAVE_MEMMOVE=${HAVE_MEMMOVE}'; echo ''
|
||||
@echo 'HAVE_NEWSTR=${HAVE_NEWSTR}'; echo ''
|
||||
@@ -2788,6 +2882,7 @@ env:
|
||||
@echo 'HAVE_PRAGMA_GCC_POSION=${HAVE_PRAGMA_GCC_POSION}'; echo ''
|
||||
@echo 'HAVE_STATFS=${HAVE_STATFS}'; echo ''
|
||||
@echo 'HAVE_STDBOOL_H=${HAVE_STDBOOL_H}'; echo ''
|
||||
@echo 'HAVE_STDINT_H=${HAVE_STDINT_H}'; echo ''
|
||||
@echo 'HAVE_STDLIB_H=${HAVE_STDLIB_H}'; echo ''
|
||||
@echo 'HAVE_STRDUP=${HAVE_STRDUP}'; echo ''
|
||||
@echo 'HAVE_STRING_H=${HAVE_STRING_H}'; echo ''
|
||||
@@ -2928,22 +3023,29 @@ full_debug: calcinfo env
|
||||
@echo '=-=-=-= Contents of ${TARGET_MKF} follows =-=-=-='
|
||||
-@${CAT} ${TARGET_MKF}
|
||||
@echo '=-=-=-= End of contents of ${TARGET_MKF} =-=-=-='
|
||||
@echo '=-=-=-= Invoking ${MAKE} -f Makefile Q= V=@ clobber =-=-=-='
|
||||
@echo '=-=-= Invoking ${MAKE} -f Makefile Q= V=@ clobber =-=-=-='
|
||||
-@${MAKE} -f Makefile Q= H=@ S= E= V=@ clobber
|
||||
@echo '=-=-=-= Back to the main Makefile for $@ rule =-=-=-='
|
||||
@echo '=-=-=-= Invoking ${MAKE} -f Makefile Q= V=@ all =-=-=-='
|
||||
@echo '=-=-= Invoking ${MAKE} -f Makefile Q= V=@ all =-=-=-='
|
||||
@echo '=-=-= this may take a bit of time =-=-='
|
||||
-@${MAKE} -f Makefile Q= H=@ S= E= V=@ all
|
||||
@echo '=-=-=-= Back to the main Makefile for $@ rule =-=-=-='
|
||||
@echo '=-=-=-= Determining C compiler and C enviroment compatibility =-=-=-='
|
||||
@echo '=-=-= Invoking ${MAKE} -f Makefile Q= V=@ chk_c${EXT} =-=-=-='
|
||||
-@${MAKE} -f Makefile Q= H=@ S= E= V=@ chk_c${EXT}
|
||||
@echo '=-=-= Executing chk_c${EXT} -c =-=-=-='
|
||||
-@./chk_c${EXT} -c
|
||||
@echo '=-=-=-= Back to the main Makefile for $@ rule =-=-=-='
|
||||
@echo '=-=-=-= Determining the source version =-=-=-='
|
||||
@echo '=-=-= Invoking ${MAKE} -f Makefile Q= H=@ S= E= V=@ ver_calc${EXT} =-=-=-='
|
||||
-@${MAKE} -f Makefile Q= H=@ S= E= V=@ ver_calc${EXT}
|
||||
-@./ver_calc${EXT}
|
||||
@echo '=-=-=-= Back to the main Makefile for $@ rule =-=-=-='
|
||||
-@${ECHON} '=-=-=-= Print #defile values if custom functions '
|
||||
-@${ECHON} '=-=-=-= Print #define values if custom functions '
|
||||
@echo 'are allowed =-=-=-='
|
||||
-@${CALC_ENV} ./calc${EXT} -e -q -C 'print custom("sysinfo", 2);'
|
||||
@echo '=-=-=-= Back to the main Makefile for $@ rule =-=-=-='
|
||||
@echo '=-=-=-= Invoking ${MAKE} -f Makefile Q= V=@ check =-=-=-='
|
||||
@echo '=-=-= Invoking ${MAKE} -f Makefile Q= V=@ check =-=-=-='
|
||||
@echo '=-=-= this may take a while =-=-='
|
||||
-@${MAKE} -f Makefile Q= V=@ check
|
||||
@echo '=-=-=-= Back to the main Makefile for $@ rule =-=-=-='
|
||||
@@ -4000,6 +4102,12 @@ charbit.o: banned.h
|
||||
charbit.o: charbit.c
|
||||
charbit.o: have_ban_pragma.h
|
||||
charbit.o: have_limits.h
|
||||
chk_c.o: banned.h
|
||||
chk_c.o: bool.h
|
||||
chk_c.o: chk_c.c
|
||||
chk_c.o: have_ban_pragma.h
|
||||
chk_c.o: have_stdint.h
|
||||
chk_c.o: have_stdlib.h
|
||||
codegen.o: alloc.h
|
||||
codegen.o: attribute.h
|
||||
codegen.o: banned.h
|
||||
|
Reference in New Issue
Block a user