diff --git a/Makefile b/Makefile index 1398ad5..4485aec 100644 --- a/Makefile +++ b/Makefile @@ -1,11 +1,11 @@ .PHONY: all spec duktape libduktape clean cleanlib -CRYSTAL_BIN := $(shell which crystal) -SOURCES := $(shell find src -name '*.cr') +CRYSTAL_BIN := $(shell which crystal) +SOURCES := $(shell find src -name '*.cr') SPEC_SOURCES := $(shell find spec -name '*.cr') -CURRENT := $(shell pwd) -EXT := $(CURRENT)/src/ext -OUTPUT := $(CURRENT)/.build +CURRENT := $(shell pwd) +EXT := $(CURRENT)/src/ext +OUTPUT := $(CURRENT)/.build all: duktape duktape: $(OUTPUT)/duktape diff --git a/src/ext/Makefile b/src/ext/Makefile index 3ad3a32..53d3cf3 100644 --- a/src/ext/Makefile +++ b/src/ext/Makefile @@ -1,16 +1,28 @@ .PHONY: libduktape clean -CURRENT := $(shell pwd) -EXT := $(CURRENT) -PREV := $(shell dirname `pwd`]) -OUTPUT := $(PREV)/.build -LIBDIR := $(PREV)/.build/lib -INCLUDEDIR := $(PREV)/.build/include +CURRENT := $(shell pwd) +EXT := $(CURRENT) +PREV := $(shell dirname `pwd`]) +OUTPUT := $(PREV)/.build +LIBDIR := $(PREV)/.build/lib +INCLUDEDIR := $(PREV)/.build/include +DUK_OPTS = \ + -DDUK_OPT_DEEP_C_STACK \ + -DDUK_OPT_DEBUGGER_SUPPORT \ + -DDUK_OPT_INTERRUPT_COUNTER \ + -DDUK_OPT_FASTINT +CFLAGS = \ + -Wall \ + -c \ + -std=c99 \ + -Os \ + -fstrict-aliasing \ + -fomit-frame-pointer libduktape: $(OUTPUT)/libduktape.o $(LIBDIR)/libduktape.a $(INCLUDEDIR)/duktape.h $(OUTPUT)/libduktape.o: $(EXT)/duktape.c @mkdir -p $(OUTPUT) - gcc -o $@ $(EXT)/duktape.c -c -Wall -std=c99 -Os -fstrict-aliasing -fomit-frame-pointer -DDUK_OPT_DEEP_C_STACK -DDUK_OPT_DEBUGGER_SUPPORT -DDUK_OPT_INTERRUPT_COUNTER -DDUK_OPT_FASTINT + gcc -o $@ $(EXT)/duktape.c $(CFLAGS) $(DUK_OPTS) $(LIBDIR)/libduktape.a: @mkdir -p $(LIBDIR) ar rcs $(LIBDIR)/libduktape.a $(OUTPUT)/libduktape.o diff --git a/src/lib_duktape.cr b/src/lib_duktape.cr index cc58976..6a55325 100644 --- a/src/lib_duktape.cr +++ b/src/lib_duktape.cr @@ -4,7 +4,7 @@ # # This is free software. Please see LICENSE for details. -@[Link(ldflags: "-L#{__DIR__}/.build/lib -L#{__DIR__}/.build/include -lduktape")] +@[Link(ldflags: "-L#{__DIR__}/.build/lib -L#{__DIR__}/.build/include -lduktape -lm")] lib LibDUK alias Context = Void*