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_ORIGINAL := $(RUSTC)
9 BARE_RUSTC := $(HOST_RPATH_ENV) '$(RUSTC)'
10 BARE_RUSTDOC := $(HOST_RPATH_ENV) '$(RUSTDOC)'
11 RUSTC := $(BARE_RUSTC) --out-dir $(TMPDIR) -L $(TMPDIR) $(RUSTFLAGS)
12 RUSTDOC := $(BARE_RUSTDOC) -L $(TARGET_RPATH_DIR)
14 RUSTC := $(RUSTC) -Clinker=$(RUSTC_LINKER)
15 RUSTDOC := $(RUSTDOC) -Clinker=$(RUSTC_LINKER)
17 #CC := $(CC) -L $(TMPDIR)
18 HTMLDOCCK := $(PYTHON) $(S)/src/etc/htmldocck.py
19 CGREP := "$(S)/src/etc/cat-and-grep.sh"
21 # This is the name of the binary we will generate and run; use this
22 # e.g. for `$(CC) -o $(RUN_BINFILE)`.
23 RUN_BINFILE = $(TMPDIR)/$(1)
25 # RUN and FAIL are basic way we will invoke the generated binary. On
26 # non-windows platforms, they set the LD_LIBRARY_PATH environment
27 # variable before running the binary.
29 RLIB_GLOB = lib$(1)*.rlib
32 UNAME = $(shell uname)
34 ifeq ($(UNAME),Darwin)
35 RUN = $(TARGET_RPATH_ENV) $(RUN_BINFILE)
36 FAIL = $(TARGET_RPATH_ENV) $(RUN_BINFILE) && exit 1 || exit 0
37 DYLIB_GLOB = lib$(1)*.dylib
38 DYLIB = $(TMPDIR)/lib$(1).dylib
39 STATICLIB = $(TMPDIR)/lib$(1).a
40 STATICLIB_GLOB = lib$(1)*.a
43 RUN = PATH="$(PATH):$(TARGET_RPATH_DIR)" $(RUN_BINFILE)
44 FAIL = PATH="$(PATH):$(TARGET_RPATH_DIR)" $(RUN_BINFILE) && exit 1 || exit 0
45 DYLIB_GLOB = $(1)*.dll
46 DYLIB = $(TMPDIR)/$(1).dll
47 STATICLIB = $(TMPDIR)/$(1).lib
48 STATICLIB_GLOB = $(1)*.lib
50 LLVM_FILECHECK := $(shell cygpath -u "$(LLVM_FILECHECK)")
52 RUN = $(TARGET_RPATH_ENV) $(RUN_BINFILE)
53 FAIL = $(TARGET_RPATH_ENV) $(RUN_BINFILE) && exit 1 || exit 0
54 DYLIB_GLOB = lib$(1)*.so
55 DYLIB = $(TMPDIR)/lib$(1).so
56 STATICLIB = $(TMPDIR)/lib$(1).a
57 STATICLIB_GLOB = lib$(1)*.a
62 COMPILE_OBJ = $(CC) -c -Fo:`cygpath -w $(1)` $(2)
63 COMPILE_OBJ_CXX = $(CXX) -c -Fo:`cygpath -w $(1)` $(2)
64 NATIVE_STATICLIB_FILE = $(1).lib
65 NATIVE_STATICLIB = $(TMPDIR)/$(call NATIVE_STATICLIB_FILE,$(1))
66 OUT_EXE=-Fe:`cygpath -w $(TMPDIR)/$(call BIN,$(1))` \
67 -Fo:`cygpath -w $(TMPDIR)/$(1).obj`
69 COMPILE_OBJ = $(CC) -c -o $(1) $(2)
70 COMPILE_OBJ_CXX = $(CXX) -c -o $(1) $(2)
71 NATIVE_STATICLIB_FILE = lib$(1).a
72 NATIVE_STATICLIB = $(call STATICLIB,$(1))
73 OUT_EXE=-o $(TMPDIR)/$(1)
77 # Extra flags needed to compile a working executable with the standard library
80 EXTRACFLAGS := ws2_32.lib userenv.lib advapi32.lib
82 EXTRACFLAGS := -lws2_32 -luserenv
83 EXTRACXXFLAGS := -lstdc++
86 ifeq ($(UNAME),Darwin)
87 EXTRACFLAGS := -lresolv
89 ifeq ($(UNAME),FreeBSD)
90 EXTRACFLAGS := -lm -lpthread -lgcc_s
93 EXTRACFLAGS := -lm -lpthread -lposix4 -lsocket -lresolv
95 ifeq ($(UNAME),OpenBSD)
96 EXTRACFLAGS := -lm -lpthread -lc++abi
97 RUSTC := $(RUSTC) -C linker="$(word 1,$(CC:ccache=))"
99 EXTRACFLAGS := -lm -lrt -ldl -lpthread
100 EXTRACXXFLAGS := -lstdc++
107 REMOVE_DYLIBS = rm $(TMPDIR)/$(call DYLIB_GLOB,$(1))
108 REMOVE_RLIBS = rm $(TMPDIR)/$(call RLIB_GLOB,$(1))
114 $(MSVC_LIB) -out:`cygpath -w $@` $<
120 $(CC) -dynamiclib -Wl,-dylib -o $@ $<
122 $(CC) -o $@ $< -shared
126 $(CC) $< -link -dll -out:`cygpath -w $@`
129 $(CC) -o $@ $< -shared
132 $(TMPDIR)/lib%.o: %.c
133 $(call COMPILE_OBJ,$@,$<)