summaryrefslogtreecommitdiffhomepage
path: root/shared.mk
diff options
context:
space:
mode:
authorAndrew Clayton <a.clayton@nginx.com>2023-08-02 17:03:48 +0100
committerAndrew Clayton <a.clayton@nginx.com>2023-08-21 23:24:12 +0100
commitd6ed6a219b31a58526721f96195c80061d41ce54 (patch)
tree17a1fd6ecf72a327916ff0f8bc7aaf85b981ceff /shared.mk
downloadunit-wasm-d6ed6a219b31a58526721f96195c80061d41ce54.tar.gz
unit-wasm-d6ed6a219b31a58526721f96195c80061d41ce54.tar.bz2
Initial commitv0.1.0
libunit-wasm and example C and Rust WebAssembly modules for NGINX Unit. Co-developed-by: Timo Stark <t.stark@nginx.com> Co-developed-by: Liam Crilly <liam@nginx.com> Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
Diffstat (limited to 'shared.mk')
-rw-r--r--shared.mk51
1 files changed, 51 insertions, 0 deletions
diff --git a/shared.mk b/shared.mk
new file mode 100644
index 0000000..5c2e112
--- /dev/null
+++ b/shared.mk
@@ -0,0 +1,51 @@
+# Some common Makefile stuff
+
+# Look for wasi-sysroot in some common places, falling back
+# to provided WASI_SYSROOT
+ifneq ("$(wildcard /usr/wasm32-wasi)", "")
+ # Fedora
+ WASI_SYSROOT ?= /usr/wasm32-wasi
+else ifneq ("$(wildcard /usr/local/share/wasi-sysroot)", "")
+ # FreeBSD
+ WASI_SYSROOT ?= /usr/local/share/wasi-sysroot
+endif
+
+# By default compiler etc output is hidden, use
+# make V=1 ...
+# to show it
+v = @
+ifeq ($V,1)
+ v =
+endif
+
+# Optionally enable debugging builds with
+# make D=1 ...
+# -g is always used, this just changes the optimisation level.
+# On GCC this would be -Og, however according to the clang-16(1)
+# man page, -O0 'generates the most debuggable code'.
+ifeq ($D,1)
+ CFLAGS += -O0
+else
+ CFLAGS += -O2
+endif
+
+# Optionally enable Werror with
+# make E=1 ...
+ifeq ($E,1)
+ CFLAGS += -Werror
+endif
+
+# Pretty print compiler etc actions...
+PP_CC = @echo ' CC '
+PP_AR = @echo ' AR '
+PP_CCLNK = @echo ' CCLNK '
+PP_GEN = @echo ' GEN '
+
+CC = clang
+CFLAGS += -Wall -Wextra -Wdeclaration-after-statement -Wvla \
+ -Wmissing-prototypes -Wstrict-prototypes -Wold-style-definition \
+ -Wimplicit-function-declaration -Wimplicit-int -Wint-conversion \
+ -std=gnu11 -g -fno-common -fno-strict-aliasing \
+ --target=wasm32-wasi --sysroot=$(WASI_SYSROOT)
+LDFLAGS = -Wl,--no-entry,--export=__heap_base,--export=__data_end,--export=malloc,--export=free,--stack-first,-z,stack-size=$$((8*1024*1024)) \
+ -mexec-model=reactor --rtlib=compiler-rt