0

I have this Makefile:

P5.obj P5.sym: P5.asm
        lc3as P5.asm

I want the assembler to run if either P5.obj or P5.sym are out of date. However, deleting P5.sym does not cause it to be regenerated.

What am I doing wrong?

1

(I assumed the lc3as P5.asm will generate files P5.obj and P5.sym. Assumed you try run make.)

The default target is the first target unless you don't specify it (depends on make-dialect).

For example:

# Makefile
a b:
    echo a > a
    echo b > b

If you run make both file a and b will be created. If you delete b and run make:

`a' is up to date.

because the a target is the default.

The general solution is to create a target with name all at begin of Makefile:

all: a b

a b:
   echo a > a
   echo b > b

.PHONY: all

In this case if you delete b the make will regenerate it (because the default target is all and its dependencies are a and b).

  • Yep, this was the problem. – Nick ODell Jan 16 '18 at 21:24
0

Dependencies usually go after the name of the rule, though it's unclear to me from your question what the inputs are and what the output is. Assuming lc3as P5.asm produces P5 as output (and depends on all of P5.asm, P5.obj, and P5.sym) the entry might look something like:

P5: P5.asm P5.obj P5.sym
        lc3as P5.asm

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.