2

I have written a small c program and created a Makefile to compile and execute it. Basically, I do the following:

$ make
$ make run

But, my executable requires some arguments, so I would like to specify them this way:

$ make run arg1 arg2

Is it possible to achieve that?

kaspersky
  • 3,959
  • 4
  • 33
  • 50

1 Answers1

2

How about this?

Makefile

 demo: demo1.c
            cc -o demo1 demo1.c
 run:
            ./demo1 $A $B

Passing argument as a variable A and B

[spatel@mg0008 tmp]$ make run A=2 B=3
./demo1 2 3
2 + 3 = 5
Satish
  • 16,544
  • 29
  • 93
  • 149