Last active
January 8, 2017 01:49
-
-
Save koturn/8f6880acdfb769fa518cc69d5e2a408b to your computer and use it in GitHub Desktop.
簡易的なプログラムのためのMakefile
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
CXX := g++ -std=gnu++14 | |
CXXFLAGS := -Wall -Wextra -O3 -march=native -DNDEBUG | |
LDFLAGS := -s | |
TARGET := hoge | |
SRCS := $(wildcard *.cpp *.cxx *.cc) | |
OBJS := $(foreach PAT,%.cpp %.cxx %.cc,$(patsubst $(PAT),%.o,$(filter $(PAT),$(SRCS)))) | |
ifeq ($(OS),Windows_NT) | |
TARGET := $(addsuffix .exe, $(TARGET)) | |
else | |
TARGET := $(addsuffix .out, $(TARGET)) | |
endif | |
%.exe: | |
$(CXX) $(LDFLAGS) $(filter %.c %.cpp %.cxx %.cc %.o, $^) $(LDLIBS) -o $@ | |
%.out: | |
$(CXX) $(LDFLAGS) $(filter %.c %.cpp %.cxx %.cc %.o, $^) $(LDLIBS) -o $@ | |
.PHONY: all clean | |
all: $(TARGET) | |
$(TARGET): $(OBJS) | |
$(foreach SRC,$(SRCS),$(eval $(filter-out \,$(shell $(CXX) -MM $(SRC))))) | |
clean: | |
$(RM) $(TARGET) $(OBJS) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment