From e2b025bdfc319b63b831a0d4ac337afd6d812958 Mon Sep 17 00:00:00 2001 From: Sami Samhuri Date: Sun, 24 Apr 2011 18:55:00 -0700 Subject: [PATCH] make it work on linux --- Makefile | 6 +++--- Readme.md | 4 ++-- src/Makefile | 4 ++-- test/Makefile | 18 +++++++++--------- test/laketest.c | 6 ++++-- 5 files changed, 20 insertions(+), 18 deletions(-) diff --git a/Makefile b/Makefile index 2ad0b30..4c0635e 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,8 @@ all: cd src && make all -lake: - cd src && make lake +liblake: + cd src && make liblake repl: cd src && make repl @@ -12,7 +12,7 @@ clean: -rm -f lake test: - cd src && make lake + cd src && make liblake cd test && make test_clean: diff --git a/Readme.md b/Readme.md index df2f04f..ccd9380 100644 --- a/Readme.md +++ b/Readme.md @@ -41,9 +41,9 @@ Hooray! That sure is repl-ish. If you want to build a static library: - $ make lake + $ make liblake -The binary will be in `build/lake.a` and you may do with it as you like. Lake creates no global variables and has no shared state. Everything is neatly wrapped up in a [`LakeCtx`](blob/master/src/lake.h#L120-128) so theoretically you can run multiple interpreters in the same process. I haven't tried it yet but it should work. +The binary will be in `build/liblake.a` and you may do with it as you like. Lake creates no global variables and has no shared state. Everything is neatly wrapped up in a [`LakeCtx`](blob/master/src/lake.h#L120-128) so theoretically you can run multiple interpreters in the same process. I haven't tried it yet but it should work. Tests ===== diff --git a/src/Makefile b/src/Makefile index 5bb711b..b4a007f 100644 --- a/src/Makefile +++ b/src/Makefile @@ -16,7 +16,7 @@ LAKE_OBJS = $(LAKE_BUILD)/comment.o \ $(LAKE_BUILD)/sym.o \ $(LAKE_BUILD)/symtable.o -all: lake repl +all: liblake repl repl: $(LAKE_OBJS) $(LAKE_BUILD)/repl.o $(CC) $(CFLAGS) $(LFLAGS) $^ -o $(LAKE_BUILD)/$@ @@ -25,7 +25,7 @@ $(LAKE_BUILD)/%.o: %.c @mkdir -p $(dir $@) $(CC) $(CFLAGS) -c $< -o $@ -lake: $(LAKE_OBJS) +liblake: $(LAKE_OBJS) rm -f $(LAKE_BUILD)/$@.a ar cq $(LAKE_BUILD)/$@.a $(LAKE_OBJS) diff --git a/test/Makefile b/test/Makefile index 17ed165..16dc86b 100644 --- a/test/Makefile +++ b/test/Makefile @@ -1,7 +1,7 @@ CC = gcc CFLAGS := -Wall -g -I../src $(shell pkg-config --cflags glib-2.0) LFLAGS := $(shell pkg-config --libs glib-2.0) -DEPS = laketest.o ../build/lake.a +OBJS = ../build/liblake.a TESTS = test_comment test_dlist test_env test_eval all: $(TESTS) @@ -13,17 +13,17 @@ all: $(TESTS) test: all -test_comment: $(DEPS) test_comment.o - $(CC) $(CFLAGS) $(LFLAGS) $^ -o $@ +test_comment: laketest.o test_comment.o + $(CC) $(CFLAGS) $(LFLAGS) $^ $(OBJS) -o $@ -test_dlist: $(DEPS) test_dlist.o - $(CC) $(CFLAGS) $(LFLAGS) $^ -o $@ +test_dlist: laketest.o test_dlist.o + $(CC) $(CFLAGS) $(LFLAGS) $^ $(OBJS) -o $@ -test_env: $(DEPS) test_env.o - $(CC) $(CFLAGS) $(LFLAGS) $^ -o $@ +test_env: laketest.o test_env.o + $(CC) $(CFLAGS) $(LFLAGS) $^ $(OBJS) -o $@ -test_eval: $(DEPS) test_eval.o - $(CC) $(CFLAGS) $(LFLAGS) $^ -o $@ +test_eval: laketest.o test_eval.o + $(CC) $(CFLAGS) $(LFLAGS) $^ $(OBJS) -o $@ clean: -rm -f *.o $(TESTS) diff --git a/test/laketest.c b/test/laketest.c index 9f7b9cd..e44e268 100644 --- a/test/laketest.c +++ b/test/laketest.c @@ -9,17 +9,19 @@ * */ +#include #include +#include #include "laketest.h" static void capture_output(void) { - int fd = fopen("./tmp", "w"); + int fd = open("./tmp", O_WRONLY); close(2); int newfd = dup(fd); close(fd); - fd = fopen("./tmp", "w"); + fd = open("./tmp", O_WRONLY); close(1); newfd = dup(fd); close(fd);