[7 / 1 / ?]
I know how to use them but I feel like I don't yet get what their main purpose is.
FLAGS=-Wall
PROG=prog
build: src/main.c
mkdir -p obj/
gcc $(FLAGS) -c -o obj/main.o src/main.c
link: obj/main.o
gcc $(FLAGS) -o $(PROG) obj/main.o
clean:
if [ -d obj/ ]; then rm -r obj/; fi
if [ -f $(PROG) ]; then rm $(PROG); fi
Is this how I'm supposed to do it or is there a better way?
FLAGS=-Wall
PROG=prog
build: src/main.c
mkdir -p obj/
gcc $(FLAGS) -c -o obj/main.o src/main.c
link: obj/main.o
gcc $(FLAGS) -o $(PROG) obj/main.o
clean:
if [ -d obj/ ]; then rm -r obj/; fi
if [ -f $(PROG) ]; then rm $(PROG); fi
Is this how I'm supposed to do it or is there a better way?