Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@ TOP_HEADERS = $(addprefix $(SRCPATH)/, $(HEADERS))
TOP_MJS_PUBLIC_HEADERS = $(addprefix $(SRCPATH)/, $(MJS_PUBLIC_HEADERS))
TOP_MJS_SOURCES = $(addprefix $(SRCPATH)/, $(MJS_SOURCES))
TOP_COMMON_SOURCES = $(addprefix $(SRCPATH)/, $(COMMON_SOURCES))
CFLAGS_MMAP ?= -DCS_MMAP

CFLAGS_EXTRA ?=
MFLAGS += -I. -Isrc -Isrc/frozen
MFLAGS += -DMJS_MAIN -DMJS_EXPOSE_PRIVATE -DCS_ENABLE_STDIO -DMJS_ENABLE_DEBUG -I../frozen
MFLAGS += $(CFLAGS_EXTRA)
CFLAGS += -lm -std=c99 -Wall -Wextra -pedantic -g $(MFLAGS)
COMMON_CFLAGS = -DCS_MMAP -DMJS_MODULE_LINES
CFLAGS += --std=c99 -Wall -Wextra -pedantic -g $(MFLAGS)
LDFLAGS ?=
COMMON_CFLAGS = $(CFLAGS_MMAP) -DMJS_MODULE_LINES
ASAN_CFLAGS = -fsanitize=address

.PHONY: all test test_full difftest ci-test
Expand All @@ -37,7 +39,8 @@ else
endif

ifeq ($(UNAME_S),Linux)
COMMON_CFLAGS += -Wl,--no-as-needed -ldl
COMMON_CFLAGS += -Wl,--no-as-needed
LDFLAGS += -ldl -lm
ASAN_CFLAGS += -fsanitize=leak
endif

Expand Down Expand Up @@ -81,7 +84,7 @@ CFLAGS += $(COMMON_CFLAGS)
# NOTE: we compile straight from sources, not from the single amalgamated file,
# in order to make sure that all sources include the right headers
$(PROG): $(TOP_MJS_SOURCES) $(TOP_COMMON_SOURCES) $(TOP_HEADERS) $(BUILD_DIR)
$(DOCKER_CLANG) clang $(CFLAGS) $(TOP_MJS_SOURCES) $(TOP_COMMON_SOURCES) -o $(PROG)
$(DOCKER_CLANG) clang $(CFLAGS) $(TOP_MJS_SOURCES) $(TOP_COMMON_SOURCES) $(LDFLAGS) -o $(PROG)

$(BUILD_DIR):
mkdir -p $@
Expand Down
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,17 @@ Hello 1234!

# Build stand-alone mJS binary

> [!NOTE]\
> By default, it starts Docker container to perform build.
> If you needn't that, you can disable Docker by passing `DOCKER_CLANG=`
> argument into the Make command: `make all DOCKER_CLANG=`

> [!NOTE]\
> On Windows, you have to use UNIX-like environment emulators (Cygwin/Msys2).
> Also, there can be problems with POSIX headers (like `sys/mman.h`).
> To fix this, you need to pass `CFLAGS_MMAP=` argument into the Make command:
> `make all CFLAGS_MMAP=`.

Build:
```
$ make
Expand Down