Last active
August 23, 2016 09:03
-
-
Save hschlichter/31284857882cedcd0c95df45b917f3b4 to your computer and use it in GitHub Desktop.
Simple makefile for building C/C++ programs.
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
CC = clang++ | |
CFLAGS = -std=c++14 -O0 -g -Wall -MMD | |
LDFLAGS = | |
INCLUDE = -I. | |
LDINCLUDE = | |
SRCS = main.cpp\ | |
helper.cpp | |
OUTDIR = ./out | |
OBJS = $(foreach obj, $(SRCS:.cpp=.o), $(OUTDIR)/$(obj)) | |
# Main build rules. | |
.PHONY: all | |
all: $(OBJS) | |
$(CC) $^ -o $(OUTDIR)/main $(CFLAGS) $(INCLUDE) $(LDINCLUDE) $(LDFLAGS) | |
$(OBJS): $(OUTDIR)/%.o: %.cpp | |
$(CC) -c $(CFLAGS) -o $@ $< $(INCLUDE) | |
-include $(OBJS:%.o=%.d) | |
# Clean rules | |
.PHONY: clean | |
clean: | |
@rm -rf $(OUTDIR) | |
@mkdir $(OUTDIR) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment