forked from pschachte/wybe
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
114 lines (86 loc) · 3.48 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
# File : Makefile
# Author : Peter Schachte
# Purpose : Build and install the Wybe compiler
# Configure these to your preferred installation locations
INSTALLBIN=/usr/local/bin
INSTALLLIB=/usr/local/lib/wybe
# You shouldn't need to edit anything below here
VERSION = 0.1
SRCDIR = src
LIBDIR = wybelibs
WYBELIBS = wybe.o command_line.o logging.o random.o benchmark.o
CLIBS = wybe/cbits.o
LIBS = $(WYBELIBS) $(CLIBS)
SHELL := /bin/bash
ifeq ($(shell uname), Darwin)
ISSYSROOT = -isysroot `xcrun --show-sdk-path`
# On Mac OS X, gtimeout is in homebrew coreutils package
TIMEOUT = gtimeout
endif
ifeq ($(shell uname), Linux)
ISSYSROOT =
TIMEOUT = timeout
endif
all: wybemk libs
install: wybemk
cp wybemk "$(INSTALLBIN)"
rm -rf "$(INSTALLLIB)"
mkdir -p "$(INSTALLLIB)"
cp -r "$(LIBDIR)/." "$(INSTALLLIB)"
"$(INSTALLBIN)/wybemk" --force-all $(addsuffix ", $(addprefix "$(INSTALLLIB)/,$(WYBELIBS)))
wybemk: $(SRCDIR)/*.hs $(SRCDIR)/Version.lhs
stack -j3 build && cp "`stack path --local-install-root`/bin/$@" "$@"
libs: $(addprefix $(LIBDIR)/,$(LIBS))
$(LIBDIR)/%.o: $(LIBDIR)/%.wybe wybemk
./wybemk --force-all -L $(LIBDIR) $@
$(LIBDIR)/wybe.o: wybemk $(LIBDIR)/wybe/*.wybe
./wybemk --force-all -L $(LIBDIR) $@
$(LIBDIR)/wybe/cbits.o: $(LIBDIR)/wybe/cbits.c
clang $(ISSYSROOT) -I /usr/local/include -c "$<" -o "$@"
$(SRCDIR)/Version.lhs: $(addprefix $(SRCDIR)/,*.hs)
@echo -e "Generating Version.lhs for version $(VERSION)"
@rm -f "$@"
@printf "Version.lhs automatically generated: DO NOT EDIT\n" > "$@"
@printf "\n" >> "$@"
@printf "> module Version (version,gitHash,buildDate,libDir) where\n\n" >> "$@"
@printf "> version :: String\n> version = \"%s\"\n\n" "$(VERSION)" >> "$@"
@printf "> gitHash :: String\n> gitHash = \"%s\"\n\n" "`git rev-parse --short HEAD`" >> "$@"
@printf "> buildDate :: String\n> buildDate = \"%s\"\n\n" "`date`" >> "$@"
@printf "> libDir :: String\n> libDir = \"%s\"\n\n" "$(INSTALLLIB)" >> "$@"
.PHONY: doc
doc: src/README.md
# Assemble README markdown source file automatically
src/README.md: src/*.hs Makefile src/README.md.intro src/README.md.outro
cat src/README.md.intro > "$@"
printf "The source files in this directory and their purposes are:\n\n" >> "$@"
printf "| File " >> "$@"
printf "| Purpose |\n" >> "$@"
printf "| ---------------------------- " >> "$@"
printf "| -------------------------------------------------------- |\n" >> "$@"
for f in src/*.hs ; do \
b=`basename $$f` ; \
m=`basename $$f .hs` ; \
printf "| `printf '%-29s' [$$b]\(#$$m\)`| " ; \
sed -n "s/^-- *Purpose *: *\(.*\)/\1/p" $$f | tr -d '\n' ; \
printf " |\n" ; \
done >> "$@"
printf "\n\n# Modules in more detail\n\n" >> "$@"
for f in src/*.hs ; do \
m=`basename $$f .hs` ; \
echo -e ; \
sed -E -e '/^-- *Purpose *:/{s/^-- *Purpose *:/## '"$$m -- "'/; G; p;}' -e '/BEGIN MAJOR DOC/,/END MAJOR DOC/{//d ; s/^-- ? ?//p;}' -e 'd' <$$f ; \
done >> "$@"
printf "\n\n" >> "$@"
cat src/README.md.outro >> "$@"
test: wybemk
@rm -f ERRS ; touch ERRS
@rm -f $(LIBDIR)/*.o $(LIBDIR)/wybe/*.o
@echo -e "Building $(LIBDIR)/wybe/cbits.o"
@make $(LIBDIR)/wybe/cbits.o
@printf "Testing building wybe library ("
@$(TIMEOUT) 40 $(MAKE) libs
@printf ") done.\n"
@time ( cd test-cases/ && ./run-all-test.sh )
clean:
stack clean
rm -f $(SRCDIR)/*.o $(SRCDIR)/*.hi $(SRCDIR)/Version.lhs documentation/*.pdf publications/*.pdf $(LIBDIR)/*.o $(LIBDIR)/wybe/*.o test-cases/*.o