Joe
Joe

Reputation: 15

Makefile: make run command

Here is my my makefile. I know there is a shorter way to write it out, but I have a question on how to run it. My hw says I have to use the command: make run --- this command should cause the executable file to run using file redirection to read the input file data.

How would I go about setting that up?

Also i know the gcc is supposed to be tabbed.

test:  main.o sum.o stack.o bSearch.o database.o db.o set.o parse.o bubble.o
    gcc -o object main.o sum.o stack.o bSearch.o db.o set.o parse.o bubble.o

main.o: main.c sum.h
gcc -c main.c

sum.o: sum.c sum.h
    gcc -c sum.c

stack.o: stack.c stack.h
    gcc -c stack.c

bSearch.o: bSearch.c defs.h sortAndsearch.h
    gcc -c bSearch.c

database.o: database.c defs.h parse.h
    gcc -c database.c

db.o: db.c defs.h
    gcc -c db.c

set.o: set.c set.h db.h
    gcc -c set.c

parse.o: parse.c parse.h
    gcc -c parse.c

bubble.o: bubble.c defs.h
    gcc -c bubble.c

sortAndsearch.h: db.h

defs.h: set.h sortAndsearch.h

stack.h: set.h

clean:
    rm *.o object

Upvotes: 0

Views: 13271

Answers (1)

Chris Turner
Chris Turner

Reputation: 8142

"run" is just like any other target in your Makefile such as "test" or "set.o" - but you have to add the rule to the Makefile for make to know what to do with it.

run:
  ./test < input.txt

Upvotes: 5

Related Questions