1 # These variables are specifically meant to be overridable via
2 # the make command-line.
5 WASM_TARGET_FLAGS
= --target
=wasm32
10 # These variables describe the locations of various files and
11 # directories in the source tree.
13 BASICS_INC
= $(BASICS_DIR
)/include
14 BASICS_LIBC_DIR
= $(BASICS_DIR
)/libc
15 BASICS_LIBC_SOURCES
= $(BASICS_LIBC_DIR
)/string.c
16 DLMALLOC_DIR
= dlmalloc
17 DLMALLOC_SRC_DIR
= $(DLMALLOC_DIR
)/src
18 DLMALLOC_SOURCES
= $(DLMALLOC_SRC_DIR
)/wrapper.c
19 DLMALLOC_INC
= $(DLMALLOC_DIR
)/include
21 # Configure support for threads.
22 ifeq ($(THREADS
), single
)
23 WASM_CFLAGS
+= -mthread-model single
-DWASM_THREAD_MODEL_SINGLE
25 ifeq ($(THREADS
), posix
)
26 WASM_CFLAGS
+= -mthread-model posix
-DWASM_THREAD_MODEL_POSIX
32 mkdir
-p
"$(SYSROOT)/usr"
35 # Install the include files.
37 cp
-r
"$(BASICS_INC)" "$(SYSROOT)/usr"
40 # Build the C startup files.
43 "$(WASM_CC)" $(WASM_CFLAGS
) $(WASM_TARGET_FLAGS
) --sysroot
="$(SYSROOT)" -c
$(BASICS_LIBC_DIR
)/crt
*.s
44 mkdir
-p
"$(SYSROOT)/lib"
45 mv
*.o
"$(SYSROOT)/lib"
48 # Compile and install the libc-subset source files.
51 "$(WASM_CC)" $(WASM_CFLAGS
) $(WASM_TARGET_FLAGS
) --sysroot
="$(SYSROOT)" -c
$(BASICS_LIBC_SOURCES
)
52 mkdir
-p
"$(SYSROOT)/lib"
53 $(AR
) crs
"$(SYSROOT)/lib/libc-basics.a" *.o
57 # Compile and install the dlmalloc source files.
60 "$(WASM_CC)" $(WASM_CFLAGS
) $(WASM_TARGET_FLAGS
) --sysroot
="$(SYSROOT)" -c
$(DLMALLOC_SOURCES
) -I
$(DLMALLOC_INC
)
61 mkdir
-p
"$(SYSROOT)/lib"
62 $(AR
) crs
"$(SYSROOT)/lib/libc-dlmalloc.a" *.o