bug-make
[Top][All Lists]
Advanced

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

Re: 4.3: -p: exit status is 2


From: Steffen Nurpmeso
Subject: Re: 4.3: -p: exit status is 2
Date: Sat, 19 Dec 2020 01:28:50 +0100
User-agent: s-nail v14.9.20-84-g7268a84d

Paul Smith wrote in
 <898afb17671ea69f18ae7a4ed22a57aa35eb87e0.camel@gnu.org>:
 |On Sat, 2020-12-19 at 00:04 +0100, Steffen Nurpmeso wrote:
 |> While finding a way to truly detect whether being run by BSD make
 |> (which cannot supervise a shell script that turns on "set -m" to
 |> monitors its childs) i stumbled upon the fact that
 |> 
 |>   $ make -p
 |> 
 |> exits 2.
 |
 |Yes.  The manual says specifically:
 |
 |> Print the data base (rules and variable values) that results from
 |> reading the makefiles; then EXECUTE AS USUAL OR AS OTHERWISE
 |> SPECIFIED.
 |
 |(emphasis added).  If you examine the output you'll see that you got an
 |error:
 |
 |  make: *** No targets specified and no makefile found.  Stop.
 |
 |and the manual says:
 |
 |> 2
 |> The exit status is two if make encounters any errors. It will print
 |> messages describing the particular errors.
 |
 |so this is as expected.

Oh.  I see, sorry for the noise then!

 |I guess there is some issue with the documentation here since the error
 |message is actually shown before the database is printed while the
 |documentation implies that the database will be printed first.
 |
 |> Even if i follow the manual advice
 |> 
 |>   $ make -p -f /dev/null
 |> 
 |> i get complains (bad manual advice!),
 |
 |I don't see why it's bad advice.  The advice doesn't say that it will
 |run with a 0 exit code, it just says that if you want to see the
 |default targets, without any targets defined by your makefile, you can
 |try using "-f /dev/null".
 |
 |>   $ echo all: > y.mk; make -p -f y.mk
 |
 |You don't need to make a file: you can do something like this:
 |
 |  $ echo 'all:;' | make -p -f-

Yes, thanks.  But no, the test is solely to find out whether we
run running BSD make, which has no -p (yet, but he sounds as if
that remains), but he says i should watch out for .PARSEDIR, so
i end up doing

  case "${JOBMON}" in
  [yY]*)
     # BSD make cannot monitor shells which monitor
     i=
     ( ${MAKE} -p ) >/dev/null 2>&1
     if [ ${?} -ne 0 ]; then
        ${cat} > .t.mk.mon <<'_EOT'
  all:
          @printf ''
  ifdef .PARSEDIR
  .if defined(.PARSEDIR)
          @echo yes
  .endif
  endif
  _EOT
        i=`${MAKE} -f .t.mk.mon 2>/dev/null`
        if [ ${?} -ne 0 ] || [ -n "${i}" ]; then
           i="${MAKE} cannot supervise sh(1)ells with"
        fi
     fi
  
     if [ -z "${i}" ] && (set -m >/dev/null 2>&1); then
        JOBMON=y
     else
        [ -z "${i}" ] && i="${SHELL} does not support"
        echo >&2 ${i}" \"set -m[onitor]\"!"
        echo >&2 'Failing (hanging) tests could leave stale processes around!'
        JOBMON=
     fi
     ;;
  *)
     JOBMON=
     ;;
  esac

Maybe i am too tired and fail to see a better way, the above works
as desired for GNU make, Schily make, SunOS 5.9 and 5.10 make, and
BSD make fails for -p and the ifdef, and shall it ever support the
compatibility for ifdef then it will still work (until anyone
implements .PARSEDIR).

Thank you!

And a nice weekend i wish from Germany,

--steffen
|
|Der Kragenbaer,                The moon bear,
|der holt sich munter           he cheerfully and one by one
|einen nach dem anderen runter  wa.ks himself off
|(By Robert Gernhardt)



reply via email to

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