Files
wren/Makefile

78 lines
1.8 KiB
Makefile
Raw Normal View History

AR = ar rcu
2014-01-23 23:29:50 -08:00
# Compiler flags.
CFLAGS = -std=c99 -Wall -Werror
# TODO: Add -Wextra.
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)
# Don't include main.c in the shared library.
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:
@rm -rf build wren wrend libwren.a libwrend.a
2014-04-26 08:07:03 -07:00
prep:
@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
# Debug shared lib
libwrend.a: $(DEBUG_OBJECTS)
$(AR) $@ $^
2014-04-26 08:07:03 -07:00
# Debug command-line interpreter.
wrend: build/debug/main.o libwrend.a
$(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)
$(CC) -c -fPIC $(CFLAGS) $(DEBUG_CFLAGS) -Iinclude -o $@ $<
2014-01-23 23:29:50 -08:00
# Release build.
release: prep wren
# Release shared lib
libwren.a: $(RELEASE_OBJECTS)
$(AR) $@ $^
2014-04-26 08:07:03 -07:00
# Release command-line interpreter.
wren: build/release/main.o libwren.a
$(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)
$(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.
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