]> git.proxmox.com Git - rustc.git/blob - src/test/run-make/tools.mk
Imported Upstream version 1.0.0-alpha.2
[rustc.git] / src / test / run-make / tools.mk
1 # These deliberately use `=` and not `:=` so that client makefiles can
2 # augment HOST_RPATH_DIR / TARGET_RPATH_DIR.
3 HOST_RPATH_ENV = \
4 $(LD_LIB_PATH_ENVVAR)="$(TMPDIR):$(HOST_RPATH_DIR):$($(LD_LIB_PATH_ENVVAR))"
5 TARGET_RPATH_ENV = \
6 $(LD_LIB_PATH_ENVVAR)="$(TMPDIR):$(TARGET_RPATH_DIR):$($(LD_LIB_PATH_ENVVAR))"
7
8 BARE_RUSTC := $(HOST_RPATH_ENV) $(RUSTC)
9 RUSTC := $(BARE_RUSTC) --out-dir $(TMPDIR) -L $(TMPDIR)
10 CC := $(CC) -L $(TMPDIR)
11 HTMLDOCCK := $(PYTHON) $(S)/src/etc/htmldocck.py
12
13 # This is the name of the binary we will generate and run; use this
14 # e.g. for `$(CC) -o $(RUN_BINFILE)`.
15 RUN_BINFILE = $(TMPDIR)/$(1)
16
17 # RUN and FAIL are basic way we will invoke the generated binary. On
18 # non-windows platforms, they set the LD_LIBRARY_PATH environment
19 # variable before running the binary.
20
21 RLIB_GLOB = lib$(1)*.rlib
22 STATICLIB = $(TMPDIR)/lib$(1).a
23 STATICLIB_GLOB = lib$(1)*.a
24 BIN = $(1)
25
26 UNAME = $(shell uname)
27 ifneq (,$(findstring MINGW,$(UNAME)))
28 IS_WINDOWS=1
29 endif
30
31 ifeq ($(UNAME),Darwin)
32 RUN = $(TARGET_RPATH_ENV) $(RUN_BINFILE)
33 FAIL = $(TARGET_RPATH_ENV) $(RUN_BINFILE) && exit 1 || exit 0
34 DYLIB_GLOB = lib$(1)*.dylib
35 DYLIB = $(TMPDIR)/lib$(1).dylib
36 RPATH_LINK_SEARCH =
37 else
38 ifdef IS_WINDOWS
39 RUN = PATH="$(PATH):$(TARGET_RPATH_DIR)" $(RUN_BINFILE)
40 FAIL = PATH="$(PATH):$(TARGET_RPATH_DIR)" $(RUN_BINFILE) && exit 1 || exit 0
41 DYLIB_GLOB = $(1)*.dll
42 DYLIB = $(TMPDIR)/$(1).dll
43 BIN = $(1).exe
44 RPATH_LINK_SEARCH =
45 else
46 RUN = $(TARGET_RPATH_ENV) $(RUN_BINFILE)
47 FAIL = $(TARGET_RPATH_ENV) $(RUN_BINFILE) && exit 1 || exit 0
48 DYLIB_GLOB = lib$(1)*.so
49 DYLIB = $(TMPDIR)/lib$(1).so
50 RPATH_LINK_SEARCH = -Wl,-rpath-link=$(1)
51 endif
52 endif
53
54 # Extra flags needed to compile a working executable with the standard library
55 ifdef IS_WINDOWS
56 EXTRACFLAGS := -lws2_32 -luserenv
57 else
58 ifeq ($(shell uname),Darwin)
59 else
60 ifeq ($(shell uname),FreeBSD)
61 EXTRACFLAGS := -lm -lpthread -lgcc_s
62 else
63 ifeq ($(shell uname),OpenBSD)
64 EXTRACFLAGS := -lm -lpthread
65 else
66 EXTRACFLAGS := -lm -lrt -ldl -lpthread
67 endif
68 endif
69 endif
70 endif
71
72 REMOVE_DYLIBS = rm $(TMPDIR)/$(call DYLIB_GLOB,$(1))
73 REMOVE_RLIBS = rm $(TMPDIR)/$(call RLIB_GLOB,$(1))
74
75 %.a: %.o
76 ar crus $@ $<
77 %.dylib: %.o
78 $(CC) -dynamiclib -Wl,-dylib -o $@ $<
79 %.so: %.o
80 $(CC) -o $@ $< -shared
81 %.dll: lib%.o
82 $(CC) -o $@ $< -shared
83
84 $(TMPDIR)/lib%.o: %.c
85 $(CC) -c -o $@ $<
86