Last active
February 7, 2017 21:46
-
-
Save lithammer/cd06310c65ff4047928aae3b7623e0b5 to your computer and use it in GitHub Desktop.
Basic Makefile for C
This file contains hidden or 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
TARGET = <binary name> | |
CFLAGS = -g -Wall -Wextra $(OPTFLAGS) | |
CC ?= llvm-gcc | |
BUILDDIR = build | |
DISTDIR = dist | |
HEADERS := $(wildcard src/**/*.h src/*.h) | |
SRC := $(wildcard src/**/*.c src/*.c) | |
OBJS := $(SRC:.c=.o) | |
.PHONY: all | |
all: $(TARGET) | |
$(TARGET): $(OBJS) | |
$(CC) $(OBJS) -Wall $(LIBS) -o $@ | |
%.o: %.c $(HEADERS) | |
$(CC) $(CFLAGS) -c $< -o $@ | |
.PHONY: clean | |
clean: | |
@$(RM) -v $(OBJS) $(TARGET) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment