Skip to content

Instantly share code, notes, and snippets.

@yui0
Created October 26, 2017 05:37
Show Gist options
  • Save yui0/32207dcac4ca95cad57aa88da4c09581 to your computer and use it in GitHub Desktop.
Save yui0/32207dcac4ca95cad57aa88da4c09581 to your computer and use it in GitHub Desktop.
Makefile template
# ©2017 YUICHIRO NAKADA
PROGRAM = hello
CC = clang
CPP = clang++
CFLAGS = -Wall -Os
CPPFLAGS= $(CFLAGS)
LDFLAGS =
CSRC = $(wildcard *.c)
CPPSRC = $(wildcard *.cpp)
DEPS = $(wildcard *.h) Makefile
OBJS = $(patsubst %.c,%.o,$(CSRC)) $(patsubst %.cpp,%.o,$(CPPSRC))
%.o: %.cpp $(DEPS)
$(CPP) -c -o $@ $< $(CPPFLAGS)
%.o: %.c $(DEPS)
$(CC) -c -o $@ $< $(CFLAGS)
$(PROGRAM): $(OBJS)
$(CPP) -o $@ $^ -s $(LDFLAGS)
.PHONY: clean
clean:
$(RM) $(PROGRAM) $(OBJS) *.o *.s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment