]> git.lizzy.rs Git - rust.git/blob - mk/rt.mk
doc: 'if' expressions no longer require parens
[rust.git] / mk / rt.mk
1 ######################################################################
2 # Runtime (C++) library variables
3 ######################################################################
4
5 RUNTIME_CS := rt/sync/timer.cpp \
6               rt/sync/sync.cpp \
7               rt/sync/lock_and_signal.cpp \
8               rt/rust.cpp \
9               rt/rust_builtin.cpp \
10               rt/rust_run_program.cpp \
11               rt/rust_crate_cache.cpp \
12               rt/rust_env.cpp \
13               rt/rust_scheduler.cpp \
14               rt/rust_task.cpp \
15               rt/rust_task_list.cpp \
16               rt/rust_chan.cpp \
17               rt/rust_port.cpp \
18               rt/rust_upcall.cpp \
19               rt/rust_uv.cpp \
20               rt/rust_log.cpp \
21               rt/rust_timer.cpp \
22               rt/circular_buffer.cpp \
23               rt/isaac/randport.cpp \
24               rt/rust_srv.cpp \
25               rt/rust_kernel.cpp \
26               rt/rust_shape.cpp \
27               rt/rust_obstack.cpp \
28               rt/rust_gc.cpp \
29               rt/rust_abi.cpp \
30               rt/rust_cc.cpp \
31               rt/rust_debug.cpp \
32               rt/memory_region.cpp \
33               rt/test/rust_test_harness.cpp \
34               rt/test/rust_test_runtime.cpp \
35               rt/test/rust_test_util.cpp \
36               rt/arch/i386/context.cpp \
37
38 RUNTIME_LL :=
39
40 RUNTIME_S := rt/arch/i386/_context.S \
41              rt/arch/i386/ccall.S
42
43 RUNTIME_HDR := rt/globals.h \
44                rt/rust.h \
45                rt/rust_abi.h \
46                rt/rust_cc.h \
47                rt/rust_debug.h \
48                rt/rust_gc.h \
49                rt/rust_internal.h \
50                rt/rust_util.h \
51                rt/rust_chan.h \
52                rt/rust_env.h \
53                rt/rust_obstack.h \
54                rt/rust_unwind.h \
55                rt/rust_upcall.h \
56                rt/rust_port.h \
57                rt/rust_scheduler.h \
58                rt/rust_shape.h \
59                rt/rust_task.h \
60                rt/rust_task_list.h \
61                rt/rust_log.h \
62                rt/circular_buffer.h \
63                rt/util/array_list.h \
64                rt/util/indexed_list.h \
65                rt/util/synchronized_indexed_list.h \
66                rt/util/hash_map.h \
67                rt/sync/sync.h \
68                rt/sync/timer.h \
69                rt/sync/lock_and_signal.h \
70                rt/sync/lock_free_queue.h \
71                rt/rust_srv.h \
72                rt/rust_kernel.h \
73                rt/memory_region.h \
74                rt/memory.h \
75                rt/test/rust_test_harness.h \
76                rt/test/rust_test_runtime.h \
77                rt/test/rust_test_util.h \
78                rt/arch/i386/context.h \
79
80 ifeq ($(CFG_WINDOWSY), 1)
81   LIBUV_OSTYPE := win
82   LIBUV_LIB := rt/libuv/Default/obj.target/src/rt/libuv/libuv.a
83 else ifeq ($(CFG_OSTYPE), apple-darwin)
84   LIBUV_OSTYPE := mac
85   LIBUV_LIB := rt/libuv/Default/libuv.a
86 else
87   LIBUV_OSTYPE := unix
88   LIBUV_LIB := rt/libuv/Default/obj.target/src/rt/libuv/libuv.a
89 endif
90
91 RUNTIME_DEF := rt/rustrt$(CFG_DEF_SUFFIX)
92 RUNTIME_INCS := -I $(S)src/rt/isaac -I $(S)src/rt/uthash \
93                 -I $(S)src/rt/arch/i386 -I $(S)src/rt/libuv/include
94 RUNTIME_OBJS := $(RUNTIME_CS:.cpp=.o) $(RUNTIME_LL:.ll=.o) $(RUNTIME_S:.S=.o)
95 RUNTIME_LIBS := $(LIBUV_LIB)
96
97 rt/%.o: rt/%.cpp $(MKFILES)
98         @$(call E, compile: $@)
99         $(Q)$(call CFG_COMPILE_C, $@, $(RUNTIME_INCS)) $<
100
101 rt/%.o: rt/%.S $(MKFILES)
102         @$(call E, compile: $@)
103         $(Q)$(call CFG_COMPILE_C, $@, $(RUNTIME_INCS)) $<
104
105 ifdef CFG_WINDOWSY
106 rt/main.ll: rt/main.ll.in
107         @$(call E, sed: $@)
108         $(Q)sed 's/MAIN/WinMain@16/' < $^ > $@
109 else
110 rt/main.ll: rt/main.ll.in
111         @$(call E, sed: $@)
112         $(Q)sed 's/MAIN/main/' < $^ > $@
113 endif
114
115 rt/%.o: rt/%.ll $(MKFILES)
116         @$(call E, llc: $@)
117         $(Q)$(LLC) -filetype=obj -relocation-model=pic -march=x86 -o $@ $<
118
119 rt/$(CFG_RUNTIME): $(RUNTIME_OBJS) $(MKFILES) $(RUNTIME_HDR) $(RUNTIME_DEF) $(RUNTIME_LIBS)
120         @$(call E, link: $@)
121         $(Q)$(call CFG_LINK_C,$@, $(RUNTIME_OBJS) \
122           $(CFG_GCCISH_POST_LIB_FLAGS) $(RUNTIME_LIBS) \
123           $(CFG_LIBUV_LINK_FLAGS),$(RUNTIME_DEF),$(CFG_RUNTIME))
124
125 # FIXME: For some reason libuv's makefiles can't figure out the correct definition
126 # of CC on the mingw I'm using, so we are explicitly using gcc. Also, we
127 # have to list environment variables first on windows... mysterious
128 $(LIBUV_LIB): $(wildcard \
129                      $(S)src/rt/libuv/* \
130                      $(S)src/rt/libuv/*/* \
131                      $(S)src/rt/libuv/*/*/* \
132                      $(S)src/rt/libuv/*/*/*/*)
133         $(Q)$(MAKE) -C $(S)mk/libuv/$(LIBUV_OSTYPE) \
134                 CFLAGS="-m32" LDFLAGS="-m32" \
135                 CC="$(CFG_GCCISH_CROSS)$(CC)" \
136                 CXX="$(CFG_GCCISH_CROSS)$(CXX)" \
137                 AR="$(CFG_GCCISH_CROSS)$(AR)" \
138                 builddir_name="$(CFG_BUILD_DIR)/rt/libuv" \
139                 V=$(VERBOSE) FLOCK= uv
140
141 # These could go in rt.mk or rustllvm.mk, they're needed for both.
142
143 %.linux.def:    %.def.in $(MKFILES)
144         @$(call E, def: $@)
145         $(Q)echo "{" > $@
146         $(Q)sed 's/.$$/&;/' $< >> $@
147         $(Q)echo "};" >> $@
148
149 %.darwin.def:   %.def.in $(MKFILES)
150         @$(call E, def: $@)
151         $(Q)sed 's/^./_&/' $< > $@
152
153 ifdef CFG_WINDOWSY
154 %.def:  %.def.in $(MKFILES)
155         @$(call E, def: $@)
156         $(Q)echo LIBRARY $* > $@
157         $(Q)echo EXPORTS >> $@
158         $(Q)sed 's/^./    &/' $< >> $@
159 endif