-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakefile
More file actions
47 lines (34 loc) · 934 Bytes
/
makefile
File metadata and controls
47 lines (34 loc) · 934 Bytes
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
# A simple Makefile for compiling small SDL projects
# # set the compiler
# CC := clang
# set the compiler flags
#
#
CFLAGS := -ggdb3 --std=c99 -Wall -Wextra -pedantic -Iinclude
SDL := `sdl2-config --cflags --libs` -lSDL2_image
HDRS := $(wildcard include/*.h)
SRC := $(wildcard src/*.c)
ODIR := obj
_OBJS := main.o chip8.o display.o instruction.o
OBJS := $(patsubst %,$(ODIR)/%,$(_OBJS))
CLEANUP := chip8 *.core
# name of executable
EXEC := chip8
# default recipe
all: $(EXEC)
# recipe for building object files
$(ODIR)/%.o: src/%.c $(HDRS)
@mkdir -p $(@D)
$(CC) $(CFLAGS) -MMD -c -o $@ $<
# recipe for building the final executable
$(EXEC): $(OBJS) $(HDRS) makefile
$(CC) -o $@ $(OBJS) $(SDL) $(CFLAGS)
# recipe for running test rom
test: $(EXEC)
-@./$(EXEC) test/jumpingXO.ch8 2>/dev/null || true
# recipe for cleaning workspace
clean:
@rm -f $(CLEANUP)
@rm -rf $(ODIR)
.PHONY: all clean
-include $(ODIR)/*.d