Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GNU Make 4.1+dbg1.1: recipe with "make -f " got unexpected result #22

Closed
liugang opened this issue Jul 16, 2015 · 11 comments
Closed

GNU Make 4.1+dbg1.1: recipe with "make -f " got unexpected result #22

liugang opened this issue Jul 16, 2015 · 11 comments

Comments

@liugang
Copy link

liugang commented Jul 16, 2015

GNU Make 4.1+dbg1.1: recipe with "make -f " got unexpected result
but GNU Make 3.82+dbg0.9 works fine.

Test GNU Make 4.1+dbg1.1

ls

Makefile1.mk  Makefile2.mk

cat Makefile1.mk

FOO := foo

all:
    @echo $(FOO)

cat Makefile2.mk

all:
    make -f Makefile1.mk

remake -X -f Makefile2.mk

GNU Make 4.1+dbg1.1
Built for x86_64-unknown-linux-gnu
Copyright (C) 1988-2014 Free Software Foundation, Inc.
Copyright (C) 2015 Rocky Bernstein.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Reading makefiles...
Updating makefiles....
Updating goal targets....
-> (/home/galen_liu/remake_test/Makefile2.mk:1)
Will update target:all: 
remake<0> l
/home/galen_liu/remake_test/Makefile2.mk:1
Target: all:
#  recipe to execute (from 'Makefile2.mk', line 2):
    make -f Makefile1.mk
remake<1> n
 File `all' does not exist.
-- (/home/galen_liu/remake_test/Makefile2.mk:1)
Will update target:all: 
remake<2> n
Must remake target `all'.
Makefile2.mk:2: target 'all' does not exist
##>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
make -f Makefile1.mk
##<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
# make[1]: Entering directory '/home/galen_liu/remake_test'
touch all
# GNU Make 4.0
# Built for x86_64-pc-linux-gnu
# Copyright (C) 1988-2013 Free Software Foundation, Inc.
# License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
# This is free software: you are free to change and redistribute it.
# There is NO WARRANTY, to the extent permitted by law.

# Make data base, printed on Thu Jul 16 17:07:32 2015

# Variables

# automatic
<D = $(patsubst %/,%,$(dir $<))
# automatic
?F = $(notdir $?)
# environment
DESKTOP_SESSION = ubuntu
# default
.SHELLFLAGS := -c
# environment
XDG_SESSION_TYPE = x11
# environment
UPSTART_INSTANCE = 
# default
CWEAVE = cweave
# automatic
?D = $(patsubst %/,%,$(dir $?))
# automatic
@D = $(patsubst %/,%,$(dir $@))
# environment
XAUTHORITY = /home/galen_liu/.Xauthority
# environment
GDMSESSION = ubuntu
# environment
XMODIFIERS = @im=fcitx
# makefile
CURDIR := /home/galen_liu/remake_test
# makefile
SHELL = /bin/sh
# default
RM = rm -f
# environment
GDM_LANG = en_US
# environment
VTE_VERSION = 3803
# environment
_ = /usr/local/bin/remake
# default
PREPROCESS.F = $(FC) $(FFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -F
# default
LINK.m = $(OBJC) $(OBJCFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_ARCH)
# environment
XDG_CONFIG_DIRS = /etc/xdg/xdg-ubuntu:/usr/share/upstart/xdg:/etc/xdg
# default
OUTPUT_OPTION = -o $@
# default
COMPILE.cpp = $(COMPILE.cc)
# makefile (from 'Makefile1.mk', line 1)
MAKEFILE_LIST :=  Makefile1.mk
# automatic
@F = $(notdir $@)
# environment
IM_CONFIG_PHASE = 1
# 'override' directive
GNUMAKEFLAGS := 
# environment
SESSIONTYPE = gnome-session
# environment under -e
MAKELEVEL := 1
# environment
MANDATORY_PATH = /usr/share/gconf/ubuntu.mandatory.path
# environment
XDG_DATA_DIRS = /usr/share/ubuntu:/usr/share/gnome:/usr/local/share/:/usr/share/
# environment
DBUS_SESSION_BUS_ADDRESS = unix:abstract=/tmp/dbus-Ip5ba3W6Zp
# default
CC = cc
# default
CHECKOUT,v = +$(if $(wildcard $@),,$(CO) $(COFLAGS) $< $@)
# environment
CLUTTER_IM_MODULE = xim
# environment
LC_NAME = zh_CN.UTF-8
# default
CPP = $(CC) -E
# environment
USE_CCACHE = 1
# environment
XDG_SESSION_PATH = /org/freedesktop/DisplayManager/Session0
# default
LEX = lex
# default
MAKE_HOST := x86_64-pc-linux-gnu
# environment
NO_PROXY = localhost,127.0.0.0/8,::1
# default
LD = ld
# default
TEXI2DVI = texi2dvi
# environment
GPG_AGENT_INFO = /run/user/1000/keyring/gpg:0:1
# default
YACC = yacc
# environment
UPSTART_JOB = unity7
# default
COMPILE.mod = $(M2C) $(M2FLAGS) $(MODFLAGS) $(TARGET_ARCH)
# environment
XDG_RUNTIME_DIR = /run/user/1000
# default
ARFLAGS = rv
# default
LINK.r = $(FC) $(FFLAGS) $(RFLAGS) $(LDFLAGS) $(TARGET_ARCH)
# environment
WINDOWID = 25165835
# default
COMPILE.f = $(FC) $(FFLAGS) $(TARGET_ARCH) -c
# default
LINT.c = $(LINT) $(LINTFLAGS) $(CPPFLAGS) $(TARGET_ARCH)
# default
YACC.m = $(YACC) $(YFLAGS)
# default
LINT = lint
# default
LINK.p = $(PC) $(PFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_ARCH)
# default
YACC.y = $(YACC) $(YFLAGS)
# default
AR = ar
# environment
LC_NUMERIC = zh_CN.UTF-8
# default
.FEATURES := target-specific order-only second-expansion else-if shortest-stem undefine oneshell archives jobserver output-sync check-symlink load
# default
TANGLE = tangle
# environment
SESSION = ubuntu
# environment
XDG_GREETER_DATA_DIR = /var/lib/lightdm-data/galen_liu
# environment
LS_COLORS = rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.axv=01;35:*.anx=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.axa=00;36:*.oga=00;36:*.spx=00;36:*.xspf=00;36:
# environment
JOB = unity-settings-daemon
# environment
XDG_SESSION_DESKTOP = ubuntu
# environment
SSH_AUTH_SOCK = /run/user/1000/keyring/ssh
# default
GET = get
# automatic
%F = $(notdir $%)
# environment
DISPLAY = :0
# default
COMPILE.F = $(FC) $(FFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c
# environment
no_proxy = localhost,127.0.0.0/8,::1
# default
CTANGLE = ctangle
# environment
GTK_IM_MODULE = fcitx
# default
.LIBPATTERNS = lib%.so lib%.a
# default
LINK.C = $(LINK.cc)
# environment
PWD = /home/galen_liu/remake_test
# environment
QT_QPA_PLATFORMTHEME = appmenu-qt5
# default
LINK.S = $(CC) $(ASFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_MACH)
# environment
XDG_SEAT = seat0
# default
PREPROCESS.r = $(FC) $(FFLAGS) $(RFLAGS) $(TARGET_ARCH) -F
# default
LINK.c = $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_ARCH)
# environment
GTK_MODULES = overlay-scrollbar:unity-gtk-module
# default
LINK.cc = $(CXX) $(CXXFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_ARCH)
# default
LINK.s = $(CC) $(ASFLAGS) $(LDFLAGS) $(TARGET_MACH)
# environment
HOME = /home/galen_liu
# environment
LD_LIBRARY_PATH = /usr/local/lib:
# environment
LOGNAME = galen_liu
# automatic
+F = $(notdir $+)
# default
CO = co
# default
MAKE_VERSION := 4.0
# environment
GNOME_DESKTOP_SESSION_ID = this-is-deprecated
# automatic
^D = $(patsubst %/,%,$(dir $^))
# environment
XDG_VTNR = 7
# environment
LC_TIME = zh_CN.UTF-8
# default
COMPILE.m = $(OBJC) $(OBJCFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c
# default
MAKE = $(MAKE_COMMAND)
# environment
QT_IM_MODULE = fcitx
# environment
SHLVL = 1
# default
AS = as
# default
PREPROCESS.S = $(CC) -E $(CPPFLAGS)
# environment
JAVA_HOME = /opt/jdk1.6.0_45
# environment
COMPIZ_CONFIG_PROFILE = ubuntu
# default
COMPILE.p = $(PC) $(PFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c
# environment
XDG_SESSION_ID = c1
# environment
USER = galen_liu
# default
FC = f77
# environment
LC_MONETARY = zh_CN.UTF-8
# makefile
.DEFAULT_GOAL := all
# environment
XDG_CURRENT_DESKTOP = Unity
# environment
LIBVIRT_DEFAULT_URI = qemu:///system
# environment
CLASSPATH = .:/opt/jdk1.6.0_45/jre/lib/rt.jar:/opt/jdk1.6.0_45/lib/dt.jar:/opt/jdk1.6.0_45/lib/tools.jar
# environment
UPSTART_EVENTS = xsession started
# automatic
%D = $(patsubst %/,%,$(dir $%))
# environment
GNOME_KEYRING_PID = 
# environment
LC_TELEPHONE = zh_CN.UTF-8
# default
WEAVE = weave
# default
MAKE_COMMAND := make
# default
LINK.cpp = $(LINK.cc)
# default
F77 = $(FC)
# environment
OLDPWD = /home/galen_liu
# default
.VARIABLES := 
# default
PC = pc
# automatic
*F = $(notdir $*)
# environment
LANGUAGE = en_US
# environment
XDG_SEAT_PATH = /org/freedesktop/DisplayManager/Seat0
# default
COMPILE.def = $(M2C) $(M2FLAGS) $(DEFFLAGS) $(TARGET_ARCH)
# environment
GNOME_KEYRING_CONTROL = 
# environment under -e
MAKEFLAGS = eiprtw
# environment under -e
MFLAGS = -eiprtw
# automatic
*D = $(patsubst %/,%,$(dir $*))
# default
LEX.l = $(LEX) $(LFLAGS) -t
# default
LEX.m = $(LEX) $(LFLAGS) -t
# automatic
+D = $(patsubst %/,%,$(dir $+))
# default
COMPILE.r = $(FC) $(FFLAGS) $(RFLAGS) $(TARGET_ARCH) -c
# environment
MAKE_TERMOUT = /dev/pts/28
# environment
LC_PAPER = zh_CN.UTF-8
# default
M2C = m2c
# environment
SVN_EDITOR = vi
# makefile (from 'Makefile1.mk', line 1)
FOO := foo
# environment
COMPIZ_BIN_PATH = /usr/bin/
# environment
DEFAULTS_PATH = /usr/share/gconf/ubuntu.default.path
# default
MAKEFILES := 
# environment
UPSTART_SESSION = unix:abstract=/com/ubuntu/upstart-session/1000/1572
# default
COMPILE.cc = $(CXX) $(CXXFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c
# automatic
<F = $(notdir $<)
# default
CXX = g++
# environment
LC_MEASUREMENT = zh_CN.UTF-8
# environment
INSTANCE = 
# default
COFLAGS = 
# environment
CCACHE_UMASK = 002
# default
COMPILE.C = $(COMPILE.cc)
# environment
QT4_IM_MODULE = fcitx
# automatic
^F = $(notdir $^)
# default
COMPILE.S = $(CC) $(ASFLAGS) $(CPPFLAGS) $(TARGET_MACH) -c
# environment
PATH = /opt/jdk1.6.0_45/bin:/usr/lib/jvm/java-6-openjdk-amd64/jre/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
# default
LINK.F = $(FC) $(FFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_ARCH)
# default
SUFFIXES := 
# default
COMPILE.c = $(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c
# default
COMPILE.s = $(AS) $(ASFLAGS) $(TARGET_MACH)
# default
.INCLUDE_DIRS = /usr/include /usr/local/include /usr/include
# environment
LC_IDENTIFICATION = zh_CN.UTF-8
# default
.RECIPEPREFIX := 
# default
MAKEINFO = makeinfo
# environment
MAKE_TERMERR = /dev/pts/28
# default
OBJC = cc
# environment
LC_ADDRESS = zh_CN.UTF-8
# default
LINK.f = $(FC) $(FFLAGS) $(LDFLAGS) $(TARGET_ARCH)
# default
TEX = tex
# environment
LANG = en_US.UTF-8
# environment
TERM = xterm
# default
F77FLAGS = $(FFLAGS)
# default
LINK.o = $(CC) $(LDFLAGS) $(TARGET_ARCH)
# variable set hash-table stats:
# Load=177/1024=17%, Rehash=0, Collisions=29/205=14%

# Pattern-specific Variable Values

# No pattern-specific variable values.

# Directories


# No files, no impossibilities in 0 directories.

# Implicit Rules

# No implicit rules.

# Files

all:
#  Implicit rule search has not been done.
#  Last modified 2514-05-30 09:53:03.107374182
#  File has been updated.
#  Successfully updated.
#  recipe to execute (from 'Makefile1.mk', line 4):
    @echo $(FOO)

# Not a target:
Makefile1.mk:
#  Implicit rule search has been done.
#  Last modified 2015-07-16 16:39:55.80266134
#  File has been updated.
#  Successfully updated.

# Not a target:
.DEFAULT:
#  Implicit rule search has not been done.
#  Modification time never checked.
#  File has not been updated.

# files hash-table stats:
# Load=4/1024=0%, Rehash=0, Collisions=0/15=0%
# VPATH Search Paths

# No 'vpath' search paths.

# No general ('VPATH' variable) search path.

# strcache buffers: 1 (0) / strings = 6 / storage = 68 B / avg = 11 B
# current buf: size = 8162 B / used = 68 B / count = 6 / avg = 11 B

# strcache performance: lookups = 9 / hit rate = 33%
# hash-table stats:
# Load=6/8192=0%, Rehash=0, Collisions=0/9=0%
# Finished Make data base on Thu Jul 16 17:07:32 2015

# make[1]: Leaving directory '/home/galen_liu/remake_test'
Successfully remade target file `all'.


ls

all  Makefile1.mk  Makefile2.mk

Here, We got file: all

Test GNU Make 3.82+dbg0.9

ls

Makefile1.mk  Makefile2.mk

cat Makefile1.mk

FOO := foo

all:
    @echo $(FOO)

cat Makefile2.mk

all:
    make -f Makefile1.mk

remake -X -f Makefile2.mk

GNU Make 3.82+dbg0.9
Built for x86_64-unknown-linux-gnu
Copyright (C) 2010  Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Reading makefiles...
Updating makefiles....
Updating goal targets....
-> (/home/galen_liu/remake_test/Makefile2.mk:1)
Will update target:all: 
remake<0> l
/home/galen_liu/remake_test/Makefile2.mk:1
Target: all:
#  commands to execute (from `Makefile2.mk', line 2):
    make -f Makefile1.mk

remake<1> n
  /home/galen_liu/remake_test/Makefile2.mk:1    File `all' does not exist.
-- (/home/galen_liu/remake_test/Makefile2.mk:1)
Will update target:all: 
remake<2> n
  /home/galen_liu/remake_test/Makefile2.mk:1    Must remake target `all'.
Invoking recipe from Makefile2.mk:2 to update target `all'.
##>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
make -f Makefile1.mk
##<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
make[1]: Entering directory `/home/galen_liu/remake_test'
foo
make[1]: Leaving directory `/home/galen_liu/remake_test'
  /home/galen_liu/remake_test/Makefile2.mk:1    Successfully remade target file `all'.
@liugang
Copy link
Author

liugang commented Jul 21, 2015

I downloaded the make source via apt-get and patch it, I added some debug info.

$ apt-get source make
$ cd make-dfsg-4.0
$ dpkg-buildpackage
$ ./configure
$ make && sudo make install

This is my patch

--- make-dfsg-4.0.orig/main.c   2013-10-09 12:22:40.000000000 +0800
+++ make-dfsg-4.0/main.c    2015-07-21 09:48:48.195562772 +0800
@@ -153,7 +153,7 @@ int just_print_flag;
 static struct stringlist *db_flags = 0;
 static int debug_flag = 0;

-int db_level = 0;
+int db_level = DB_BASIC;

 /* Synchronize output (--output-sync).  */

@@ -688,7 +688,7 @@ expand_command_line_file (char *name)
 static RETSIGTYPE
 debug_signal_handler (int sig UNUSED)
 {
-  db_level = db_level ? DB_NONE : DB_BASIC;
+  db_level = db_level ? DB_BASIC : DB_BASIC;
 }
 #endif

@@ -746,6 +746,7 @@ decode_debug_flags (void)
           }
       }

+  db_level = DB_BASIC;
   if (db_level)
     verify_flag = 1;

@@ -1052,6 +1053,12 @@ main (int argc, char **argv, char **envp
   PATH_VAR (current_directory);
   unsigned int restarts = 0;
   unsigned int syncing = 0;
+  printf("argc = %d\n", argc);
+  int ii = 0;
+  for (ii = 0; ii < argc ; ii++) {
+          printf("argv[%d] = %s\n", ii, argv[ii]);
+  }
+
 #ifdef WINDOWS32
   char *unix_path = NULL;
   char *windows32_path = NULL;
@@ -2146,6 +2153,7 @@ main (int argc, char **argv, char **envp
       if (! ISDB (DB_MAKEFILES))
         db_level = DB_NONE;

+      printf("Galen: Updating makefiles....\n");
       DB (DB_BASIC, (_("Updating makefiles....\n")));

       /* Remove any makefiles we don't want to try to update.
@@ -2294,8 +2302,10 @@ main (int argc, char **argv, char **envp

           remove_intermediates (0);

-          if (print_data_base_flag)
-            print_data_base ();
+          if (print_data_base_flag) {
+                  printf("main(), print_data_base\n");
+                  print_data_base ();
+          }

           clean_jobserver (0);

@@ -2552,7 +2562,7 @@ main (int argc, char **argv, char **envp
     /* Exit.  */
     die (makefile_status);
   }
-
+  printf("exit................\n");
   /* NOTREACHED */
   exit (0);
 }
@@ -2739,6 +2749,10 @@ decode_switches (int argc, char **argv,
   register const struct command_switch *cs;
   register struct stringlist *sl;
   register int c;
+  int ii = 0;
+  for (ii = 0; ii < argc ; ii++) {
+          printf("argv[%d] = %s\n", ii, argv[ii]);
+  }

   /* getopt does most of the parsing for us.
      First, get its vectors set up.  */
@@ -3405,8 +3419,11 @@ die (int status)
       /* Remove the intermediate files.  */
       remove_intermediates (0);

-      if (print_data_base_flag)
-        print_data_base ();
+      printf("print_data_base_flag = %d\n", print_data_base_flag);
+      if (print_data_base_flag) {
+              printf("%s(), %d, print_data_base......\n", __FUNCTION__, __LINE__);
+              print_data_base ();
+      }

       if (verify_flag)
         verify_file_data_base ();

and I test remake 4.1 and remake 3.82.

remake 4.1

Makefile2.mk:2: target 'all' does not exist
##>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
/usr/local/bin/make -f Makefile1.mk
##<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
argc = 3
argv[0] = /usr/local/bin/make
argv[1] = -f
argv[2] = Makefile1.mk
argv[0] = (null)
argv[1] = -Xpreaction
argv[0] = /usr/local/bin/make
argv[1] = -f
argv[2] = Makefile1.mk
# GNU Make 4.0
# Built for x86_64-unknown-linux-gnu
# Copyright (C) 1988-2013 Free Software Foundation, Inc.
# License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
# This is free software: you are free to change and redistribute it.
# There is NO WARRANTY, to the extent permitted by law.
Reading makefiles...
argv[0] = (null)
argv[1] = -eiprtw
Galen: Updating makefiles....
Updating goal targets....
 File 'all' does not exist.
Must remake target 'all'.
# make[1]: Entering directory '/home/galen_liu/remake_test'
touch all
Successfully remade target file 'all'.
print_data_base_flag = 1
die(), 3424, print_data_base......

remake 3.82

Invoking recipe from Makefile2.mk:2 to update target `all'.
##>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
/usr/local/bin/make -f Makefile1.mk
##<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
argc = 3
argv[0] = /usr/local/bin/make
argv[1] = -f
argv[2] = Makefile1.mk
argv[0] = (null)
argv[1] = -X
argv[0] = /usr/local/bin/make
argv[1] = -f
argv[2] = Makefile1.mk
GNU Make 4.0
Built for x86_64-unknown-linux-gnu
Copyright (C) 1988-2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Reading makefiles...
argv[0] = (null)
argv[1] = -w
Galen: Updating makefiles....
Updating goal targets....
 File 'all' does not exist.
Must remake target 'all'.
make[1]: Entering directory '/home/galen_liu/remake_test'
echo ==============>foo
Successfully remade target file 'all'.
print_data_base_flag = 0
make[1]: Leaving directory '/home/galen_liu/remake_test'
  /home/galen_liu/remake_test/Makefile2.mk:1    Successfully remade target file `all'.

I found the difference:

in function: decode_switches (int argc, char **argv, int env)

remake 4.1 pass "argv[1] = -eiprtw"
remake 3.82 only pass "argv[1] = -w"

$ man make

       -e, --environment-overrides
            Give variables taken from the environment precedence over variables from makefiles.
       -i, --ignore-errors
            Ignore all errors in commands executed to remake files.
       -p, --print-data-base
            Print  the  data  base (rules and variable values) that results from reading the makefiles; then execute as usual or as otherwise speci‐
            fied.  This also prints the version information given by the -v switch (see below).  To print the data base without trying to remake any
            files, use make -p -f/dev/null.

       -r, --no-builtin-rules
            Eliminate use of the built-in implicit rules.  Also clear out the default list of suffixes for suffix rules.

       -t, --touch
            Touch  files  (mark  them  up to date without really changing them) instead of running their commands.  This is used to pretend that the
            commands were done, in order to fool future invocations of make.
       -w, --print-directory
            Print a message containing the working directory before and after other processing.  This may be useful for tracking  down  errors  from
            complicated nests of recursive make commands.

}}}






@liugang
Copy link
Author

liugang commented Jul 21, 2015

From my first log, we also can see, remake pass it through evnironment MAKEFLAGS and MFLAGS

# environment under -e
MAKEFLAGS = eiprtw
# environment under -e
MFLAGS = -eiprtw

@liugang
Copy link
Author

liugang commented Jul 21, 2015

cat Makefile

all:
        @echo "MAKEFLAGS = $(MAKEFLAGS) in Makefile"
        @echo "MFLAGS = $(MFLAGS) in Makefile"
        @make -f Makefile1.mk

cat Makefile1.mk

FOO := foo

$(info MAKEFLAGS = $(MAKEFLAGS))
$(info MFLAGS = $(MFLAGS))

all:
        @echo "MAKEFLAGS = $(MAKEFLAGS) in Makefile1.mk"
        @echo "MFLAGS = $(MFLAGS) in Makefile1.mk"
        @echo "echo ==============>$(FOO)"

The MAKEFLAGS and MFLAGS of Make4.1+dbg1.1 is different form Make 3.82+dbg0.9

Make 4.1+dbg1.1

MAKEFLAGS= -Xpreaction
MFLAGS=-Xpreaction

Make 3.82+dgb0.9

MAKEFLAGS=X
MFLAGS=-X

@liugang
Copy link
Author

liugang commented Jul 21, 2015

This is my gdb debug backtrace:

(gdb) bt
#0  decode_switches (argc=2, argv=0x7fffffffbe20, env=1) at main.c:2748
#1  0x000000000041ca0f in decode_env_switches (envar=0x43436e "MAKEFLAGS", len=11) at main.c:2996
#2  0x000000000041982f in main (argc=3, argv=0x7fffffffd9e8, envp=0x7fffffffda08) at main.c:1414
(gdb) p argc
$180 = 2
(gdb) p argv[0]
$181 = 0x0
(gdb) p argv[1]
$182 = 0x65a890 "-Xpreaction"
(gdb) p argv[2]
$183 = 0x0

in function decode_switches(), it will call getopt_long to parse argv, "-Xpreaction"

options is

-bBdehikLmnpqrRsStvwC:f:I:j::l::o:O::W:
  while (optind < argc)
    {
      /* Parse the next argument.  */
      c = getopt_long (argc, argv, options, long_options, (int *) 0);

Finally, Xpreaction will be parsed as :

?pre??ti??

"preti" will be sorted as "eiprt", "w" will append to it. it will be "eiprtw".

now, do you know where eiprtw is from?

# environment under -e
MAKEFLAGS = eiprtw
# environment under -e
MFLAGS = -eiprtw

@rocky
Copy link
Owner

rocky commented Jul 21, 2015

Thanks for investigating and reporting the problem.

I will look at in more detail when I get a chance.

The bug is that the weird behavior of the -X flag isn't deparsed correctly.

rocky added a commit that referenced this issue Jul 22, 2015
@rocky
Copy link
Owner

rocky commented Jul 22, 2015

I think commit 6ee1f82 now handles this properly. But please double check.

Down the line, for all of these commits, I need to turn your examples into test code which get run along with the other tests. But that's another issue.

@liugang
Copy link
Author

liugang commented Jul 23, 2015

I think commit 6ee1f82 now handles this properly. But please double check.

Yes, this issue is resolved, but I think the commit will cause other issue, not compatible previous behavior.

After I apply the commit, the MAKEFLAGS, MFLAGS will be --debuggerpreaction, I think it isn't right compare with the behavior of remake 3.82-dgb0.9

Makefile:2: target 'all' does not exist
##>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
echo "MAKEFLAGS =  --debuggerpreaction in Makefile"
##<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
MAKEFLAGS =  --debuggerpreaction in Makefile
##>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
echo "MFLAGS = --debuggerpreaction in Makefile"
##<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
MFLAGS = --debuggerpreaction in Makefile
##>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
make -f Makefile1.mk
##<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

The behavior of remake 3.82-dgb0.9 is below:

Invoking recipe from Makefile:2 to update target `all'.
##>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
echo "MAKEFLAGS = X in Makefile"
##<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
MAKEFLAGS = X in Makefile
##>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
echo "MFLAGS = -X in Makefile"
##<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
MFLAGS = -X in Makefile
##>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
make -f Makefile1.mk
##<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

MAKEFLAGS = X (without '-')
MFLAGS = -X

pass environments MAKEFLAGS = X and MFLAGS = -X to child process $(MAKE), will cause child process remake enter debug mode, pass them to gnu make, gnu make can't recognize -X, and will ignore it.

The form like below will cause child remake enter debug mode

all:
        $(MAKE) 

The form like below, gnu make will ignore -X option.

all:
        make

so this commit 6ee1f82 will cause all $(MAKE) won't enter debug mode.
For large project, this behavior (child remake wont' enter debug mode) is very necessary,

Example: Our project will build many third-party libraris, pass -X to child $(MAKE) will cause
I debug hundreds of Makefiles, I have to press debug command "next", "continue" thousands of times,
but I only want to debug Makefile written by ourself, not Makefiles in third-party libraries.

Will update target:install-am
remake<<<<10>>>> 
GNU Make 3.82+dbg0.9
Built for x86_64-unknown-linux-gnu
Copyright (C) 2010  Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Reading makefiles...
Updating makefiles....
-> (/home/galen_liu/sqlite3/Makefile:303)
Will update target:Makefile: Makefile.in config.status
remake<<<<<...0>>>>>... 

I advise strongly to add an option to user , Let user decide whether pass -X to child $(MAKE) via MAKEFLAGS = X and MFLAGS = -X

I found "setq MAKEFLAGS", "setq MFLAGS" can avoid child $(MAKE) to enter debug mode.

but this need type many characters, can you add an another option in "set OPTION {on|off|toggle}" for this purpose?

remake<0> help set
set OPTION {on|off|toggle}
  set variable VARIABLE VALUE    

In the first form, Set debugger value for OPTION.
In the second form, set a GNU make variable
Run `set' for a list of options and current values

See also 'setq'.
remake<1> set
set basename   -- Set if we are to show short or long filenames is off.
set debug      -- Set GNU Make debug mask (set via --debug or -d) is 3361.
set ignore-errors -- Set value of GNU Make --ignore-errors (or -i) flag is off.
set keep-going -- Set value of GNU Make --keep-going (or -k) flag is off.
set silent     -- Set value of GNU Make --silent (or -s) flags. is off.
set variable   -- Set a GNU Make variable VARIABLE

@rocky
Copy link
Owner

rocky commented Jul 23, 2015

In commit dbcc5de -X or --debugger are now short options only, and newly added --debugger-stop is added to specify at which point to stop. That should address the problem that additional flags were unintentionally added to MFLAGS and MAKEFLAGS. This is incompatible with remake 3.82, but so be it; GNU make options processing don't easily allow the behavior using something like -X to mean -X preaction, and experience has shown that the other kinds of stopping ("goal', "preread", etc.) aren't used much.

You have a couple of misconceptions. If you have a Makefile:

all:
        make

You are supposed to get whatever make resolves to. That's the way GNU make works and that what's supposed to happen.

For example, you could have a /usr/bin/make and a /usr/local/bin/make in your path, and /usr/local/bin/make happens to resolve first, but you invoke with /usr/bin/make instead. In GNU make the recursion will pick up the PATH variable and run /usr/local/bin/make.

It is common that inside a makefile you'll want to recursively run the same make program that was used as was used to invoke the makefile. What you are supposed to do is invoke with $(MAKE), not make.

Lastly, I'll say that while compatibility is a good thing and generally desirably, it is and will sometimes be broken. make 3.82 isn't totally compatible with make 4.1 or else it would be the same thing as 3.82. I am not sure it is totally upward compatible either. Incompatibilities between make 3.82 and make 4.1 will be reflected in incompatibilities between remake 3.82 and remake 4.1.

Specifically the behavior of -X no longer takes an optional argument. Option processing between make 3.82 and 4.1 has changed, the the 3.82 behavior was an extension to the make behavior that I can't or no longer want to support.

@rocky
Copy link
Owner

rocky commented Jul 23, 2015

Example: Our project will build many third-party libraris, pass -X to child $(MAKE) will cause
I debug hundreds of Makefiles, I have to press debug command "next", "continue" thousands of times,
but I only want to debug Makefile written by ourself, not Makefiles in third-party libraries.

Here is what I think is the more natural gdb-like way to address at least part of this. "step" is what is generally called "step into" while "next" is generally called "step over". So "step" should cause debugging into a recursive make, while "step over" should not.

Since that' a separate issue, I'm going to open that as a separate issue. Bugs which wander all over the place aren't helpful to others. And already I find most of what's written here a little difficult to follow. So unless the original problem, and only that one, isn't addressed, let's close this.

@rocky rocky closed this as completed Jul 23, 2015
@liugang
Copy link
Author

liugang commented Jul 24, 2015

I agree with you, this issue is fixed and should be close.

Thanks, rocky.

@rocky
Copy link
Owner

rocky commented Jul 24, 2015

(Thanks - it's good to get confirmation.)

yarikoptic added a commit that referenced this issue Oct 15, 2017
* commit '1f7602b54d707d971245a2aea08e86715911dbf1^':
  Reinstate manpage. Document --target option
  Add install from source instructions and...
  Try using travis container architecture
  One more target comment
  Save and show breakoint mask
  Remove remnant of future REMAKEFLAGS
  Remove stray debug print
  Proof of concept for issue #25. It does this by setting MAKEFILE rather than REMAKEFILE though.
  Set long name in options string for -X or --debugger
  Can't support -X=... form. So split out into -X (--debugger) and --debugger-stop.
  In parsing options to set MAKEFLAGS, don't treat -X as short option. Github issue #22
  debugger quit command was not leaving recursive make. Issue #24
  Initialize global_argv; github issue #23
  Fix expand option of debugger "target" command Github issue #21
  GNU Make bug in enumeration values?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants