Commit ff2b108a authored by Francois-Rene Rideau's avatar Francois-Rene Rideau
Browse files

Add cl-shim, a tiny binary to enable #!/usr/bin/cl on BSD.

parent cdde94b4
# Generated during a (debian) build
# Generated during a build
build.xcvb
cl-launch
cl-launch.asd
launcher.lisp
wrapper.sh
cl-shim
# Generated when compiling with e.g. SLIME
*.*f*sl
......
......@@ -21,3 +21,12 @@ in the shell function do_tests, which will double the testing time, currently
over an hour for me.
Happy hacking!
Bibliography:
* For how #! works, see the NetBSD man page on "script" in section 7: man 7 script
http://netbsd.gw.com/cgi-bin/man-cgi?script+7+NetBSD-current
Note that Linux recursively accepts a shell script as a script interpreter,
and therefore does not need the cl-shim binary, whereas
while MacOS splits the argument of a #! script by spaces.
......@@ -74,3 +74,5 @@ TODO for cl-launch as of 4.0.6
** on ECL, we still have to create temporary files for --eval,
but we still don't want to have other systems depend on them
except the top-level one.
* Change manual so it starts with the minimum needed to use it.
......@@ -16,7 +16,7 @@ source:
@echo "Building Lisp source code for cl-launch in current directory"
@${CL_LAUNCH} --include ${PWD} -B install_path > /dev/null
install: install_binary install_source install_system
install: install_binary install_source install_system install_cl
install_binary: install_binary_standalone
......@@ -49,6 +49,18 @@ install_binary_with_include:
--lisp '$(LISPS)' \
--output ${INSTALL_BIN}/cl-launch -B install_bin > /dev/null
cl-shim: cl-shim.c
cc -Os -W -Wall -Werror -DCL_LAUNCH_SCRIPT="\"${INSTALL_BIN}/cl-launch\"" -o $@ $<
ifeq($(shell uname), Linux)
install_cl: install_binary
ln -s cl-launch ${INSTALL_BIN}/cl
else
install_cl: cl-shim
cp -p cl-shim ${INSTALL_BIN}/cl
endif
clean:
git clean -xfd
......
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <alloca.h>
#include <errno.h>
#ifndef CL_LAUNCH_SCRIPT
#define CL_LAUNCH_SCRIPT "/usr/bin/cl-launch"
#endif
char me[] = "cl-shim";
char var[] = "CL_ARGV0";
char shell[] = "/bin/sh";
int main (int argc, char**argv) {
int res;
size_t l;
char**args;
res = setenv(var, argv[0], 1);
if (res == -1) { perror(me); exit(42); }
l = (1+argc)*sizeof(char**);
args = malloc(l);
if (!args) { exit(42); }
args[0] = argv[0];
args[1] = CL_LAUNCH_SCRIPT;
for(;argc>0;argc--) {
args[argc+1] = argv[argc];
}
res = execv(shell, args);
perror(me);
exit(42);
}
......@@ -24,7 +24,7 @@ build-stamp: configure-stamp
dh_testdir
sh ./cl-launch.sh \
--include /${include_dir} \
--lisp "cmucl sbcl clisp ecl openmcl gclcvs allegro lisp gcl" \
--lisp "sbcl ccl clisp abcl ecl cmucl allegro lispworks scl gcl xcl" \
--rc \
-B generate_install_files
touch build-stamp
......@@ -54,7 +54,6 @@ binary-indep: build install
dh_installdocs -i
dh_installchangelogs -i
dh_link -i
#dh_lisp -i
dh_compress -i
dh_fixperms -i
dh_installdeb -i
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment