use a build directory instead of polluting src/

This commit is contained in:
Sami Samhuri 2011-04-23 20:55:18 -07:00
parent e3a60f879b
commit 36d238914c
5 changed files with 46 additions and 24 deletions

3
.gitignore vendored
View file

@ -1,6 +1,5 @@
*.o *.o
lake build
lake.a
test/* test/*
!test/*.[ch] !test/*.[ch]
!test/Makefile !test/Makefile

View file

@ -1,12 +1,18 @@
all: all:
cd src && make clean && make cd src && make all
mv src/lake ./lake
lake:
cd src && make lake
repl:
cd src && make repl
clean: clean:
cd src && make clean cd src && make clean
-rm -f lake
test: test:
cd src && make lake.a cd src && make lake
cd test && make cd test && make
test_clean: test_clean:

View file

@ -12,11 +12,11 @@ Compiling & Running
Portable C99, only dep is glib, nothing to configure, no documentation! 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
#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. 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: Lake's special forms are:
* `quote` * `quote`

View file

@ -1,20 +1,33 @@
LAKE_BUILD = ../build
CC = gcc CC = gcc
CFLAGS := -Wall -g $(shell pkg-config --cflags glib-2.0) CFLAGS := -Wall -g $(shell pkg-config --cflags glib-2.0)
LFLAGS := $(shell pkg-config --libs 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 \ LAKE_OBJS = $(LAKE_BUILD)/comment.o \
symtable.o fn.o dlist.o primitive.o comment.o lake.o $(LAKE_BUILD)/dlist.o \
OBJS = $(LAKE_OBJS) repl.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) repl: $(LAKE_OBJS) $(LAKE_BUILD)/repl.o
$(CC) $(CFLAGS) $(LFLAGS) $^ -o $@ $(CC) $(CFLAGS) $(LFLAGS) $^ -o $(LAKE_BUILD)/$@
lake.a: $(LAKE_OBJS) $(LAKE_BUILD)/%.o: %.c
rm -f $@ @mkdir -p $(dir $@)
ar cq $@ $(LAKE_OBJS) $(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: clean:
@touch dummy.o lake -rm -rf $(LAKE_BUILD)
rm -f *.o lake

View file

@ -1,7 +1,7 @@
CC = gcc CC = gcc
CFLAGS := -Wall -g -I../src $(shell pkg-config --cflags glib-2.0) CFLAGS := -Wall -g -I../src $(shell pkg-config --cflags glib-2.0)
LFLAGS := $(shell pkg-config --libs 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 TESTS = test_comment test_dlist test_env
all: $(TESTS) all: $(TESTS)
@ -23,9 +23,7 @@ test_env: $(DEPS) test_env.o
test_eval: $(DEPS) test_eval.o test_eval: $(DEPS) test_eval.o
$(CC) $(CFLAGS) $(LFLAGS) $^ -o $@ $(CC) $(CFLAGS) $(LFLAGS) $^ -o $@
# use touch to prevent errors in case files do not exist
clean: clean:
@touch dummy.o $(TESTS) -rm -f *.o $(TESTS)
rm -f *.o $(TESTS)
.PHONY: all $(TESTS) .PHONY: all $(TESTS)