shithub: femtolisp

Download patch

ref: 12b90137449917cc543e307d9d90db5235e29176
parent: be0d4d0d4764c2bdac6299bfed58357207de35d3
author: JeffBezanson <jeff.bezanson@gmail.com>
date: Sun Aug 23 21:11:36 EDT 2009

changes to support mac compilation better. patches from Stefan.


--- a/femtolisp/Makefile
+++ b/femtolisp/Makefile
@@ -9,7 +9,8 @@
 LLT = $(LLTDIR)/libllt.a
 
 FLAGS = -falign-functions -Wall -Wextra -Wno-strict-aliasing -I$(LLTDIR) $(CFLAGS) -DUSE_COMPUTED_GOTO
-LIBS = $(LLT) -lm
+LIBFILES = $(LLT)
+LIBS = $(LIBFILES) -lm
 
 DEBUGFLAGS = -g -DDEBUG $(FLAGS)
 SHIPFLAGS = -O2 -DNDEBUG $(FLAGS)
@@ -30,11 +31,11 @@
 $(LLT):
 	cd $(LLTDIR) && make
 
-debug: $(DOBJS) $(LIBS)
+debug: $(DOBJS) $(LIBFILES)
 	$(CC) $(DEBUGFLAGS) $(DOBJS) -o $(EXENAME) $(LIBS)
 	make test
 
-release: $(OBJS) $(LIBS)
+release: $(OBJS) $(LIBFILES)
 	$(CC) $(SHIPFLAGS) $(OBJS) -o $(EXENAME) $(LIBS)
 
 clean:
--- /dev/null
+++ b/femtolisp/Makefile.macosx
@@ -1,0 +1,44 @@
+CC = gcc
+
+NAME = flisp
+SRCS = $(NAME).c builtins.c string.c equalhash.c table.c iostream.c
+OBJS = $(SRCS:%.c=%.o)
+DOBJS = $(SRCS:%.c=%.do)
+EXENAME = $(NAME)
+LLTDIR = ../llt
+LLT = $(LLTDIR)/libllt.a
+
+FLAGS = -falign-functions -Wall -Wextra -Wno-strict-aliasing -I$(LLTDIR) $(CFLAGS) -DUSE_COMPUTED_GOTO
+LIBFILES = $(LLT)
+LIBS = $(LIBFILES) -lm -framework ApplicationServices
+
+DEBUGFLAGS = -g -DDEBUG $(FLAGS)
+SHIPFLAGS = -O2 -DNDEBUG $(FLAGS)
+
+default: release test
+
+test:
+	./flisp unittest.lsp
+
+%.o: %.c
+	$(CC) $(SHIPFLAGS) -c $< -o $@
+%.do: %.c
+	$(CC) $(DEBUGFLAGS) -c $< -o $@
+
+flisp.o: flisp.c cvalues.c types.c flisp.h print.c read.c
+flisp.do: flisp.c cvalues.c types.c flisp.h print.c read.c
+
+$(LLT):
+	cd $(LLTDIR) && make
+
+debug: $(DOBJS) $(LIBFILES)
+	$(CC) $(DEBUGFLAGS) $(DOBJS) -o $(EXENAME) $(LIBS)
+	make test
+
+release: $(OBJS) $(LIBFILES)
+	$(CC) $(SHIPFLAGS) $(OBJS) -o $(EXENAME) $(LIBS)
+
+clean:
+	rm -f *.o
+	rm -f *.do
+	rm -f $(EXENAME)
--- a/llt/dblprint.c
+++ b/llt/dblprint.c
@@ -2,8 +2,8 @@
 #include <stdlib.h>
 #include <string.h>
 #include <stdio.h>
-#include "ieee754.h"
 #include "dtypes.h"
+#include "ieee754.h"
 
 int double_exponent(double d)
 {
--- a/llt/ios.c
+++ b/llt/ios.c
@@ -31,6 +31,20 @@
 
 /* OS-level primitive wrappers */
 
+#if defined(MACOSX) || defined(MACINTEL)
+void *memrchr(const void *s, int c, size_t n)
+{
+    const unsigned char *src = s + n;
+    unsigned char uc = c;
+    while (--src >= (unsigned char *) s)
+        if (*src == uc)
+            return (void *) src;
+    return NULL;
+}
+#else
+extern void *memrchr(const void *s, int c, size_t n);
+#endif
+
 static int _fd_available(long fd)
 {
 #ifndef WIN32
--- a/llt/timefuncs.c
+++ b/llt/timefuncs.c
@@ -105,7 +105,7 @@
 #endif
 }
 
-#ifdef LINUX
+#if defined(LINUX) || defined(MACOSX) || defined(MACINTEL)
 extern char *strptime(const char *s, const char *format, struct tm *tm);
 double parsetime(char *str)
 {
--- a/llt/utf8.h
+++ b/llt/utf8.h
@@ -1,7 +1,7 @@
 #ifndef __UTF8_H_
 #define __UTF8_H_
 
-#ifndef MACOSX
+#if !defined(MACOSX) && !defined(MACINTEL)
 #if !defined(__DTYPES_H_) && !defined(_SYS_TYPES_H)
 typedef char int8_t;
 typedef short int16_t;