forked from ozra/onyx-lang
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
63 lines (48 loc) · 1.7 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
.PHONY: all spec onyx doc clean bootstrap
-include Makefile.local # for optional local options e.g. threads
O := .build
SOURCES := $(shell find src -name '*.cr')
SPEC_SOURCES := $(shell find spec -name '*.cr') $(shell find spec -name '*.ox')
FLAGS := $(if $(release),--release )$(if $(stats),--stats )$(if $(threads),--threads $(threads),--threads 3)
EXPORTS := $(if $(release),,CRYSTAL_CONFIG_PATH=`pwd`/src)
# EXPORTS := CRYSTAL_CONFIG_PATH=`pwd`/src
SHELL = /bin/bash
LLVM_CONFIG := $(shell command -v llvm-config-3.6 llvm-config-3.5 llvm-config | head -n 1)
LLVM_EXT_DIR = src/llvm/ext
LLVM_EXT_OBJ = $(LLVM_EXT_DIR)/llvm_ext.o
LIB_CRYSTAL_SOURCES = $(shell find src/ext -name '*.c')
LIB_CRYSTAL_OBJS = $(subst .c,.o,$(LIB_CRYSTAL_SOURCES))
LIB_CRYSTAL_TARGET = src/ext/libcrystal.a
CFLAGS += -fPIC
all: onyx
bootstrap:
./bootstrap.sh
install:
./install.sh
ifeq (${LLVM_CONFIG},)
$(error Could not locate llvm-config, make sure it is installed and in your PATH)
endif
spec: all_spec
$(O)/all_spec
doc:
$(BUILD_PATH) ./bin/cr-ox doc docs/main.cr
onyx: $(O)/onyx
all_spec: $(O)/all_spec
llvm_ext: $(LLVM_EXT_OBJ)
libcrystal: $(LIB_CRYSTAL_TARGET)
deps: llvm_ext libcrystal
$(O)/all_spec: deps $(SOURCES) $(SPEC_SOURCES)
@mkdir -p $(O)
$(BUILD_PATH) ./bin/cr-ox build $(FLAGS) -o $@ spec/all_spec.cr
$(O)/onyx: deps $(SOURCES)
@mkdir -p $(O)
$(BUILD_PATH) $(EXPORTS) ./bin/cr-ox build $(FLAGS) -o $@ src/compiler/onyx.cr -D without_openssl -D without_zlib
$(LLVM_EXT_OBJ): $(LLVM_EXT_DIR)/llvm_ext.cc
$(CXX) -c -o $@ $< `$(LLVM_CONFIG) --cxxflags`
$(LIB_CRYSTAL_TARGET): $(LIB_CRYSTAL_OBJS)
ar -rcs $@ $^
clean:
rm -rf $(O)
rm -rf ./doc
rm -rf $(LLVM_EXT_OBJ)
rm -rf $(LIB_CRYSTAL_OBJS) $(LIB_CRYSTAL_TARGET)