# Variables
CC = gcc
SRC = main.c
BIN = main.o

# Because this is the first target in the makefile, it is the one that is run by make without specifying a target (the default target). It has the binary as the prerequisite, meaning that it checks if the binary is up to date
compile: $(BIN)

# By specifying prerequisites after the colon, make will check if the timestamp of the target is newer than the timestamps of all prerequisites. If so, it reports the target as 'up to date'. If not, it runs the command to update it.
$(BIN): $(SRC)
	$(CC) -g -o $(BIN) $(SRC)

run:
	./$(BIN)

clean:
	rm $(BIN)

# By default, make assumes every target name (like my_program, compile, or clean) is a file that will be generated by the commands beneath it. .PHONY overrides that, essentially alerting make to the presence of targets that do not have associated files. This directive can go anywhere in the makefile
.PHONY: run compile clean
