Skip to content
Snippets Groups Projects
Commit 3d21a0aa authored by tanguy.cavagna's avatar tanguy.cavagna :desktop:
Browse files

Enhance makefile

parent c268e6b7
Branches
Tags
No related merge requests found
......@@ -6,21 +6,23 @@ LIBS = -lSDL2 -lm
TARGET = main
BIN = bin
# Create the bin directory when the makefile is parsed
$(shell mkdir -p $(BIN))
RUN = ./$(BIN)/$(TARGET)
# Get source and object
SOURCE = $(wildcard *.c)
OBJECT = $(patsubst %,$(BIN)/%, $(notdir $(SOURCE:.c=.o)))
# Convert the source in object
$(BIN)/%.o: %.c
# Convert the source in object, but before all, run `$(BIN)` aka mkdir
$(BIN)/%.o: %.c | $(BIN)
$(CC) $(CFLAGS) -c $< -o $@
# Create the target
$(BIN)/$(TARGET): $(OBJECT)
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) $(LIBS)
$(RUN)
$(BIN):
mkdir -p $(BIN)
# Echo the source and object values
help:
......@@ -29,7 +31,7 @@ help:
# Run the program
run:
./$(BIN)/$(TARGET)
$(RUN)
.PHONY: clean # Specify that the clean target is not a file
clean:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment