-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathMakefile
186 lines (116 loc) · 5.19 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
# Makefile for Orion-X3/Orion-X4/mx and derivatives
# Written in 2011
# This makefile is licensed under the WTFPL
WARNINGS := -Wno-unused-parameter -Wno-sign-conversion -Wno-padded -Wno-conversion -Wno-shadow -Wno-missing-noreturn -Wno-unused-macros -Wno-switch-enum -Wno-deprecated -Wno-format-nonliteral -Wno-trigraphs -Wno-unused-const-variable -Wdeprecated-declarations -Werror=return-type
GCCWARNINGS := -Wno-init-list-lifetime
CLANGWARNINGS := -Wno-undefined-func-template -Wno-comma -Wno-nullability-completeness -Wno-redundant-move -Wno-nested-anon-types -Wno-gnu-anonymous-struct -Wno-reserved-id-macro -Wno-extra-semi -Wno-gnu-zero-variadic-macro-arguments -Wno-shift-sign-overflow -Wno-exit-time-destructors -Wno-global-constructors -Wno-c++98-compat-pedantic -Wno-documentation-unknown-command -Wno-weak-vtables -Wno-c++98-compat -Wold-style-cast
SYSROOT := build/sysroot
PREFIX := usr/local
OUTPUTBIN := flaxc
OUTPUT := $(SYSROOT)/$(PREFIX)/bin/$(OUTPUTBIN)
CC ?= "clang"
CXX ?= "clang++"
LLVM_CONFIG ?= "llvm-config"
CXXSRC := $(shell find source external/tinyprocesslib -iname "*.cpp")
CXXOBJ := $(CXXSRC:.cpp=.cpp.o)
CXXDEPS := $(CXXSRC:.cpp=.cpp.d)
PRECOMP_HDRS := source/include/precompile.h
PRECOMP_GCH := $(PRECOMP_HDRS:.h=.h.gch)
FLXLIBLOCATION := $(SYSROOT)/$(PREFIX)/lib
FLXSRC := $(shell find libs -iname "*.flx")
NUMFILES := $$(($(words $(CXXSRC))))
DEFINES := -D__USE_MINGW_ANSI_STDIO=1
SANITISE :=
CXXFLAGS += -std=c++17 -fvisibility=hidden -O0 -g -c -Wall -frtti -fno-omit-frame-pointer $(SANITISE) $(DEFINES)
LDFLAGS += $(SANITISE) -fvisibility=hidden
UNAME_IDENT := $(shell uname)
COMPILER_IDENT := $(shell $(CC) --version | head -n 1)
ifeq ("$(UNAME_IDENT)","Darwin")
LIBFFI_CFLAGS := $(shell env PKG_CONFIG_PATH=/usr/local/opt/libffi/lib/pkgconfig pkg-config --cflags libffi)
LIBFFI_LDFLAGS := $(shell env PKG_CONFIG_PATH=/usr/local/opt/libffi/lib/pkgconfig pkg-config --libs libffi)
else
LIBFFI_CFLAGS := $(shell pkg-config --cflags libffi)
LIBFFI_LDFLAGS := $(shell pkg-config --libs libffi)
# on linux, we need to explicitly export our functions
# like __declspec(dllexport) except __attribute__((visibility("default")))
LDFLAGS += -Wl,--export-dynamic
endif
MPFR_CFLAGS := $(shell pkg-config --cflags mpfr)
MPFR_LDFLAGS := $(shell pkg-config --libs mpfr)
CXXFLAGS += $(MPFR_CFLAGS) $(LIBFFI_CFLAGS)
LDFLAGS += $(MPFR_LDFLAGS) $(LIBFFI_LDFLAGS)
ENABLE_CODE_COVERAGE ?= "yes"
ifneq (,$(findstring clang,$(COMPILER_IDENT)))
CXXFLAGS += -Xclang -fcolor-diagnostics $(SANITISE) $(CLANGWARNINGS)
ifeq ("$(ENABLE_CODE_COVERAGE)","yes")
CXXFLAGS += -fprofile-instr-generate -fcoverage-mapping
LDFLAGS += -fprofile-instr-generate -fcoverage-mapping
endif
else
CXXFLAGS += $(GCCWARNINGS)
ifeq ("$(ENABLE_CODE_COVERAGE)","yes")
CXXFLAGS += -fprofile-arcs -ftest-coverage
LDFLAGS += -lgcov
endif
endif
UTF8REWIND_AR := external/libutf8rewind.a
FLXFLAGS += -sysroot $(SYSROOT) --ffi-escape
SUPERTINYBIN := build/supertiny
GLTESTBIN := build/gltest
TESTBIN := build/tester
SUPERTINYSRC := build/supertiny.flx
GLTESTSRC := build/gltest.flx
TESTSRC := build/tester.flx
.DEFAULT_GOAL = jit
-include $(CXXDEPS)
-include source/include/precompile.h.d
.PHONY: copylibs jit compile clean build linux ci satest tiny
satest: build
@$(OUTPUT) $(FLXFLAGS) -run build/standalone.flx
tester: build
@$(OUTPUT) $(FLXFLAGS) -run build/tester.flx
ci: test
jit: build
@$(OUTPUT) $(FLXFLAGS) -run -o $(SUPERTINYBIN) $(SUPERTINYSRC)
compile: build
@$(OUTPUT) $(FLXFLAGS) -o $(SUPERTINYBIN) $(SUPERTINYSRC) -lm
test: build
@$(OUTPUT) $(FLXFLAGS) -run -o $(TESTBIN) $(TESTSRC)
repl: build
@$(OUTPUT) $(FLXFLAGS) -repl
gltest: build
@$(OUTPUT) $(FLXFLAGS) -run -framework GLUT -framework OpenGL -lsdl2 -o $(GLTESTBIN) $(GLTESTSRC)
build1:
build: build1 $(OUTPUT) copylibs
# built
build/%.flx: build
@$(OUTPUT) $(FLXFLAGS) -run -profile $@
copylibs: $(FLXSRC)
@mkdir -p $(FLXLIBLOCATION)/flaxlibs
@cp -R libs $(FLXLIBLOCATION)/
@rm -r $(FLXLIBLOCATION)/flaxlibs
@mv $(FLXLIBLOCATION)/libs $(FLXLIBLOCATION)/flaxlibs
$(OUTPUT): $(PRECOMP_GCH) $(CXXOBJ) $(COBJ) $(UTF8REWIND_AR)
@printf "# linking\n"
@mkdir -p $(dir $(OUTPUT))
@$(CXX) -o $@ $(CXXOBJ) $(COBJ) $(LDFLAGS) -Lexternal -L$(shell $(LLVM_CONFIG) --prefix)/lib $(shell $(LLVM_CONFIG) --system-libs --libs core engine native linker bitwriter lto vectorize all-targets object orcjit) -lmpfr -lgmp -lpthread -ldl -lffi -lutf8rewind
%.cpp.o: %.cpp
@$(eval DONEFILES += "CPP")
@printf "# compiling [$(words $(DONEFILES))/$(NUMFILES)] $<\n"
@$(CXX) $(CXXFLAGS) $(WARNINGS) -include source/include/precompile.h -Isource/include -Iexternal -I$(shell $(LLVM_CONFIG) --includedir) -MMD -MP -o $@ $<
%.h.gch: %.h
@printf "# precompiling header $<\n"
@$(CXX) $(CXXFLAGS) $(WARNINGS) -o $@ $< -MMD -MP
$(UTF8REWIND_AR):
@$(MAKE) -C external/utf8rewind all
# haha
clena: clean
clean:
@rm -f $(OUTPUT)
@find source -name "*.o" | xargs rm -f
@find source -name "*.gch*" | xargs rm -f
@find source -name "*.pch*" | xargs rm -f
@find source -name "*.c.m" | xargs rm -f
@find source -name "*.c.d" | xargs rm -f
@find source -name "*.cpp.m" | xargs rm -f
@find source -name "*.cpp.d" | xargs rm -f