I am new to c and trying to learn how to write a simple makefile for my program on raspbian. My program has a dependency for another program afpfs-ng
Is this the correct syntax to make sure the dependent program is downloaded and installed?
all: myprogram.c
sudo gcc -o myprogram -ansi myprogram.c
packages:
sudo apt-get install afpfs-ng
clean:
($RM) myprogram
Is this the correct syntax to make sure the dependent program is downloaded and installed?
If the package name is correct, this is the correct syntax to make make packages work. It does assume that the person running the program has sudo rights to execute apt-get. It also runs that command unconditionally for make packages, but that shouldn't be too much of a problem because apt-get will check if the package is already installed.
The main problem is that make all doesn't execute make packages, which can be accomplished with
all: myprogram.c packages
# command
Since apt-get is inherently non-portable, it's correct if it works on your box :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With