bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] Makefile: avoid undefined variables


From: Grisha Levit
Subject: [PATCH] Makefile: avoid undefined variables
Date: Thu, 24 Oct 2024 15:07:46 -0400

These are reported by make --warn-undefined-variables.

Most were being set previously (sometimes 20 years ago) and got left
behind in recepies after their definitions have been removed. Others
only get set in some configurations so it makes sense to prevent them
from inheriting stray values from the environment otherwise. A few are
just typos.

This leaves only a couple warnings:
* BASH_MAKEFLAGS: not sure if still necessary after the MFLAGS removal?
* U: afaict something autoconf puts into LIBOBJS for ansi2knr, safe to
  ignore


Makefile.in
- ALLOC_FILES,GLOBC,GLOBO,LIBRARY_SOURCE: remove deprecated variables
- PROGRAM: correct to Program
- PURIFY: provide default (empty) definition
- GRAM_H: remove usage in HSOURCES prior to definition (should the
  definition be moved up instead?)

{builtins,support}/Makefile.in
- SYSTEM_FLAGS: remove legacy variable

lib/readline/Makefile.in
- APP_CFLAGS: remove unused variable

lib/sh/Makefile.in
- LIBOBJDIR: provide default (empty) value for use in LIBOBJS

{,builtins/,lib/{glob,readline,sh,tilde}/}Makefile.in
- ADDON_CFLAGS,ADDON_LDFLAGS: provide default (empty) value

lib/tilde/Makefile.in
- ASAN_CFLAGS: correct to ADDON_CFLAGS

{builtins,lib/sh}/Makefile.in
- DEBUG: let configure populate default value
---
 Makefile.in              | 24 ++++++++++++++----------
 builtins/Makefile.in     |  5 ++++-
 lib/glob/Makefile.in     |  1 +
 lib/readline/Makefile.in |  4 +++-
 lib/sh/Makefile.in       |  4 ++++
 lib/tilde/Makefile.in    |  5 +++--
 support/Makefile.in      |  2 +-
 7 files changed, 30 insertions(+), 15 deletions(-)

diff --git a/Makefile.in b/Makefile.in
index 4352eb00..a382eafd 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -97,7 +97,7 @@ TESTSCRIPT = @TESTSCRIPT@
 DEBUGGER_START_FILE = @DEBUGGER_START_FILE@
 
 #If you have purify, and want to use it, run the make as `make PURIFY=purify'
-#PURIFY = @PURIFY@
+PURIFY =
 
 # Here is a rule for making .o files from .c files that does not
 # force the type of the machine (like -M_MACHINE) into the flags.
@@ -155,6 +155,10 @@ SYSTEM_FLAGS = -DPROGRAM='"$(Program)"' 
-DCONF_HOSTTYPE='"$(Machine)"' -DCONF_OS
 BASE_CCFLAGS = $(SYSTEM_FLAGS) $(LOCAL_DEFS) \
          $(DEFS) $(LOCAL_CFLAGS) $(INCLUDES) $(STYLE_CFLAGS)
 
+# set by lint/sanitize targets
+ADDON_CFLAGS =
+ADDON_LDFLAGS =
+
 CCFLAGS = $(ADDON_CFLAGS) $(BASE_CCFLAGS) ${PROFILE_FLAGS} $(CPPFLAGS) 
$(CFLAGS)
 
 CCFLAGS_FOR_BUILD = $(BASE_CCFLAGS) $(CPPFLAGS_FOR_BUILD) $(CFLAGS_FOR_BUILD)
@@ -467,9 +471,9 @@ LIBRARY_LDFLAGS = $(READLINE_LDFLAGS) $(HISTORY_LDFLAGS) 
$(GLOB_LDFLAGS) \
 
 # The main source code for the Bourne Again SHell.
 CSOURCES = shell.c eval.c parse.y general.c make_cmd.c print_cmd.c y.tab.c \
-          dispose_cmd.c execute_cmd.c variables.c $(GLOBC) version.c \
+          dispose_cmd.c execute_cmd.c variables.c version.c \
           expr.c copy_cmd.c flags.c subst.c hashcmd.c hashlib.c mailcheck.c \
-          test.c trap.c alias.c jobs.c nojobs.c $(ALLOC_FILES) braces.c \
+          test.c trap.c alias.c jobs.c nojobs.c braces.c \
           input.c bashhist.c array.c arrayfunc.c assoc.c sig.c pathexp.c \
           unwind_prot.c siglist.c bashline.c bracecomp.c error.c \
           list.c stringlib.c locale.c findcmd.c redir.c \
@@ -477,7 +481,7 @@ CSOURCES = shell.c eval.c parse.y general.c make_cmd.c 
print_cmd.c y.tab.c \
 
 HSOURCES = shell.h flags.h trap.h hashcmd.h hashlib.h jobs.h builtins.h \
           general.h variables.h config.h $(ALLOC_HEADERS) alias.h \
-          quit.h unwind_prot.h syntax.h ${GRAM_H} \
+          quit.h unwind_prot.h syntax.h \
           command.h input.h error.h bashansi.h dispose_cmd.h make_cmd.h \
           subst.h externs.h siglist.h bashhist.h bashline.h bashtypes.h \
           array.h arrayfunc.h sig.h mailcheck.h bashintl.h bashjmp.h \
@@ -512,7 +516,7 @@ SIGNAMES_O = @SIGNAMES_O@
 ARRAY_O = @ARRAY_O@
 
 # Matching object files.
-OBJECTS         = shell.o eval.o y.tab.o general.o make_cmd.o print_cmd.o 
$(GLOBO) \
+OBJECTS         = shell.o eval.o y.tab.o general.o make_cmd.o print_cmd.o \
           dispose_cmd.o execute_cmd.o variables.o copy_cmd.o error.o \
           expr.o flags.o $(JOBS_O) subst.o hashcmd.o hashlib.o mailcheck.o \
           trap.o input.o unwind_prot.o pathexp.o sig.o test.o version.o \
@@ -676,7 +680,7 @@ lsan-tests: lsan  $(TESTS_SUPPORT)
        @( cd $(srcdir)/tests && \
                BUILD_DIR=$(BUILD_DIR) PATH=$(BUILD_DIR)/tests:$$PATH 
THIS_SH=$(THIS_SH) $(SHELL) ${TESTSCRIPT} )
 
-profiling-tests:       ${PROGRAM}
+profiling-tests:       ${Program}
        @test "X$$PROFILE_FLAGS" == "X" && { echo "profiling-tests: must be 
built with profiling enabled" >&2; exit 1; }
        @${MAKE} $(BASH_MAKEFLAGS) tests TESTSCRIPT=run-gprof
 
@@ -876,11 +880,11 @@ info dvi ps: force
 force:
 
 # unused
-TAGS:  $(SOURCES) $(BUILTIN_C_SRC) $(LIBRARY_SOURCE)
-       ( cd $(topdir) && $(ETAGS) $(ETAGSFLAGS) $(SOURCES) $(BUILTIN_C_SRC) 
$(LIBRARY_SOURCE) )
+TAGS:  $(SOURCES) $(BUILTIN_C_SRC)
+       ( cd $(topdir) && $(ETAGS) $(ETAGSFLAGS) $(SOURCES) $(BUILTIN_C_SRC) )
 
-tags:  $(SOURCES) $(BUILTIN_C_SRC) $(LIBRARY_SOURCE)
-       ( cd $(topdir) && $(CTAGS) $(CTAGSFLAGS) $(SOURCES) $(BUILTIN_C_SRC) 
$(LIBRARY_SOURCE) > $@ )
+tags:  $(SOURCES) $(BUILTIN_C_SRC)
+       ( cd $(topdir) && $(CTAGS) $(CTAGSFLAGS) $(SOURCES) $(BUILTIN_C_SRC) > 
$@ )
 
 # Targets that actually do things not part of the build
 
diff --git a/builtins/Makefile.in b/builtins/Makefile.in
index 64643c73..febbbe5e 100644
--- a/builtins/Makefile.in
+++ b/builtins/Makefile.in
@@ -56,6 +56,8 @@ BUILD_DIR = @BUILD_DIR@
 
 LIBBUILD = ${BUILD_DIR}/lib
 
+DEBUG = @DEBUG@
+
 PROFILE_FLAGS = @PROFILE_FLAGS@
 CFLAGS = @CFLAGS@
 CFLAGS_FOR_BUILD = @CFLAGS_FOR_BUILD@ @CROSS_COMPILE@
@@ -95,8 +97,9 @@ HELPFILES_TARGET = @HELPFILES_TARGET@
 
 INCLUDES = -I. -I.. @RL_INCLUDE@ -I$(topdir) -I$(BASHINCDIR) -I$(topdir)/lib 
-I$(srcdir) ${INTL_INC}
 
-BASE_CCFLAGS = ${PROFILE_FLAGS} $(DEFS) $(LOCAL_DEFS) $(SYSTEM_FLAGS) \
+BASE_CCFLAGS = ${PROFILE_FLAGS} $(DEFS) $(LOCAL_DEFS) \
         ${INCLUDES} $(STYLE_CFLAGS) $(LOCAL_CFLAGS)
+ADDON_CFLAGS =
 
 CCFLAGS = ${ADDON_CFLAGS} $(BASE_CCFLAGS) $(CPPFLAGS) $(CFLAGS)
 
diff --git a/lib/glob/Makefile.in b/lib/glob/Makefile.in
index 503cd873..48da8fcb 100644
--- a/lib/glob/Makefile.in
+++ b/lib/glob/Makefile.in
@@ -39,6 +39,7 @@ MV = mv
 SHELL = @MAKE_SHELL@
 
 PROFILE_FLAGS = @PROFILE_FLAGS@
+ADDON_CFLAGS =
 
 CFLAGS = @CFLAGS@
 LOCAL_CFLAGS = @LOCAL_CFLAGS@
diff --git a/lib/readline/Makefile.in b/lib/readline/Makefile.in
index 1b4afcdf..11832263 100644
--- a/lib/readline/Makefile.in
+++ b/lib/readline/Makefile.in
@@ -54,6 +54,8 @@ CTAGS = ctags -tw
 
 DEBUG = @DEBUG@
 
+ADDON_CFLAGS =
+
 CFLAGS = @CFLAGS@
 LOCAL_CFLAGS = @LOCAL_CFLAGS@ ${DEBUG}
 STYLE_CFLAGS = @STYLE_CFLAGS@
@@ -65,7 +67,7 @@ LOCAL_DEFS = @LOCAL_DEFS@
 
 INCLUDES = -I. -I$(BUILD_DIR) -I$(topdir) -I$(topdir)/lib
 
-CCFLAGS = $(DEFS) $(LOCAL_DEFS) $(APP_CFLAGS) $(CPPFLAGS) ${INCLUDES} \
+CCFLAGS = $(DEFS) $(LOCAL_DEFS) $(CPPFLAGS) ${INCLUDES} \
          $(STYLE_CFLAGS) $(LOCAL_CFLAGS) $(CFLAGS) ${ADDON_CFLAGS}
 
 .c.o:
diff --git a/lib/sh/Makefile.in b/lib/sh/Makefile.in
index fa7463d7..ec16d3c0 100644
--- a/lib/sh/Makefile.in
+++ b/lib/sh/Makefile.in
@@ -55,6 +55,8 @@ MV = mv
 
 SHELL = @MAKE_SHELL@
 
+DEBUG = @DEBUG@
+
 CFLAGS = @CFLAGS@
 LOCAL_CFLAGS = @LOCAL_CFLAGS@ ${DEBUG}
 STYLE_CFLAGS = @STYLE_CFLAGS@
@@ -62,6 +64,7 @@ CPPFLAGS = @CPPFLAGS@
 LDFLAGS = @LDFLAGS@ @LOCAL_LDFLAGS@
 
 PROFILE_FLAGS = @PROFILE_FLAGS@
+ADDON_CFLAGS =
 
 DEFS = @DEFS@
 LOCAL_DEFS = @LOCAL_DEFS@
@@ -101,6 +104,7 @@ CSOURCES = clktck.c clock.c getcwd.c getenv.c oslib.c 
setlinebuf.c \
 HSOURCES = 
 
 # The object files contained in $(LIBRARY_NAME)
+LIBOBJDIR =
 LIBOBJS = @LIBOBJS@
 OBJECTS = clktck.o clock.o getenv.o oslib.o setlinebuf.o strnlen.o \
          itos.o zread.o zwrite.o shtty.o shmatch.o eaccess.o \
diff --git a/lib/tilde/Makefile.in b/lib/tilde/Makefile.in
index a79a5248..6ab327a8 100644
--- a/lib/tilde/Makefile.in
+++ b/lib/tilde/Makefile.in
@@ -39,6 +39,7 @@ MV = mv
 SHELL = @MAKE_SHELL@
 
 PROFILE_FLAGS = @PROFILE_FLAGS@
+ADDON_CFLAGS =
 
 CFLAGS = @CFLAGS@
 LOCAL_CFLAGS = @LOCAL_CFLAGS@
@@ -53,8 +54,8 @@ BASHINCDIR = ${topdir}/include
 
 INCLUDES = -I. -I../.. -I$(topdir) -I${BASHINCDIR} -I$(topdir)/lib
 
-CCFLAGS = ${ASAN_CFLAGS} $(PROFILE_FLAGS) $(DEFS) $(LOCAL_DEFS) $(CPPFLAGS) \
-         ${INCLUDES} $(STYLE_CFLAGS) $(LOCAL_CFLAGS) $(CFLAGS)
+CCFLAGS = $(PROFILE_FLAGS) $(DEFS) $(LOCAL_DEFS) $(CPPFLAGS) \
+         ${INCLUDES} $(STYLE_CFLAGS) $(LOCAL_CFLAGS) $(CFLAGS) $(ADDON_CFLAGS)
 
 .c.o:
        $(CC) -c $(CCFLAGS) $<
diff --git a/support/Makefile.in b/support/Makefile.in
index f7de7ac2..eae28a83 100644
--- a/support/Makefile.in
+++ b/support/Makefile.in
@@ -63,7 +63,7 @@ LDFLAGS_FOR_BUILD = @LDFLAGS_FOR_BUILD@ $(LOCAL_LDFLAGS) 
$(CFLAGS_FOR_BUILD)
 
 INCLUDES = -I${BUILD_DIR} -I${topdir}
 
-BASE_CCFLAGS = ${PROFILE_FLAGS} $(DEFS) $(LOCAL_DEFS) $(SYSTEM_FLAGS) \
+BASE_CCFLAGS = ${PROFILE_FLAGS} $(DEFS) $(LOCAL_DEFS) \
          ${INCLUDES} $(STYLE_CFLAGS) $(LOCAL_CFLAGS)
 
 CCFLAGS = $(BASE_CCFLAGS) $(CPPFLAGS) $(CFLAGS)
-- 
2.47.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]