Created
January 23, 2014 13:28
-
-
Save denkiwakame/8578413 to your computer and use it in GitHub Desktop.
ヘッダ依存関係をなんtか
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
GCC = g++ | |
CFLAGS = -O2 -MMD -Wall -Wextra | |
SRCS = main.cpp sample.cpp | |
TARGET = main | |
OBJS = $(SRCS:.cpp=.o) | |
DEPS = $(SRCS:.cpp=.d) | |
.cpp.o: | |
$(GCC) $(CFLAGS) -c $< -o $@ | |
$(TARGET): $(OBJS) | |
$(GCC) $(CFLAGS) -o $@ $+ | |
default: $(OBJS) $(TARGET) | |
clean: | |
$(RM) $(OBJS) $(TARGET) | |
-include $(DEPS) | |
--------------------------------------------------------------------- | |
CXX=g++ | |
INCDIR=`pkg-config --libs opencv` | |
LIBDIR=`pkg-config --cflags opencv` | |
CFLAGS=-Wall | |
TARGETS=endecoder | |
SRCS=main.cpp | |
OBJS=$(SRCS:.cpp=.o) | |
DEPS=$(SRCS:.cpp=.d) | |
all: $(TARGETS) $(OBJS) | |
$(TARGETS): $(OBJS) | |
$(CXX) -o $@ $(OBJS) $(INCDIR) $(LIBDIR) | |
.cpp.o: | |
$(CXX) $(CFLAGS) -c -O2 -MMD $< $(INCDIR) $(LIBDIR) | |
clean: | |
rm -rf $(TARGETS) $(OBJS) *.gch *.d | |
-include $(DEPS) | |
.d 作って 最後に-include $(DEPS)しないとヘッダの更新に反応しなくてかなしみ
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
suffix
.cpp.o
cppからoつくるー
$< 依存ファイルで変更があったやつ
$(GCC) $ (CFLAGS) -c $< -o $ @
$@いまのターゲットのフルネーム(作ろうとしてるやつ)
-c リンクしない
-O2 optimization lv2 -O4:デバッグではちょっとやりすぎ
-c -o 以外はCFLAGS