-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
66 lines (47 loc) · 1.16 KB
/
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
UNAME_S := $(shell uname -s)
AS:= nasm
CC?= clang
LD:= ld
RM?= rm -f
DEBUG?= yes
NAME:= wolfasm
CFLAGS+= -I./include -march=native $(shell sdl2-config --cflags)
ASFLAGS+= -I./include/
LDFLAGS+=
# Add your OS flags here
ifeq ($(UNAME_S),Darwin)
SRC:= $(shell find -E ./src -regex '.*\.(asm|c)')
CFLAGS+= -Weverything
ASFLAGS+= -f macho64
LDFLAGS+= -lc -ldylib1.o -dynamic -lSDL2 -lSDL2_ttf -lSDL2_image -lSDL2_mixer \
-macosx_version_min 10.12
else ifeq ($(UNAME_S),Linux)
SRC:= $(shell find ./src -regextype posix-extended -regex ".*\.(asm|c)")
CFLAGS+=
ASFLAGS+= -f elf64
LDFLAGS+= -lc -lSDL2 -lSDL2_ttf -lSDL2_image -lSDL2_mixer -dynamic-linker /lib64/ld-linux-x86-64.so.2
else
$(error Unsupported operating system)
endif
ifeq ($(DEBUG),yes)
CFLAGS+= -O0 -g
ASFLAGS+= -O0 -g
else
CFLAGS+= -O2 -fomit-frame-pointer
ASFLAGS+= -O2
endif
OBJ_S:= $(SRC:%.asm=%.o)
OBJ_C:= $(SRC:%.c=%.o)
OBJ:= $(filter %.o, $(OBJ_C) $(OBJ_S))
$(NAME): $(OBJ)
$(LD) $(LDFLAGS) -o $(NAME) $(OBJ)
%.o: %.asm
$(AS) $(ASFLAGS) -o $@ $<
%.o: %.c
$(CC) $(CFLAGS) -c -o $@ $<
all: $(NAME)
clean:
$(RM) $(OBJ)
$(RM) $(NAME)
re: clean all
.PHONY: clean re all