-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
48 lines (36 loc) · 1015 Bytes
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
CC = clang
ASM = nasm
LD = $(CC)
MKDIR = mkdir -p
RM = rm -rf
ASMFLAGS = -f elf64
SOLUTION_DIR = solution
BUILD = build
SRCDIR = $(SOLUTION_DIR)/src
INCDIR = $(SOLUTION_DIR)/include
OBJDIR = $(BUILD)/obj
TARGET = $(BUILD)/sepia-filter-test
$(BUILD):
$(MKDIR) $@
$(OBJDIR):
$(MKDIR) $@
OBJS_C = $(subst $(SRCDIR), $(OBJDIR), $(patsubst %.c, %.o, $(wildcard $(SRCDIR)/*.c)))
OBJS_ASM = $(subst $(SRCDIR), $(OBJDIR), $(patsubst %.asm, %.o, $(wildcard $(SRCDIR)/*.asm)))
INCLUDES = $(wildcard $(INCDIR)/*.h)
CFLAGS = $(strip $(file < $(SOLUTION_DIR)/compile_flags.txt))
# make c objects
$(OBJDIR)/%.o: $(SRCDIR)/%.c $(INCLUDES) | $(OBJDIR)
$(CC) -c $< -I $(INCDIR) -o $@ $(CFLAGS)
# make asm objects
$(OBJDIR)/%.o: $(SRCDIR)/%.asm $(INCLUDES) | $(OBJDIR)
$(ASM) $(ASMFLAGS) -o $@ $<
# %.o: %.asm
# $(ASM) $(ASMFLAGS) -o $@ $<
# link objects
$(TARGET): $(OBJS_C) $(OBJS_ASM) | $(BUILD)
$(LD) -lm -o $@ $^
.PHONY: clean all build-all
all: build-all
build-all: $(TARGET)
clean:
$(RM) $(OBJS_C) $(TARGET)