2015-01-02 14:59:52 -05:00
|
|
|
AR = ar rcu
|
2014-01-23 23:29:50 -08:00
|
|
|
# Compiler flags.
|
|
|
|
|
CFLAGS = -std=c99 -Wall -Werror
|
|
|
|
|
# TODO: Add -Wextra.
|
2015-01-12 10:01:34 -05:00
|
|
|
DEBUG_CFLAGS = -O0 -DDEBUG -g
|
2014-01-23 23:29:50 -08:00
|
|
|
RELEASE_CFLAGS = -Os
|
|
|
|
|
|
|
|
|
|
# Files.
|
|
|
|
|
SOURCES = $(wildcard src/*.c)
|
|
|
|
|
HEADERS = $(wildcard src/*.h)
|
|
|
|
|
OBJECTS = $(SOURCES:.c=.o)
|
|
|
|
|
|
2015-01-04 10:02:50 -08:00
|
|
|
# Don't include main.c in the shared library.
|
2015-01-02 14:59:52 -05:00
|
|
|
DEBUG_OBJECTS = $(subst build/debug/main.o,,$(addprefix build/debug/, $(notdir $(OBJECTS))))
|
|
|
|
|
RELEASE_OBJECTS = $(subst build/release/main.o,,$(addprefix build/release/, $(notdir $(OBJECTS))))
|
|
|
|
|
|
2014-01-23 23:29:50 -08:00
|
|
|
|
2014-04-26 08:07:03 -07:00
|
|
|
.PHONY: all clean test builtin docs watchdocs
|
2014-01-21 10:20:35 -06:00
|
|
|
|
2014-01-23 23:29:50 -08:00
|
|
|
all: release
|
|
|
|
|
|
2014-04-26 08:07:03 -07:00
|
|
|
clean:
|
2015-01-02 14:59:52 -05:00
|
|
|
@rm -rf build wren wrend libwren.a libwrend.a
|
2014-04-26 08:07:03 -07:00
|
|
|
|
|
|
|
|
prep:
|
2014-12-07 14:29:50 -08:00
|
|
|
@mkdir -p build/debug build/release
|
2014-04-26 08:07:03 -07:00
|
|
|
|
2014-01-23 23:29:50 -08:00
|
|
|
# Debug build.
|
|
|
|
|
debug: prep wrend
|
|
|
|
|
|
2015-01-02 14:59:52 -05:00
|
|
|
# Debug shared lib
|
|
|
|
|
libwrend.a: $(DEBUG_OBJECTS)
|
|
|
|
|
$(AR) $@ $^
|
|
|
|
|
|
2014-04-26 08:07:03 -07:00
|
|
|
# Debug command-line interpreter.
|
2015-01-02 14:59:52 -05:00
|
|
|
wrend: build/debug/main.o libwrend.a
|
2015-01-02 08:10:46 -05:00
|
|
|
$(CC) $(CFLAGS) $(DEBUG_CFLAGS) -Iinclude -o wrend $^ -lm
|
2014-01-23 23:29:50 -08:00
|
|
|
|
2014-04-26 08:07:03 -07:00
|
|
|
# Debug object files.
|
2014-01-23 23:29:50 -08:00
|
|
|
build/debug/%.o: src/%.c include/wren.h $(HEADERS)
|
2015-01-02 14:59:52 -05:00
|
|
|
$(CC) -c -fPIC $(CFLAGS) $(DEBUG_CFLAGS) -Iinclude -o $@ $<
|
2014-01-23 23:29:50 -08:00
|
|
|
|
|
|
|
|
# Release build.
|
|
|
|
|
release: prep wren
|
|
|
|
|
|
2015-01-02 14:59:52 -05:00
|
|
|
# Release shared lib
|
|
|
|
|
libwren.a: $(RELEASE_OBJECTS)
|
|
|
|
|
$(AR) $@ $^
|
|
|
|
|
|
2014-04-26 08:07:03 -07:00
|
|
|
# Release command-line interpreter.
|
2015-01-02 14:59:52 -05:00
|
|
|
wren: build/release/main.o libwren.a
|
2015-01-02 08:10:46 -05:00
|
|
|
$(CC) $(CFLAGS) $(RELEASE_CFLAGS) -Iinclude -o wren $^ -lm
|
2014-01-23 23:29:50 -08:00
|
|
|
|
2014-04-26 08:07:03 -07:00
|
|
|
# Release object files.
|
2014-01-23 23:29:50 -08:00
|
|
|
build/release/%.o: src/%.c include/wren.h $(HEADERS)
|
2015-01-02 14:59:52 -05:00
|
|
|
$(CC) -c -fPIC $(CFLAGS) $(RELEASE_CFLAGS) -Iinclude -o $@ $<
|
2014-01-21 10:20:35 -06:00
|
|
|
|
2014-01-23 23:29:50 -08:00
|
|
|
# Run the tests against the debug build of Wren.
|
2014-01-30 09:12:44 -08:00
|
|
|
test: debug
|
2014-02-02 10:30:58 -08:00
|
|
|
@./script/test.py $(suite)
|
2014-01-21 10:20:35 -06:00
|
|
|
|
2014-04-26 08:07:03 -07:00
|
|
|
# Take the contents of the scripts under builtin/ and copy them into their
|
|
|
|
|
# respective wren_<name>.c source files.
|
|
|
|
|
builtin:
|
|
|
|
|
@./script/generate_builtins.py
|
|
|
|
|
|
2014-01-23 23:29:50 -08:00
|
|
|
# Generate the Wren site.
|
2014-01-21 10:20:35 -06:00
|
|
|
docs:
|
2014-01-30 06:51:52 -08:00
|
|
|
@./script/generate_docs.py
|
|
|
|
|
|
|
|
|
|
# Continuously generate the Wren site.
|
|
|
|
|
watchdocs:
|
2014-01-23 23:29:50 -08:00
|
|
|
@./script/generate_docs.py --watch
|
2015-01-01 20:58:36 -08:00
|
|
|
|
|
|
|
|
# Build the docs and copy them to a local "gh-pages" directory.
|
|
|
|
|
gh-pages: docs
|
|
|
|
|
cp -r build/docs/. gh-pages
|