-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMakefile
More file actions
48 lines (34 loc) · 817 Bytes
/
Copy pathMakefile
File metadata and controls
48 lines (34 loc) · 817 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
48
SRCDIR = src
OBJDIR = build
VPATH = $(SRCDIR)
ASMSRCS = $(addsuffix /*.S, $(SRCDIR))
CCSRCS = $(addsuffix /*.c, $(SRCDIR))
ASRCS = $(wildcard $(ASMSRCS))
CSRCS = $(wildcard $(CCSRCS))
SRCS = $(ASRCS) $(CSRCS)
OBJS = $(addprefix $(OBJDIR)/, $(notdir $(ASRCS:.S=.o))) $(addprefix $(OBJDIR)/, $(notdir $(CSRCS:.c=.o)))
CC = gcc
AS = as
LD = ld
CFLAGS = -g
ASFLAGS = -g -o
LDFLAGS = -g -dynamic-linker /lib64/ld-linux-x86-64.so.2
LIBS = -lc -lSDLmain -lSDL
# Build rules
.PHONY: print all clean test
all: $(OBJDIR) a.out
$(OBJDIR):
mkdir $(OBJDIR)
$(OBJDIR)/%.o: %.c
$(CC) $(CFLAGS) -c $< -o $@
$(OBJDIR)/%.o: %.S
$(AS) $(ASFLAGS) $@ $<
a.out: $(OBJS)
$(LD) $(OBJS) $(LIBS) $(LDFLAGS)
clean:
rm -f a.out $(OBJDIR)/*.o *.o
print:
echo $(SRCS)
echo $(OBJS)
test:
gcc -fverbose-asm -O2 -S -c test.c