-
Notifications
You must be signed in to change notification settings - Fork 99
/
Makefile
39 lines (28 loc) · 808 Bytes
/
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
# Sources
LIB_SRC = src/ncurses.rs
LIB_DEPS = $(shell head -n1 target/.ncurses.deps 2> /dev/null)
EXAMPLES_SRC = $(wildcard examples/*.rs)
# Objects
LIB = target/$(shell rustc --print file-names ${LIB_SRC})
EXAMPLES_BIN = $(EXAMPLES_SRC:examples/%.rs=bin/%)
# CFG Directive Options
CFG_OPT ?= -O
SED_OPT=-i
ifeq ($(shell uname),Darwin)
SED_OPT=-i ''
endif
all: ${LIB} ${EXAMPLES_BIN}
lib: ${LIB}
link-ncursesw: CFG_OPT = --cfg ncursesw
link-ncursesw: all
${LIB}: ${LIB_DEPS}
@mkdir -p target
rustc ${CFG_OPT} --out-dir target ${LIB_SRC}
@rustc --emit dep-info target/.ncurses.deps ${LIB_SRC}
@sed ${SED_OPT} 's/.*: //' target/.ncurses.deps
${EXAMPLES_BIN}: bin/%: examples/%.rs ${LIB}
@mkdir -p bin
rustc --out-dir bin -L target $<
clean:
rm -rf target bin
.PHONY: all clean link-ncursesw