Declare SHELL at makefile top, sort and fix standard tool list in Makefiles

This commit is contained in:
Landon Curt Noll
2021-03-06 22:09:10 -08:00
parent 55bc690cd1
commit de6474bf28
8 changed files with 171 additions and 71 deletions

View File

@@ -53,6 +53,11 @@
# calculator by David I. Bell with help/mods from others # calculator by David I. Bell with help/mods from others
# Makefile by Landon Curt Noll # Makefile by Landon Curt Noll
# our shell
#
SHELL= /bin/sh
# Try uname -s if the target was not already set on the make command line # Try uname -s if the target was not already set on the make command line
# #
ifeq ($(target),) ifeq ($(target),)
@@ -142,7 +147,6 @@ endif
# standard utilities used during make # standard utilities used during make
# #
SHELL= /bin/sh
MAKE= make MAKE= make
SED= sed SED= sed
GREP= egrep GREP= egrep

View File

@@ -48,6 +48,11 @@
# calculator by David I. Bell with help/mods from others # calculator by David I. Bell with help/mods from others
# Makefile by Landon Curt Noll # Makefile by Landon Curt Noll
# our shell
#
SHELL= /bin/sh
#if 0 /* start of skip for non-Gnu makefiles */ #if 0 /* start of skip for non-Gnu makefiles */
############################################################################## ##############################################################################
#-=-=-=-=-=-=-=-=- Identify the target machine, if possible -=-=-=-=-=-=-=-=-# #-=-=-=-=-=-=-=-=- Identify the target machine, if possible -=-=-=-=-=-=-=-=-#
@@ -1062,7 +1067,6 @@ LIB_EXT_VERSION= ${LIB_EXT}.${VERSION}
# standard utilities used during make # standard utilities used during make
# #
SHELL= /bin/sh
AR= ar AR= ar
AWK= awk AWK= awk
CAT= cat CAT= cat
@@ -4297,7 +4301,7 @@ debug: calcinfo env
@${MAKE} -f Makefile Q= V=@ ver_calc${EXT} @${MAKE} -f Makefile Q= V=@ ver_calc${EXT}
-@./ver_calc${EXT} -@./ver_calc${EXT}
@echo '=-=-=-= Back to the main Makefile for $@ rule =-=-=-=' @echo '=-=-=-= Back to the main Makefile for $@ rule =-=-=-='
@echo -n '=-=-=-= Print #defile values if custom functions ' @/bin/echo -n '=-=-=-= Print #defile values if custom functions '
@echo 'are allowed =-=-=-=' @echo 'are allowed =-=-=-='
-@${CALC_ENV} ./calc${EXT} -e -q -C 'print custom("sysinfo", 2);' -@${CALC_ENV} ./calc${EXT} -e -q -C 'print custom("sysinfo", 2);'
@echo '=-=-=-= Back to the main Makefile for $@ rule =-=-=-=' @echo '=-=-=-= Back to the main Makefile for $@ rule =-=-=-='
@@ -4899,7 +4903,7 @@ uninstall: custom/Makefile
-${Q} if [ -f "${T}${LIBDIR}/libcalc${LIB_EXT_VERSION}" ]; then \ -${Q} if [ -f "${T}${LIBDIR}/libcalc${LIB_EXT_VERSION}" ]; then \
${RM} -f "${T}${LIBDIR}/libcalc${LIB_EXT_VERSION}"; \ ${RM} -f "${T}${LIBDIR}/libcalc${LIB_EXT_VERSION}"; \
if [ -f "${T}${LIBDIR}/libcalc${LIB_EXT_VERSION}" ]; then \ if [ -f "${T}${LIBDIR}/libcalc${LIB_EXT_VERSION}" ]; then \
echo -n "cannot uninstall " \ /bin/echo -n "cannot uninstall " \
echo "${T}${LIBDIR}/libcalc${LIB_EXT_VERSION}"; \ echo "${T}${LIBDIR}/libcalc${LIB_EXT_VERSION}"; \
else \ else \
echo "uninstalled ${T}${LIBDIR}/libcalc${LIB_EXT_VERSION}"; \ echo "uninstalled ${T}${LIBDIR}/libcalc${LIB_EXT_VERSION}"; \
@@ -5021,7 +5025,7 @@ calc-symlink:
if [ ! -L "${CATDIR}/calc.${CATEXT}" -a \ if [ ! -L "${CATDIR}/calc.${CATEXT}" -a \
"${T}${CATDIR}/calc.${CATEXT}" -ef \ "${T}${CATDIR}/calc.${CATEXT}" -ef \
"${CATDIR}/calc.${CATEXT}" ]; then \ "${CATDIR}/calc.${CATEXT}" ]; then \
echo -n "ERROR: ${T}${CATDIR}/calc.${CATEXT}" 2>&1; \ /bin/echo -n "ERROR: ${T}${CATDIR}/calc.${CATEXT}" 2>&1; \
echo "is the same as ${CATDIR}/calc.${CATEXT}" 1>&2; \ echo "is the same as ${CATDIR}/calc.${CATEXT}" 1>&2; \
else \ else \
if [ -e "${CATDIR}/calc.${CATEXT}" ]; then \ if [ -e "${CATDIR}/calc.${CATEXT}" ]; then \

82
banned.h Normal file
View File

@@ -0,0 +1,82 @@
/*
* banned - indicate which functions are banned in calc source
*
* inspired by https://github.com/git/git/blob/master/banned.h
*
* Copyright (C) 2021 Landon Curt Noll
*
* Calc is open software; you can redistribute it and/or modify it under
* the terms of the version 2.1 of the GNU Lesser General Public License
* as published by the Free Software Foundation.
*
* Calc is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
* Public License for more details.
*
* A copy of version 2.1 of the GNU Lesser General Public License is
* distributed with calc under the filename COPYING-LGPL. You should have
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Under source code control: 2021/03/06 21:07:31
* File existed as early as: 2021
*
* chongo <was here> /\oo/\ http://www.isthe.com/chongo/
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
*/
#if !defined(INCLUDE_BANNED_H)
#define INCLUDE_BANNED_H
#include "have_stdlib.h"
#ifdef HAVE_STDLIB_H
# include <stdlib.h>
#endif
/*
* From: //github.com/git/git/blob/master/banned.h
*
* This header lists functions that have been banned from our code base,
* because they're too easy to misuse (and even if used correctly,
* complicate audits). Including this header turns them into compile-time
* errors.
*/
#define BANNED(func,better) sorry_##func##_is_a_banned_function_use_##better##_instead
#undef strcpy
#define strcpy(x,y) BANNED(strcpy,strlcpy)
#undef strcat
#define strcat(x,y) BANNED(strcat,strlcat)
#undef strncpy
#define strncpy(x,y,n) BANNED(strncpy,memccpy)
#undef strncat
#define strncat(x,y,n) BANNED(strncat,memccpy)
#if defined(STDARG)
#define sprintf(...) BANNED(sprintf,snprintf)
#define vsprintf(...) BANNED(vsprintf,vsnprintf)
#else /* STDARG */
#define sprintf(buf,fmt,arg) BANNED(sprintf,snprintf)
#define vsprintf(buf,fmt,arg) BANNED(vsprintf,vsnprintf)
#endif /* STDARG */
#if 0 /* the XYtimeZZY_s() c11 functions are not yet universal - so do not ban XYtimeZZY() just yet - XXX */
#undef gmtime
#define gmtime(t) BANNED(gmtime,gmtime_s)
#undef localtime
#define localtime(t) BANNED(localtime,localtime_s)
#undef ctime
#define ctime(t) BANNED(ctime,ctime_s)
#undef ctime_r
#define ctime_r(t, buf) BANNED(ctime_r,ctime_s)
#undef asctime
#define asctime(t) BANNED(asctime,asctime_s)
#undef asctime_r
#define asctime_r(t, buf) BANNED(asctime_r,asctime_s)
#endif /* XXX */
#endif /* !INCLUDE_BANNED_H */

View File

@@ -27,7 +27,8 @@
# calculator by David I. Bell with help/mods from others # calculator by David I. Bell with help/mods from others
# Makefile by Landon Curt Noll # Makefile by Landon Curt Noll
# required vars
# our shell
# #
SHELL= /bin/sh SHELL= /bin/sh
@@ -167,17 +168,17 @@ Q=@
# #
CHMOD= chmod CHMOD= chmod
CMP= cmp CMP= cmp
RM= rm
MKDIR= mkdir
RMDIR= rmdir
CP= cp
MV= mv
CO= co CO= co
TRUE= true CP= cp
TOUCH= touch FMT= fmt
MKDIR= mkdir
MV= mv
RM= rm
RMDIR= rmdir
SED= sed SED= sed
SORT= sort SORT= sort
FMT= fmt TOUCH= touch
TRUE= true
# The calc files to install # The calc files to install
# #

View File

@@ -27,7 +27,7 @@
# Makefile by Landon Curt Noll # Makefile by Landon Curt Noll
# required vars # our shell
# #
SHELL= /bin/sh SHELL= /bin/sh
@@ -165,18 +165,19 @@ Q=@
# standard tools # standard tools
# #
CAT= cat
CHMOD= chmod CHMOD= chmod
CMP= cmp
CO= co
CP= cp
FMT= fmt
MKDIR= mkdir
MV= mv
RM= rm
RMDIR= rmdir
SED= sed SED= sed
SORT= sort SORT= sort
FMT= fmt
CMP= cmp
MKDIR= mkdir
RMDIR= rmdir
RM= rm
TOUCH= touch TOUCH= touch
MV= mv
CP= cp
CO= co
TRUE= true TRUE= true
# The ${SCRIPT} list is the list of calc shell script files (without the .calc # The ${SCRIPT} list is the list of calc shell script files (without the .calc
@@ -312,7 +313,7 @@ depend:
if [ X"$$i" != X"/dev/null" ]; then \ if [ X"$$i" != X"/dev/null" ]; then \
echo "$$i: $$i.calc"; \ echo "$$i: $$i.calc"; \
echo ' @$${RM} -f $$@'; \ echo ' @$${RM} -f $$@'; \
echo -n ' @$${SED} -e "1s:^#!/usr/local/src/bin/'; \ /bin/echo -n ' @$${SED} -e "1s:^#!/usr/local/src/bin/'; \
echo 'calc/calc:#!$${BINDIR}/calc:" $$?>$$@'; \ echo 'calc/calc:#!$${BINDIR}/calc:" $$?>$$@'; \
echo ' @$${CHMOD} +x $$@'; \ echo ' @$${CHMOD} +x $$@'; \
fi; \ fi; \

View File

@@ -27,6 +27,11 @@
# calculator by David I. Bell with help/mods from others # calculator by David I. Bell with help/mods from others
# Makefile by Landon Curt Noll # Makefile by Landon Curt Noll
# our shell
#
SHELL= /bin/sh
#if 0 /* start of skip for non-Gnu makefiles */ #if 0 /* start of skip for non-Gnu makefiles */
############################################################################## ##############################################################################
#-=-=-=-=-=-=-=-=- Identify the target machine, if possible -=-=-=-=-=-=-=-=-# #-=-=-=-=-=-=-=-=- Identify the target machine, if possible -=-=-=-=-=-=-=-=-#
@@ -357,26 +362,25 @@ LIB_EXT_VERSION= ${LIB_EXT}.${VERSION}
# standard tools # standard tools
# #
SHELL= /bin/sh
SED= sed
MAKEDEPEND= makedepend
GREP= egrep
CHMOD= chmod
FMT= fmt
SORT= sort
CMP= cmp
AR= ar AR= ar
RM= rm
TOUCH= touch
MKDIR= mkdir
RMDIR= rmdir
MV= mv
CP= cp
CO= co
TRUE= true
MAKE= make
LN= ln
AWK= awk AWK= awk
CHMOD= chmod
CMP= cmp
CO= co
CP= cp
FMT= fmt
GREP= egrep
LN= ln
MAKE= make
MAKEDEPEND= makedepend
MKDIR= mkdir
MV= mv
RM= rm
RMDIR= rmdir
SED= sed
SORT= sort
TOUCH= touch
TRUE= true
# EXTRA_CFLAGS are flags given to ${CC} when compiling C files # EXTRA_CFLAGS are flags given to ${CC} when compiling C files
# EXTRA_LDFLAGS are flags given to ${CC} when linking progs # EXTRA_LDFLAGS are flags given to ${CC} when linking progs

View File

@@ -27,6 +27,11 @@
# calculator by David I. Bell with help/mods from others # calculator by David I. Bell with help/mods from others
# Makefile by Landon Curt Noll # Makefile by Landon Curt Noll
# our shell
#
SHELL= /bin/sh
#if 0 /* start of skip for non-Gnu makefiles */ #if 0 /* start of skip for non-Gnu makefiles */
############################################################################## ##############################################################################
#-=-=-=-=-=-=-=-=- Identify the target machine, if possible -=-=-=-=-=-=-=-=-# #-=-=-=-=-=-=-=-=- Identify the target machine, if possible -=-=-=-=-=-=-=-=-#
@@ -357,26 +362,25 @@ LIB_EXT_VERSION= ${LIB_EXT}.${VERSION}
# standard tools # standard tools
# #
SHELL= /bin/sh
SED= sed
MAKEDEPEND= makedepend
GREP= egrep
CHMOD= chmod
FMT= fmt
SORT= sort
CMP= cmp
AR= ar AR= ar
RM= rm
TOUCH= touch
MKDIR= mkdir
RMDIR= rmdir
MV= mv
CP= cp
CO= co
TRUE= true
MAKE= make
LN= ln
AWK= awk AWK= awk
CHMOD= chmod
CMP= cmp
CO= co
CP= cp
FMT= fmt
GREP= egrep
LN= ln
MAKE= make
MAKEDEPEND= makedepend
MKDIR= mkdir
MV= mv
RM= rm
RMDIR= rmdir
SED= sed
SORT= sort
TOUCH= touch
TRUE= true
# EXTRA_CFLAGS are flags given to ${CC} when compiling C files # EXTRA_CFLAGS are flags given to ${CC} when compiling C files
# EXTRA_LDFLAGS are flags given to ${CC} when linking progs # EXTRA_LDFLAGS are flags given to ${CC} when linking progs

View File

@@ -165,23 +165,23 @@ Q=@
# standard tools # standard tools
# #
LCC= cc CAT= cat
ICFLAGS=
ILDFLAGS=
GREP= egrep
CHMOD= chmod CHMOD= chmod
SED= sed
SORT= sort
FMT= fmt
CMP= cmp CMP= cmp
CP= cp CP= cp
MV= mv FMT= fmt
TRUE= true GREP= egrep
RM= rm ICFLAGS=
ILDFLAGS=
LCC= cc
MKDIR= mkdir MKDIR= mkdir
MV= mv
RM= rm
RMDIR= rmdir RMDIR= rmdir
SED= sed
SORT= sort
TOUCH= touch TOUCH= touch
CAT= cat TRUE= true
# Some out of date operating systems require / want an executable to # Some out of date operating systems require / want an executable to
# end with a certain file extension. Some compile systems such as # end with a certain file extension. Some compile systems such as