Skip to content

Commit

Permalink
Merge pull request #2 from jessedoyle/math-link
Browse files Browse the repository at this point in the history
Add -lm to native compile
  • Loading branch information
jessedoyle committed Sep 11, 2015
2 parents 4aa2252 + 65b802b commit 996b4f5
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 13 deletions.
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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
Expand Down
26 changes: 19 additions & 7 deletions src/ext/Makefile
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/lib_duktape.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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*

Expand Down

0 comments on commit 996b4f5

Please sign in to comment.