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 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
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)
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.
21 RLIB_GLOB = lib$(1)*.rlib
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
34 STATICLIB = $(TMPDIR)/lib$(1).a
35 STATICLIB_GLOB = lib$(1)*.a
38 RUN = PATH="$(PATH):$(TARGET_RPATH_DIR)" $(RUN_BINFILE)
39 FAIL = PATH="$(PATH):$(TARGET_RPATH_DIR)" $(RUN_BINFILE) && exit 1 || exit 0
40 DYLIB_GLOB = $(1)*.dll
41 DYLIB = $(TMPDIR)/$(1).dll
42 STATICLIB = $(TMPDIR)/$(1).lib
43 STATICLIB_GLOB = $(1)*.lib
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 STATICLIB = $(TMPDIR)/lib$(1).a
51 STATICLIB_GLOB = lib$(1)*.a
56 COMPILE_OBJ = $(CC) -c -Fo:`cygpath -w $(1)` $(2)
57 NATIVE_STATICLIB_FILE = $(1).lib
58 NATIVE_STATICLIB = $(TMPDIR)/$(call NATIVE_STATICLIB_FILE,$(1))
59 OUT_EXE=-Fe:`cygpath -w $(TMPDIR)/$(call BIN,$(1))` \
60 -Fo:`cygpath -w $(TMPDIR)/$(1).obj`
62 COMPILE_OBJ = $(CC) -c -o $(1) $(2)
63 NATIVE_STATICLIB_FILE = lib$(1).a
64 NATIVE_STATICLIB = $(call STATICLIB,$(1))
65 OUT_EXE=-o $(TMPDIR)/$(1)
69 # Extra flags needed to compile a working executable with the standard library
72 EXTRACFLAGS := ws2_32.lib userenv.lib shell32.lib advapi32.lib
74 EXTRACFLAGS := -lws2_32 -luserenv
77 ifeq ($(UNAME),Darwin)
79 ifeq ($(UNAME),FreeBSD)
80 EXTRACFLAGS := -lm -lpthread -lgcc_s
82 ifeq ($(UNAME),Bitrig)
83 EXTRACFLAGS := -lm -lpthread
84 EXTRACXXFLAGS := -lc++ -lc++abi
86 ifeq ($(UNAME),OpenBSD)
87 EXTRACFLAGS := -lm -lpthread
88 # extend search lib for found estdc++ if build using gcc from
89 # ports under OpenBSD. This is needed for:
90 # - run-make/execution-engine
91 # - run-make/issue-19371
92 RUSTC := $(RUSTC) -L/usr/local/lib
94 EXTRACFLAGS := -lm -lrt -ldl -lpthread
95 EXTRACXXFLAGS := -lstdc++
102 REMOVE_DYLIBS = rm $(TMPDIR)/$(call DYLIB_GLOB,$(1))
103 REMOVE_RLIBS = rm $(TMPDIR)/$(call RLIB_GLOB,$(1))
110 $(CC) -dynamiclib -Wl,-dylib -o $@ $<
112 $(CC) -o $@ $< -shared
116 $(CC) $< -link -dll -out:`cygpath -w $@`
119 $(CC) -o $@ $< -shared
122 $(TMPDIR)/lib%.o: %.c
123 $(call COMPILE_OBJ,$@,$<)