-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
57 lines (46 loc) · 1.6 KB
/
Copy pathMakefile
File metadata and controls
57 lines (46 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
.DEFAULT_GOAL := help
CFLAGS = -std=c99 -Wall -Wextra -Wno-unused-parameter -Wno-unused-function -Iinclude -I$(shell brew --prefix libuv)/include
LDFLAGS = -framework JavaScriptCore -L$(shell brew --prefix libuv)/lib -luv
SOURCES = $(shell find src -name "*.c")
## Build runtime
build:
@mkdir -p build
@clang $(CFLAGS) $(SOURCES) -o build/ragtime $(LDFLAGS)
@if [ -z "$(SILENT)" ]; then echo "Built binary at: $(shell pwd)/build/ragtime"; fi
## Clean build artifacts
clean:
rm -rf build compile_commands.json
## Show this help
help:
@./scripts/generate_help.sh $(MAKEFILE_LIST)
## Generate compile commands for LSP
lsp:
echo '[{"directory":"$(PWD)","command":"clang $(CFLAGS) $(SOURCES) $(LDFLAGS)","file":"src/main.c"}]' > compile_commands.json
## Run JS file (usage: make run FILE=path/to/file.js)
run: build
@if [ -z "$(FILE)" ]; then \
echo "Usage: make run FILE=path/to/file.js"; \
exit 1; \
fi
./build/ragtime $(FILE)
## Install dependencies for macOS
setup/mac:
@echo "Installing Xcode tools..."
xcode-select --install 2>/dev/null || echo "Xcode tools already installed"
@echo "Installing Homebrew..."
@command -v brew >/dev/null 2>&1 || /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
@echo "Installing libuv..."
brew install libuv
## Install dependencies for Linux (Ubuntu/Debian)
setup/linux:
sudo apt update
sudo apt install libuv1-dev build-essential
## Run tests
test:
@make build SILENT=1
@./tests/run_tests.sh
## Install git hooks
githooks:
@lefthook install
@echo "Git hooks installed"
.PHONY: build clean githooks help lsp run setup test