Source: Jacob Sorber

Setup Tips for Your Next Programming Project

“If it’s your job to eat a frog, it’s best to do it first thing in the morning. And if it’s your job to eat two frogs, it’s best to eat the biggest one first.” — Mark Twain

Do these 2 things at the start of every project.

More Tips for Setting up a Programming Project: Subdirectories and Structure

Example - directory

CC=clang
CFLAGS=-Wall -Wextra -Werror -g
SRC=src
OBJ=obj
OBJS=$(wildcard $(SRC)/*.c)
OBJS=$(patsubst $(SRC)/%.c, $(OBJ)/%.c, $(SRCS))

BINDIR=bin
BIN = bin/main
SUBMITNAME=project5.zip

all: $(BIN)

release: CFLAGS=-Wall -O2 -DNDEBUG
release: clean
release: $(BIN)

$(BIN): $(OBJS)
	$(CC) $(CFLAGS) $(OBJS) -o $@
	
obj/%.o: $(SRC)/%.c
	$(CC) $(CFLAGS) -c $< -o $@
	
clean:
	$(RM) -r $(BIN)/* $(OBJ)/*