Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
Help us understand the problem. What is going on with this article?

Makefileテンプレ

More than 5 years have passed since last update.

-

# Makefile

# プログラム名とオブジェクトファイル名
TARGET = sandbox
OBJS = main.o

# 定義済マクロの再定義
CC = llvm-gcc
CFLAGS = -g -Wall
LDFLAGS = -lstdc++

# サフィックスルール適用対象の拡張子の定義
.SUFFIXES: .cpp .o

# プライマリターゲット
.PHONY: all
all: depend $(TARGET)

# プログラムの生成ルール
$(TARGET): $(OBJS)
    $(CC) $(LDFLAGS) -o $(TARGET) $^
    ls -al $(TARGET)

# サフィックスルール
.cpp.o:
    $(CC) $(CFLAGS) -c $<

# ファイル削除用ターゲット
.PHONY: clean
clean:
    $(RM) $(TARGET) $(OBJS) depend.inc

# 実行
.PHONY: run
run:
    ./$(TARGET)

depend:
    makedepend *.h *.cpp


BugDig
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away