TCSH Makefile - copy file to name and change permissions

571 views Asked by At

Im trying to create a makefile for a tcsh script that copies the file to the name proj3 and changes permissions to be executable by everyone. I know how to do makefiles for c++ and c and such but I dont know why we're doing it for shell scripts.

My file name is proj3final

Here is what I have so far:

proj3final:
    cp final proj3
    chmod 755 proj3

Whenever I run make proj3 or make it prompts nothing to be done

1

There are 1 answers

0
Etan Reisner On BEST ANSWER

A makefile rule should always create a file with the same name as the target.

If you want make to be able to tell when it needs to run a rule your rule needs prerequisites.

Your rule tells make that it will create the proj3final file but it actually creates the proj3 file. This is going to confuse make.

Additionally, your rule gives that target no prerequisites so whenever the proj3final file exists make will assume it is up to date and that no work must be done.

Assuming your input file is named final and you want that copied to a file named proj3final then the rule you want is

proj3final: final
        cp $< $@
        chmod 755 $@

Which should do what you want and uses the Automatic Variables for the current target ($@) and the first prerequisite ($<).