mirror of
https://github.com/samsonjs/lake.git
synced 2026-03-25 08:55:49 +00:00
use a build directory instead of polluting src/
This commit is contained in:
parent
e3a60f879b
commit
36d238914c
5 changed files with 46 additions and 24 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -1,6 +1,5 @@
|
|||
*.o
|
||||
lake
|
||||
lake.a
|
||||
build
|
||||
test/*
|
||||
!test/*.[ch]
|
||||
!test/Makefile
|
||||
|
|
|
|||
12
Makefile
12
Makefile
|
|
@ -1,12 +1,18 @@
|
|||
all:
|
||||
cd src && make clean && make
|
||||
mv src/lake ./lake
|
||||
cd src && make all
|
||||
|
||||
lake:
|
||||
cd src && make lake
|
||||
|
||||
repl:
|
||||
cd src && make repl
|
||||
|
||||
clean:
|
||||
cd src && make clean
|
||||
-rm -f lake
|
||||
|
||||
test:
|
||||
cd src && make lake.a
|
||||
cd src && make lake
|
||||
cd test && make
|
||||
|
||||
test_clean:
|
||||
|
|
|
|||
12
Readme.md
12
Readme.md
|
|
@ -12,11 +12,11 @@ Compiling & Running
|
|||
|
||||
Portable C99, only dep is glib, nothing to configure, no documentation!
|
||||
|
||||
Install glib 2.x using your package manager, for me it's either `brew install glib` or `sudo aptitude install glib`. Once you have glib just run:
|
||||
Install glib 2.x using your package manager, for me it's either `brew install glib` or `sudo aptitude install glib`. Once you have glib you can build the repl:
|
||||
|
||||
$ make && ./lake
|
||||
$ make repl && build/repl
|
||||
|
||||
That will drop you at a repl. There are booleans, symbols, integers, strings, lists, dotted lists (pairs), lambdas, a few special forms, and some primitive functions.
|
||||
There are booleans, symbols, integers, strings, lists, dotted lists (pairs), lambdas, a few special forms, and some primitive functions. You can evaluate these as you expect in a Scheme repl:
|
||||
|
||||
> #t
|
||||
#t
|
||||
|
|
@ -37,6 +37,12 @@ That will drop you at a repl. There are booleans, symbols, integers, strings, li
|
|||
|
||||
Hooray! That sure is repl-ish.
|
||||
|
||||
If you want to build a static library:
|
||||
|
||||
$ make lake
|
||||
|
||||
The binary will be in `build/lake.a` and you may do with it as you like.
|
||||
|
||||
Lake's special forms are:
|
||||
|
||||
* `quote`
|
||||
|
|
|
|||
37
src/Makefile
37
src/Makefile
|
|
@ -1,20 +1,33 @@
|
|||
LAKE_BUILD = ../build
|
||||
CC = gcc
|
||||
CFLAGS := -Wall -g $(shell pkg-config --cflags glib-2.0)
|
||||
LFLAGS := $(shell pkg-config --libs glib-2.0)
|
||||
LAKE_OBJS = env.o int.o str.o sym.o parse.o list.o eval.o \
|
||||
symtable.o fn.o dlist.o primitive.o comment.o lake.o
|
||||
OBJS = $(LAKE_OBJS) repl.o
|
||||
LAKE_OBJS = $(LAKE_BUILD)/comment.o \
|
||||
$(LAKE_BUILD)/dlist.o \
|
||||
$(LAKE_BUILD)/env.o \
|
||||
$(LAKE_BUILD)/eval.o \
|
||||
$(LAKE_BUILD)/fn.o \
|
||||
$(LAKE_BUILD)/int.o \
|
||||
$(LAKE_BUILD)/lake.o \
|
||||
$(LAKE_BUILD)/list.o \
|
||||
$(LAKE_BUILD)/parse.o \
|
||||
$(LAKE_BUILD)/primitive.o \
|
||||
$(LAKE_BUILD)/str.o \
|
||||
$(LAKE_BUILD)/sym.o \
|
||||
$(LAKE_BUILD)/symtable.o
|
||||
|
||||
all: lake
|
||||
all: lake repl
|
||||
|
||||
lake: $(OBJS)
|
||||
$(CC) $(CFLAGS) $(LFLAGS) $^ -o $@
|
||||
repl: $(LAKE_OBJS) $(LAKE_BUILD)/repl.o
|
||||
$(CC) $(CFLAGS) $(LFLAGS) $^ -o $(LAKE_BUILD)/$@
|
||||
|
||||
lake.a: $(LAKE_OBJS)
|
||||
rm -f $@
|
||||
ar cq $@ $(LAKE_OBJS)
|
||||
$(LAKE_BUILD)/%.o: %.c
|
||||
@mkdir -p $(dir $@)
|
||||
$(CC) $(CFLAGS) -c $< -o $@
|
||||
|
||||
lake: $(LAKE_OBJS)
|
||||
rm -f $(LAKE_BUILD)/$@.a
|
||||
ar cq $(LAKE_BUILD)/$@.a $(LAKE_OBJS)
|
||||
|
||||
# use touch to prevent errors in case files do not exist
|
||||
clean:
|
||||
@touch dummy.o lake
|
||||
rm -f *.o lake
|
||||
-rm -rf $(LAKE_BUILD)
|
||||
|
|
|
|||
|
|
@ -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 = minunit.h ../src/lake.a
|
||||
DEPS = minunit.h ../build/lake.a
|
||||
TESTS = test_comment test_dlist test_env
|
||||
|
||||
all: $(TESTS)
|
||||
|
|
@ -23,9 +23,7 @@ test_env: $(DEPS) test_env.o
|
|||
test_eval: $(DEPS) test_eval.o
|
||||
$(CC) $(CFLAGS) $(LFLAGS) $^ -o $@
|
||||
|
||||
# use touch to prevent errors in case files do not exist
|
||||
clean:
|
||||
@touch dummy.o $(TESTS)
|
||||
rm -f *.o $(TESTS)
|
||||
-rm -f *.o $(TESTS)
|
||||
|
||||
.PHONY: all $(TESTS)
|
||||
|
|
|
|||
Loading…
Reference in a new issue