1 # These deliberately use `=` and not `:=` so that client makefiles can
2 # augment HOST_RPATH_DIR / TARGET_RPATH_DIR.
4 $(LD_LIB_PATH_ENVVAR)="$(TMPDIR):$(HOST_RPATH_DIR):$($(LD_LIB_PATH_ENVVAR))"
6 $(LD_LIB_PATH_ENVVAR)="$(TMPDIR):$(TARGET_RPATH_DIR):$($(LD_LIB_PATH_ENVVAR))"
8 RUSTC := $(HOST_RPATH_ENV) $(RUSTC) --out-dir $(TMPDIR) -L $(TMPDIR)
9 CC := $(CC) -L $(TMPDIR)
11 # This is the name of the binary we will generate and run; use this
12 # e.g. for `$(CC) -o $(RUN_BINFILE)`.
13 RUN_BINFILE = $(TMPDIR)/$(1)
15 # RUN and FAIL are basic way we will invoke the generated binary. On
16 # non-windows platforms, they set the LD_LIBRARY_PATH environment
17 # variable before running the binary.
19 RLIB_GLOB = lib$(1)*.rlib
20 STATICLIB = $(TMPDIR)/lib$(1).a
21 STATICLIB_GLOB = lib$(1)*.a
24 UNAME = $(shell uname)
25 ifneq (,$(findstring MINGW,$(UNAME)))
29 ifeq ($(UNAME),Darwin)
30 RUN = $(TARGET_RPATH_ENV) $(RUN_BINFILE)
31 FAIL = $(TARGET_RPATH_ENV) $(RUN_BINFILE) && exit 1 || exit 0
32 DYLIB_GLOB = lib$(1)*.dylib
33 DYLIB = $(TMPDIR)/lib$(1).dylib
37 RUN = PATH="$(PATH):$(TARGET_RPATH_DIR)" $(RUN_BINFILE)
38 FAIL = PATH="$(PATH):$(TARGET_RPATH_DIR)" $(RUN_BINFILE) && exit 1 || exit 0
39 DYLIB_GLOB = $(1)*.dll
40 DYLIB = $(TMPDIR)/$(1).dll
44 RUN = $(TARGET_RPATH_ENV) $(RUN_BINFILE)
45 FAIL = $(TARGET_RPATH_ENV) $(RUN_BINFILE) && exit 1 || exit 0
46 DYLIB_GLOB = lib$(1)*.so
47 DYLIB = $(TMPDIR)/lib$(1).so
48 RPATH_LINK_SEARCH = -Wl,-rpath-link=$(1)
52 # Extra flags needed to compile a working executable with the standard library
54 EXTRACFLAGS := -lws2_32
56 ifeq ($(shell uname),Darwin)
58 ifeq ($(shell uname),FreeBSD)
59 EXTRACFLAGS := -lm -lpthread -lgcc_s
61 EXTRACFLAGS := -lm -lrt -ldl -lpthread
66 REMOVE_DYLIBS = rm $(TMPDIR)/$(call DYLIB_GLOB,$(1))
67 REMOVE_RLIBS = rm $(TMPDIR)/$(call RLIB_GLOB,$(1))
72 $(CC) -dynamiclib -Wl,-dylib -o $@ $<
74 $(CC) -o $@ $< -shared
76 $(CC) -o $@ $< -shared