Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installing dependencies in makefile

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 
like image 831
PhillyNJ Avatar asked Oct 20 '25 14:10

PhillyNJ


1 Answers

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 :)

like image 197
Fred Foo Avatar answered Oct 23 '25 05:10

Fred Foo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!