Last active
July 27, 2023 01:26
-
-
Save michaelfm1211/8425e0f3bae0504530f5c3c2ea594075 to your computer and use it in GitHub Desktop.
generic makefile for simple c projects
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SRCS := $(wildcard *.c) | |
OBJS := $(SRCS:.c=.o) | |
PROG_NAME := example_placeholder | |
CFLAGS += -Wall -Wextra -c | |
LDFLAGS += | |
# Production | |
.PHONY: all | |
all: CLFAGS += -O2 | |
all: $(PROG_NAME) | |
# Development | |
.PHONY: debug | |
debug: CFLAGS += -O0 -g -fsanitize=address | |
debug: | |
$(CC) $(CFLAGS) $(LDFLAGS) -o $(PROG_NAME) $(SRCS) | |
%.o: %.c | |
@$(CC) $(CFLAGS) -o $@ $? | |
@echo "[CC] $@" | |
$(PROG_NAME): $(OBJS) | |
@$(CC) $(LDFLAGS) -o $(PROG_NAME) $^ | |
@echo "[LD] $@" | |
.PHONY: clean | |
clean: | |
rm -rf $(OBJS) $(PROG_NAME) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment