1 export LD_LIBRARY_PATH:=$(TMPDIR):$(LD_LIBRARY_PATH)
2 export DYLD_LIBRARY_PATH:=$(TMPDIR):$(DYLD_LIBRARY_PATH)
4 RUSTC := $(RUSTC) --out-dir $(TMPDIR) -L $(TMPDIR)
5 CC := $(CC) -L $(TMPDIR)
7 # These deliberately use `=` and not `:=` so that client makefiles can
8 # augment HOST_RPATH_DIR / TARGET_RPATH_DIR.
10 $(LD_LIB_PATH_ENVVAR)=$$$(LD_LIB_PATH_ENVVAR):$(HOST_RPATH_DIR)
12 $(LD_LIB_PATH_ENVVAR)=$$$(LD_LIB_PATH_ENVVAR):$(TARGET_RPATH_DIR)
14 # This is the name of the binary we will generate and run; use this
15 # e.g. for `$(CC) -o $(RUN_BINFILE)`.
16 RUN_BINFILE = $(TMPDIR)/$(1)
18 # RUN and FAIL are basic way we will invoke the generated binary. On
19 # non-windows platforms, they set the LD_LIBRARY_PATH environment
20 # variable before running the binary.
22 RLIB_GLOB = lib$(1)*.rlib
23 STATICLIB = $(TMPDIR)/lib$(1).a
24 STATICLIB_GLOB = lib$(1)*.a
27 UNAME = $(shell uname)
28 ifneq (,$(findstring MINGW,$(UNAME)))
32 ifeq ($(UNAME),Darwin)
33 RUN = $(TARGET_RPATH_ENV) $(RUN_BINFILE)
34 FAIL = $(TARGET_RPATH_ENV) $(RUN_BINFILE) && exit 1 || exit 0
35 DYLIB_GLOB = lib$(1)*.dylib
36 DYLIB = $(TMPDIR)/lib$(1).dylib
40 RUN = PATH="$(PATH):$(TARGET_RPATH_DIR)" $(RUN_BINFILE)
41 FAIL = PATH="$(PATH):$(TARGET_RPATH_DIR)" $(RUN_BINFILE) && exit 1 || exit 0
42 DYLIB_GLOB = $(1)*.dll
43 DYLIB = $(TMPDIR)/$(1).dll
46 RUSTC := PATH="$(PATH):$(LD_LIBRARY_PATH)" $(RUSTC)
48 RUN = $(TARGET_RPATH_ENV) $(RUN_BINFILE)
49 FAIL = $(TARGET_RPATH_ENV) $(RUN_BINFILE) && exit 1 || exit 0
50 DYLIB_GLOB = lib$(1)*.so
51 DYLIB = $(TMPDIR)/lib$(1).so
52 RPATH_LINK_SEARCH = -Wl,-rpath-link=$(1)
56 # Extra flags needed to compile a working executable with the standard library
60 ifeq ($(shell uname),Darwin)
62 ifeq ($(shell uname),FreeBSD)
63 EXTRACFLAGS := -lm -lpthread -lgcc_s
65 EXTRACFLAGS := -lm -lrt -ldl -lpthread
70 REMOVE_DYLIBS = rm $(TMPDIR)/$(call DYLIB_GLOB,$(1))
71 REMOVE_RLIBS = rm $(TMPDIR)/$(call RLIB_GLOB,$(1))
76 $(CC) -dynamiclib -Wl,-dylib -o $@ $<
78 $(CC) -o $@ $< -shared
80 $(CC) -o $@ $< -shared