-
Notifications
You must be signed in to change notification settings - Fork 1
/
GNUmakefile
72 lines (57 loc) · 1.66 KB
/
GNUmakefile
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
########################################
# Find which compilers are installed.
#
VOLT ?= $(shell which volt)
HOST_UNAME := $(strip $(shell uname))
HOST_MACHINE := $(strip $(shell uname -m))
UNAME ?= $(HOST_UNAME)
MACHINE ?= $(HOST_MACHINE)
########################################
# Basic settings.
#
VFLAGS ?= --no-stdlib -I %@execdir%/rt/src
TARGETS = \
bin/libwatt-x86_64-msvc.bc \
bin/libwatt-x86-linux.bc \
bin/libwatt-x86_64-linux.bc \
bin/libwatt-x86-osx.bc \
bin/libwatt-x86_64-osx.bc \
bin/libwatt-aarch64-osx.bc
BIN_TARGETS = \
bin/libwatt-x86_64-msvc.o \
bin/libwatt-x86-linux.o \
bin/libwatt-x86_64-linux.o \
bin/libwatt-x86-osx.o \
bin/libwatt-x86_64-osx.o \
bin/libwatt-aarch64-osx.o
########################################
# Setting up the source.
#
SRC = $(shell find src toml/src json/src -name "*.volt")
OBJ = $(patsubst src/%.v, $(OBJ_DIR)/%.bc, $(SRC))
########################################
# Targets.
#
all: $(TARGETS) $(BIN_TARGETS)
$(TARGETS): $(SRC) GNUmakefile
@echo " VOLT $@"
@mkdir -p bin
@$(VOLT) $(VFLAGS) --emit-bitcode -o $@ -I src $(SRC) \
--arch $(shell echo $@ | sed "s,bin/libwatt-\([^-]*\)-[^.]*.bc,\1,") \
--platform $(shell echo $@ | sed "s,bin/libwatt-[^-]*-\([^.]*\).bc,\1,")
bin/%.o : bin/%.bc
@echo " VOLT $@"
@$(VOLT) $(VFLAGS) -c -o $@ $? \
--arch $(shell echo $@ | sed "s,bin/libwatt-\([^-]*\)-[^.]*.o,\1,") \
--platform $(shell echo $@ | sed "s,bin/libwatt-[^-]*-\([^.]*\).o,\1,")
clean:
@rm -rf $(TARGETS) .obj
@rm -rf bin
@rm -rf .pkg
@rm -rf watt.tar.gz
package: all
@mkdir -p .pkg
@cp $(TARGETS) $(BIN_TARGETS) .pkg/
@cp -r ./src/* .pkg/
@tar -czf watt.tar.gz .pkg/*
.PHONY: all clean