Skip to content

Instantly share code, notes, and snippets.

@0xdeadbeer
Created November 12, 2023 11:37
Show Gist options
  • Save 0xdeadbeer/64fe68bab648723498ccabe558878ec7 to your computer and use it in GitHub Desktop.
Save 0xdeadbeer/64fe68bab648723498ccabe558878ec7 to your computer and use it in GitHub Desktop.
Example Makefile
CC=gcc
CFLAGS=
LDFLAGS=
TARGET=project
SDIR=src
ODIR=build
SRC=$(shell find $(SDIR) -type f -name *.c)
OBJ=$(SRC:.c=.o)
all: $(TARGET)
.PHONY: default
$(TARGET): $(OBJ)
mkdir -p build
$(CC) -o $(ODIR)/$@ $^ $(LDFLAGS)
%.o: %.c
$(CC) $(CFLAGS) -o $@ -c $<
.PHONY: clean
clean:
rm -f $(ODIR)/$(TARGET) $(OBJ)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment