From 94603600a198d956c724430ab3e51b59be996976 Mon Sep 17 00:00:00 2001 From: Jesse Doyle Date: Wed, 9 Sep 2015 12:14:23 -0600 Subject: [PATCH 1/2] Add -lm to native compile --- src/ext/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ext/Makefile b/src/ext/Makefile index 3ad3a32..47618b4 100644 --- a/src/ext/Makefile +++ b/src/ext/Makefile @@ -10,7 +10,7 @@ INCLUDEDIR := $(PREV)/.build/include 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 -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 -lm $(LIBDIR)/libduktape.a: @mkdir -p $(LIBDIR) ar rcs $(LIBDIR)/libduktape.a $(OUTPUT)/libduktape.o From 65b802bff73fd69f4cf81dc853afefad7d5fd110 Mon Sep 17 00:00:00 2001 From: Jesse Doyle Date: Thu, 10 Sep 2015 13:26:27 -0600 Subject: [PATCH 2/2] cleanup makefiles and add -lm to ldflags --- Makefile | 10 +++++----- src/ext/Makefile | 26 +++++++++++++++++++------- src/lib_duktape.cr | 2 +- 3 files changed, 25 insertions(+), 13 deletions(-) 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 47618b4..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 -lm + 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*