makefile (2032B)
# note: needed both gcc and libgccjit
# macOS: brew install gcc libgccjit
# linux: sudo apt-get install build-essential gcc g++ libgccjit-14-dev
# update the prefix if needed
# Try Homebrew first (macOS)
BREW := $(shell command -v brew 2>/dev/null)
ifneq ($(BREW),)
LIBGCCJIT_PREFIX := $(shell brew --prefix libgccjit 2>/dev/null)
endif
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Darwin)
LIB := -I${LIBGCCJIT_PREFIX}/include -L${LIBGCCJIT_PREFIX}/lib/gcc/current -lgccjit
else
LIBGCCJIT_PREFIX := $(shell dirname $(shell gcc -print-file-name=libgccjit.so))
LIB := -I${LIBGCCJIT_PREFIX}/include -L${LIBGCCJIT_PREFIX} -lgccjit
endif
SRC = */*/*.c */*.c
BIN = oxc
STD = -std=c99
debug:
cc ${STD} -g -Wall -Wextra -o ${BIN} ${SRC} ${LIB}
default:
cc ${STD} -g -Wall -Wextra -Wno-unused-parameter -Wno-unused-function -fsanitize=address,undefined -o ${BIN} ${SRC} ${LIB} # -Wpedantic -Wshadow -Wconversion
fast:
cc ${STD} -O3 -ffast-math -DNDEBUG -march=native -mtune=native -flto -fomit-frame-pointer -fno-plt -fno-semantic-interposition -pipe \
-fno-trapping-math -Wl,-O3 ${LDFLAGS} -o ${BIN} ${SRC} ${LIB}
strip ${BIN}
clean:
rm -rf ${BIN} ${BIN}.* err.log
release: clean
cc ${STD} -O02 -Wall -Wshadow -Wextra -Wpedantic -Werror -o ${BIN} ${SRC} ${LIB}
check: clean
cc ${STD} -g -Wall -Wextra -fsanitize=address -fsanitize=undefined -o ${BIN} ${SRC} ${LIB}
# test: clean fast
# +@printf '%s\0' ex*.ox \
# | xargs -0 -P100 -n1 sh -c 'printf "%s\n" "$$1" 1>&2; exec ./$(BIN) --quiet "$$1" >/dev/null' sh
JOBS ?= $(shell nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || echo 16)
test: clean fast
+@find . -maxdepth 3 -name 'ex*.ox' -print0 \
| xargs -0 -r -P$(JOBS) -n1 sh -c 'printf "%s\n" "$$1" 1>&2; exec ./$(BIN) --quiet "$$1" >/dev/null' sh
test-slow: clean fast
+@find . -maxdepth 3 -name 'ex*.ox' -print0 \
| xargs -0 -r -P1 -n1 sh -c 'printf "%s\n" "$$1" 1>&2; exec ./$(BIN) --quiet "$$1" >/dev/null' sh
test-hmap: clean default
MallocNanoZone=0 ./oxc --test-hmap
again: clean default