Merge branch 'cmake'
This commit is contained in:
commit
3d6880d748
|
@ -1,9 +1,6 @@
|
|||
bin/*
|
||||
build/*
|
||||
src/lex.yy.c
|
||||
src/lex.yy.h
|
||||
src/y.tab.c
|
||||
src/y.tab.h
|
||||
lib/*
|
||||
.dir-locals.el
|
||||
GPATH
|
||||
GRTAGS
|
||||
|
|
|
@ -2,6 +2,8 @@ language: c
|
|||
compiler:
|
||||
- gcc
|
||||
- clang
|
||||
before_script:
|
||||
- cd build
|
||||
script:
|
||||
- make && make no-act
|
||||
- make debug && make no-act
|
||||
- cmake .. && make && make no-act
|
||||
- cmake -DCMAKE_BUILD_TYPE=Debug .. && make && make no-act
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
cmake_minimum_required(VERSION 2.8)
|
||||
|
||||
project(picrin)
|
||||
|
||||
# git submodule update --init
|
||||
execute_process(
|
||||
COMMAND ${GIT_EXECUTABLE} submodule update --init
|
||||
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
|
||||
)
|
||||
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY bin)
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY lib)
|
||||
set(CMAKE_C_FLAGS "-Wall -Wextra -std=c99")
|
||||
set(CMAKE_C_FLAGS_DEBUG "-DDEBUG=1")
|
||||
|
||||
# external libraries
|
||||
add_library(xfile SHARED extlib/xfile/xfile.c)
|
||||
|
||||
# build picrin
|
||||
include_directories(include extlib)
|
||||
include(src/CMakeLists.txt)
|
||||
include(tools/CMakeLists.txt)
|
||||
|
||||
# copy runtime files
|
||||
file(COPY piclib DESTINATION .)
|
||||
file(COPY etc DESTINATION .)
|
||||
|
||||
# $ make run
|
||||
add_custom_target(run bin/picrin DEPENDS repl)
|
||||
|
||||
# $ make no-act
|
||||
add_custom_target(no-act bin/picrin -e '' > /dev/null DEPENDS repl)
|
||||
|
||||
# $ make tak
|
||||
add_custom_target(tak bin/picrin etc/tak.scm DEPENDS repl)
|
||||
|
||||
# $ make lines
|
||||
add_custom_target(lines find . -name "*.[chyl]" | xargs wc -l WORKING_DIRECTORY ${PROJECT_SOURCE_DIR})
|
48
Makefile
48
Makefile
|
@ -1,48 +0,0 @@
|
|||
CFLAGS=-Wall -Wextra -std=c99
|
||||
|
||||
ifeq ($(findstring CYGWIN,$(shell uname -s)), CYGWIN)
|
||||
XFILE_LIB=cygxfile.dll
|
||||
PICRIN_LIB=cygpicrin.dll
|
||||
else
|
||||
XFILE_LIB=libxfile.so
|
||||
PICRIN_LIB=libpicrin.so
|
||||
endif
|
||||
|
||||
all: deps release
|
||||
|
||||
deps:
|
||||
git submodule update --init
|
||||
$(CC) $(CFLAGS) -shared -fPIC extlib/xfile/*.c -o lib/$(XFILE_LIB) -I./extlib/xfile
|
||||
|
||||
release: CFLAGS += -DDEBUG=0 -O3
|
||||
release: build
|
||||
|
||||
debug: CFLAGS += -g -DDEBUG=1 -O0
|
||||
debug: build
|
||||
|
||||
build: build-lib build-main
|
||||
|
||||
build-main:
|
||||
$(CC) $(CFLAGS) -D_GNU_SOURCE -Wl,-rpath lib tools/main.c -o bin/picrin -I./include -I./extlib -L./lib -lreadline -lm -lxfile -lpicrin
|
||||
|
||||
build-lib:
|
||||
cd src; \
|
||||
flex scan.l
|
||||
$(CC) $(CFLAGS) -shared -fPIC src/*.c -o lib/$(PICRIN_LIB) -I./include -I./extlib -L./lib -lm -lxfile
|
||||
|
||||
clean:
|
||||
rm -f src/lex.yy.c src/lex.yy.h
|
||||
rm -f lib/$(PICRIN_LIB)
|
||||
rm -f bin/picrin
|
||||
|
||||
run:
|
||||
bin/picrin
|
||||
|
||||
tak: release
|
||||
bin/picrin etc/tak.scm
|
||||
|
||||
lines: clean
|
||||
wc -l `find . -name "*.[chyl]"`
|
||||
|
||||
no-act:
|
||||
bin/picrin -e '' > /dev/null
|
25
README.md
25
README.md
|
@ -126,13 +126,22 @@ https://github.com/wasabiz/picrin
|
|||
|
||||
## How to use it
|
||||
|
||||
- make `Makefile`
|
||||
|
||||
Change directory to `build` then run `cmake` to create Makefile. Once `Makefile` is generated you can run `make` command to build picrin.
|
||||
|
||||
$ cd build
|
||||
$ cmake ..
|
||||
|
||||
Of course you don't need to move to `build` directory before running `cmake` (in that case `$ cmake .`), but I strongly recommend to follow above instruction.
|
||||
|
||||
- build
|
||||
|
||||
A built executable binary will be under bin/ directory and a shared library `libpicrin.so` under lib/.
|
||||
A built executable binary will be under bin/ directory and shared libraries under lib/.
|
||||
|
||||
$ make
|
||||
$ make
|
||||
|
||||
If you want to build picrin on other systems than x86_64, make sure PIC_NAN_BOXING flag is turned off (see include/config.h for detail).
|
||||
If you are building picrin on other systems than x86_64, PIC_NAN_BOXING flag is automatically turned on (see include/config.h for detail).
|
||||
|
||||
- run
|
||||
|
||||
|
@ -140,15 +149,15 @@ https://github.com/wasabiz/picrin
|
|||
|
||||
$ make run
|
||||
|
||||
- debug-run
|
||||
- debug
|
||||
|
||||
When `make` command is called with an argument `debug`, it builds the binary with all debug flags enabled (PIC_GC_STRESS, VM_DEBUG, DEBUG).
|
||||
If you execute `cmake` with debug flag `-DCMAKE_BUILD_TYPE=Debug`, it builds the binary with all debug flags enabled (PIC_GC_STRESS, VM_DEBUG, DEBUG).
|
||||
|
||||
$ make debug
|
||||
$ cmake -DCMAKE_BUILD_TYPE=Debug ..
|
||||
|
||||
- install
|
||||
|
||||
As of now picrin does not provide a command automatically installs the binary. If you want to place picrin library and binary in a parmanent directory, please do it by hand.
|
||||
As of this writing picrin does not provide a command automatically installs the binary. If you want to place picrin library and binary in a parmanent directory, please do it by hand. (TODO)
|
||||
|
||||
## Requirement
|
||||
|
||||
|
@ -157,7 +166,7 @@ picrin scheme depends on some external libraries to build the binary:
|
|||
- lex (preferably, flex)
|
||||
- readline (optional)
|
||||
|
||||
The compilation is tested only on Mac OSX. I think (or hope) it'll be ok to compile and run on other operating systems such as Linux or Windows, but there's no guarantee :(
|
||||
The compilation is tested only on Mac OSX and Ubuntu. I think (or hope) it'll be ok to compile and run on other operating systems such as Arch or Windows, but I don't guarantee :(
|
||||
|
||||
## Authors
|
||||
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
find_package(FLEX REQUIRED)
|
||||
flex_target(scan src/scan.l ${PROJECT_SOURCE_DIR}/src/lex.yy.c COMPILE_FLAGS --header-file="src/lex.yy.h")
|
||||
|
||||
add_library(picrin SHARED
|
||||
src/blob.c src/bool.c src/char.c src/codegen.c src/cont.c src/error.c
|
||||
src/file.c src/gc.c src/init.c src/lib.c src/load.c src/macro.c
|
||||
src/number.c src/pair.c src/port.c src/proc.c src/read.c src/state.c
|
||||
src/string.c src/symbol.c src/system.c src/time.c src/var.c src/vector.c
|
||||
src/vm.c src/write.c ${PROJECT_SOURCE_DIR}/src/lex.yy.c)
|
||||
target_link_libraries(picrin m xfile)
|
|
@ -29,7 +29,6 @@
|
|||
%option noyywrap
|
||||
|
||||
%option extra-type="struct parser_control *"
|
||||
%option header-file="lex.yy.h"
|
||||
%option never-interactive
|
||||
|
||||
/* comment */
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
add_executable(repl tools/main.c)
|
||||
set_target_properties(repl PROPERTIES OUTPUT_NAME picrin)
|
||||
target_link_libraries(repl picrin readline)
|
|
@ -5,7 +5,7 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <getopt.h>
|
||||
|
||||
#include "picrin.h"
|
||||
#include "picrin/pair.h"
|
||||
|
|
Loading…
Reference in New Issue