-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile.old
66 lines (53 loc) · 1.51 KB
/
Makefile.old
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
TARGETS = aphelion
SRCPATHS = \
src/common/*.c \
src/mars/*.c \
src/mars/phobos/*.c \
src/mars/phobos/analysis/*.c \
src/mars/phobos/parse/*.c \
\
src/iron/*.c \
src/iron/io/*.c \
src/iron/passes/*.c \
src/iron/passes/analysis/*.c \
src/iron/passes/transform/*.c \
src/iron/arch/*.c \
# src/llta/*.c
SRCPATHS += $(foreach target, $(TARGETS), src/iron/arch/$(target)/*.c)
SRC = $(wildcard $(SRCPATHS))
OBJECTS = $(SRC:src/%.c=build/%.o)
EXECUTABLE_NAME = mars
ECHO = echo
ifeq ($(OS),Windows_NT)
EXECUTABLE_NAME = mars.exe
else
ECHO = /usr/bin/echo
# JANK FIX FOR SANDWICH'S DUMB ECHO ON HIS LINUX MACHINE
endif
CC = gcc
LD = gcc
INCLUDEPATHS = -Isrc
DEBUGFLAGS = -pg -g
ASANFLAGS = -fsanitize=undefined -fsanitize=address
CFLAGS = -std=c17 -MD -D_XOPEN_SOURCE=700 -fwrapv \
-fno-delete-null-pointer-checks -fno-strict-overflow -fno-strict-aliasing \
-Wall -Wno-format -Wno-unused -Werror=incompatible-pointer-types -Wno-discarded-qualifiers \
OPT = -O3
FILE_NUM = 0
build/%.o: src/%.c
$(eval FILE_NUM=$(shell echo $$(($(FILE_NUM)+1))))
$(shell $(ECHO) 1>&2 -e "\e[0m[\e[32m$(FILE_NUM)/$(words $(SRC))\e[0m]\t Compiling \e[1m$<\e[0m")
@$(CC) -c -o $@ $< $(INCLUDEPATHS) $(CFLAGS) $(OPT)
build: $(OBJECTS)
@echo Linking with $(LD)...
@$(LD) $(OBJECTS) -o $(EXECUTABLE_NAME) $(CFLAGS) -lm
@echo Successfully built: $(EXECUTABLE_NAME)
debug: CFLAGS += $(DEBUGFLAGS)
debug: OPT = -O0
debug: build
clean:
@rm -rf build/
@mkdir build/
@mkdir -p $(dir $(OBJECTS))
cleanbuild: clean build
-include $(OBJECTS:.o=.d)