Last active
May 17, 2017 14:28
-
-
Save bisco/a87611145a2918822e81cd261a064dab to your computer and use it in GitHub Desktop.
C用Makefileのテンプレート
This file contains 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
SRCDIR = $(realpath .) | |
INCDIR = $(SRCDIR) | |
OBJDIR = $(SRCDIR) | |
IGNORE = $(SRCDIR)/ignore_file.c | |
SRCS = $(filter-out $(IGNORE),$(wildcard $(SRCDIR)/*.c)) | |
OBJS = $(subst $(SRCDIR),$(OBJDIR),$(SRCS:.c=.o)) | |
EXE = a.out | |
CC = gcc | |
MAKE = make | |
CFLAGS = -g -Wall -Wextra -Wpedantic -I$(INCDIR) | |
LDFLAGS = | |
.PHONY: default conf clean | |
default: conf $(EXE) | |
conf: | |
@echo "SRCDIR = " $(SRCDIR) | |
@echo "IGNORE = " $(IGNORE) | |
@echo "INCDIR = " $(INCDIR) | |
@echo "OBJDIR = " $(OBJDIR) | |
@echo "SRCS = " $(SRCS) | |
@echo "OBJS = " $(OBJS) | |
@echo "EXE = " $(EXE) | |
@echo "CC = " $(CC) | |
@echo "CFLAGS = " $(CFLAGS) | |
clean: | |
rm -f $(OBJS) $(EXE) | |
$(EXE): $(OBJS) | |
$(CC) $(CFLAGS) -o $@ $(OBJS) $(LDFLAGS) | |
$(OBJDIR)/%.o : $(SRCDIR)/%.c | |
[ -d $(OBJDIR) ] || mkdir -p $(OBJDIR) | |
$(CC) $(CFLAGS) -c -o $@ $< |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment