From c0d9bb4d8ff3aa062b7dcd10fed0334638764be1 Mon Sep 17 00:00:00 2001 From: Dimitri Fontaine Date: Tue, 29 Apr 2014 11:47:22 +0200 Subject: [PATCH] Allows to build pgloader image using CCL. Too many Makefile commands where hard-coded using SBCL, which prevented from building successfully against CCL. That's now fixed. --- Makefile | 32 +++++++++++++++++++++++--------- README.md | 26 ++++++++++++++++++-------- src/hooks.lisp | 8 ++++++++ src/main.lisp | 5 ++++- 4 files changed, 53 insertions(+), 18 deletions(-) diff --git a/Makefile b/Makefile index e797e77..ce89750 100644 --- a/Makefile +++ b/Makefile @@ -1,16 +1,31 @@ # pgloader build tool APP_NAME = pgloader -SBCL = sbcl -SBCL_OPTS = --no-sysinit --no-userinit +# use either sbcl or ccl +CL = sbcl + +ifeq ($(CL),sbcl) +CL_OPTS = --no-sysinit --no-userinit +else +CL_OPTS = --no-init +endif COMPRESS_CORE ?= yes +ifeq ($(CL),sbcl) ifeq ($(COMPRESS_CORE),yes) COMPRESS_CORE_OPT = --compress-core else COMPRESS_CORE_OPT = endif +endif + +ifeq ($(CL),sbcl) +BUILDAPP_OPTS = --require sb-posix \ + --require sb-bsd-sockets \ + --require sb-rotate-byte +endif + BUILDDIR = build LIBS = $(BUILDDIR)/libs.stamp @@ -35,14 +50,14 @@ qmynd: $(QLDIR)/local-projects/qmynd $(QLDIR)/setup.lisp: mkdir -p $(BUILDDIR) curl -o $(BUILDDIR)/quicklisp.lisp http://beta.quicklisp.org/quicklisp.lisp - $(SBCL) $(SBCL_OPTS) --load $(BUILDDIR)/quicklisp.lisp \ + $(CL) $(CL_OPTS) --load $(BUILDDIR)/quicklisp.lisp \ --eval '(quicklisp-quickstart:install :path "$(BUILDDIR)/quicklisp")' \ --eval '(quit)' quicklisp: $(QLDIR)/setup.lisp ; $(LIBS): quicklisp qmynd - $(SBCL) $(SBCL_OPTS) --load $(QLDIR)/setup.lisp \ + $(CL) $(CL_OPTS) --load $(QLDIR)/setup.lisp \ --eval '(ql:quickload "pgloader")' \ --eval '(quit)' touch $@ @@ -50,7 +65,7 @@ $(LIBS): quicklisp qmynd libs: $(LIBS) ; $(MANIFEST): libs - $(SBCL) $(SBCL_OPTS) --load $(QLDIR)/setup.lisp \ + $(CL) $(CL_OPTS) --load $(QLDIR)/setup.lisp \ --eval '(ql:write-asdf-manifest-file "$(MANIFEST)")' \ --eval '(quit)' @@ -58,7 +73,7 @@ manifest: $(MANIFEST) ; $(BUILDAPP): quicklisp mkdir -p $(BUILDDIR)/bin - $(SBCL) $(SBCL_OPTS) --load $(QLDIR)/setup.lisp \ + $(CL) $(CL_OPTS) --load $(QLDIR)/setup.lisp \ --eval '(ql:quickload "buildapp")' \ --eval '(buildapp:build-buildapp "$(BUILDAPP)")' \ --eval '(quit)' @@ -68,9 +83,8 @@ buildapp: $(BUILDAPP) ; $(PGLOADER): manifest buildapp mkdir -p $(BUILDDIR)/bin $(BUILDAPP) --logfile /tmp/build.log \ - --require sb-posix \ - --require sb-bsd-sockets \ - --require sb-rotate-byte \ + $(BUILDAPP_OPTS) \ + --sbcl $(CL) \ --asdf-path . \ --asdf-tree $(QLDIR)/local-projects \ --manifest-file $(MANIFEST) \ diff --git a/README.md b/README.md index 87dea84..997b092 100644 --- a/README.md +++ b/README.md @@ -77,16 +77,26 @@ Binary file for pgloader, named `pgloader.exe`: $ make pgloader -Note that the `Makefile` uses the `--compress-core` option, that should be -enabled in your local copy of `SBCL`. If that's not the case, it's probably -because you did compile and install `SBCL` yourself, so that you have a -decently recent version to use. Then you need to compile it with the -`--with-sb-core-compression` option. +By default, the `Makefile` uses [SBCL](http://sbcl.org/) to compile your +binary image, though it's possible to also build using +[CCL](http://ccl.clozure.com/). -You can also remove the `--compress-core` option by editing the `Makefile` -and removing the line where it appears. + $ make CC=ccl pgloader -The `make pgloader` command when successful outputs a `./build/pgloader.exe` +Note that the `Makefile` uses the `--compress-core` option when using SBCL, +that should be enabled in your local copy of `SBCL`. If that's not the case, +it's probably because you did compile and install `SBCL` yourself, so that +you have a decently recent version to use. Then you need to compile it with +the `--with-sb-core-compression` option. + +You can also remove the `--compress-core` option that way: + + $ make COMPRESS_CORE=no pgloader + +The `--compress-core` is unique to SBCL, so not used when `CC` is different +from the `sbcl` value. + +The `make pgloader` command when successful outputs a `./build/bin/pgloader` file for you to use. ## Usage diff --git a/src/hooks.lisp b/src/hooks.lisp index 4249420..9c949a5 100644 --- a/src/hooks.lisp +++ b/src/hooks.lisp @@ -11,6 +11,14 @@ (in-package #:cl-user) +#+ccl +(progn + (push (lambda () (cffi:close-foreign-library 'CL+SSL::LIBSSL)) + *save-exit-functions*) + + (push (lambda () (cffi:load-foreign-library 'CL+SSL::LIBSSL)) + *lisp-startup-functions*)) + #+sbcl (progn (push (lambda () (cffi:close-foreign-library 'CL+SSL::LIBSSL)) diff --git a/src/main.lisp b/src/main.lisp index 8dcb1a0..23daffe 100644 --- a/src/main.lisp +++ b/src/main.lisp @@ -116,7 +116,10 @@ (format t "tmpdir: ~s~%" *default-tmpdir*)) (when version - (format t "pgloader version ~s~%" *version-string*)) + (format t "pgloader version ~s~%" *version-string*) + (format t "compiled with ~a ~a~%" + (lisp-implementation-type) + (lisp-implementation-version))) (when help (usage argv))