문제

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top