Pages

Friday, August 14, 2015

I Can't Believe I Can't Get Make to Work In Linux

I have been using make since the 1980s, yet when I run make against this Makefile, I get Error 5:

all: bottom slot sides vhalbottom.ngc vhalslot.ngc vhalsides.ngc

bottom: bottom.c vhal.h
    gcc -o bottom -g bottom.c

slot: slot.c vhal.h
    gcc -o slot -g slot.c

sides: sides.c vhal.h
    gcc -o sides -g sides.c

vhalslot.ngc: slot
    ./slot -mr0.25 -pt0.509 -f50 -w3.199 >vhalslot.ngc

I
vhalsides.ngc: sides
    ./sides -mr0.25 -pt0.509 -f50 -w3.199 >vhalsides.ngc

vhalbottom.ngc: bottom
    ./bottom -mr0.25 -pt0.509 -f50 -w3.199 >vhalbottom.ngc



I have file permissions to make the *.ngc files writeable, and ot work as all the executables have x permission.  What has changed in the last few years to make make not work as it used to.

Curiously, make works although giving error 5

6 comments:

  1. There's probably nothing wrong with your Makefile, but my guess is one of your executables may be exiting with a non-zero status. I think "5" is means "Input/Output error" (symbol "EIO")

    To figure out which (I guess you aren't getting any error messages), maybe run each command by hand and display the exit status. In bash:

    echo $?

    ReplyDelete
  2. https://www.gnu.org/software/make/manual/html_node/Error-Messages.html

    It looks like make invoked something else which returned error 5 as its exit code. Hard to say more without more detail but hopefully the URL above helps.

    ReplyDelete
  3. Heh.

    After a little searching for "make returns error 5", I found a reference which gives the following explanation:

    Make doesn't have an error-code list. It reports "error 5" when one of the commands issued by Make returned a value of "5" rather than "0" (success).

    Do the functions in Slot/Sides/Bottom return any value other than 0?

    Is there a code path that typically returns a "5" from those inputs?

    What shell are you running on?

    (It might even be possible that one of the "int function()" declarations has a "return" with no argument, and "5" is on the stack when that function returns. However, I think you'd get compiler warnings from gcc about that.)

    ReplyDelete
  4. I don't know how you posted this makefile script, but there seems to be a single line with just the letter
    I
    in it. Is this the cause of the problem.

    When I have make problems, my general approach is:
    make -n > tempfile 2> &1

    then tempfile has all the commands which would be run.
    Execute individually and capture exit codes ($? in bash/sh/ksh etc) to determine the baddy

    ReplyDelete
  5. put a '-' in front of every executed command, and a '; exit 0' at the end.

    ReplyDelete
  6. Exit (0l in the programs made all the differencw. Thanks all

    ReplyDelete