shithub: femtolisp

Download patch

ref: 2923137ef047b401d560766537782f60e67f9a0c
parent: ff34b09a3c80e2390eb5d81053b687d90c9f21bd
parent: 74041edf5623ac14660169a98b9d1915affb6471
author: Jeff Bezanson <jeff.bezanson@gmail.com>
date: Sun Apr 19 15:04:32 EDT 2015

Merge pull request #16 from cryptorick/freebsd-first-class

Make FreeBSD a "first class citizen" among femtolisp's build OSes.

--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,5 @@
-CC = gcc
+FREEBSD-GE-10 = $(shell test `uname` = FreeBSD -a `uname -r | cut -d. -f1` -ge 10 && echo YES)
+CC = $(if $(FREEBSD-GE-10),clang,gcc)
 
 NAME = flisp
 SRCS = $(NAME).c builtins.c string.c equalhash.c table.c iostream.c
@@ -32,7 +33,7 @@
 flmain.do: flmain.c flisp.h
 
 $(LLT):
-	cd $(LLTDIR) && make
+	cd $(LLTDIR) && $(MAKE)
 
 $(LIBTARGET).da: $(DOBJS)
 	rm -rf $@
@@ -44,7 +45,7 @@
 
 debug: $(DOBJS) $(LIBFILES) $(LIBTARGET).da flmain.do
 	$(CC) $(DEBUGFLAGS) $(DOBJS) flmain.do -o $(EXENAME) $(LIBS) $(LIBTARGET).da
-	make test
+	$(MAKE) test
 
 release: $(OBJS) $(LIBFILES) $(LIBTARGET).a flmain.o
 	$(CC) $(SHIPFLAGS) $(OBJS) flmain.o -o $(EXENAME) $(LIBS) $(LIBTARGET).a
--- a/flisp.c
+++ b/flisp.c
@@ -2307,6 +2307,8 @@
     set(symbol("*os-name*"), symbol("macos"));
 #elif defined(OPENBSD)
     set(symbol("*os-name*"), symbol("openbsd"));
+#elif defined(FREEBSD)
+    set(symbol("*os-name*"), symbol("freebsd"));
 #else
     set(symbol("*os-name*"), symbol("unknown"));
 #endif
--- a/llt/Makefile
+++ b/llt/Makefile
@@ -1,4 +1,5 @@
-CC = gcc
+FREEBSD-GE-10 = $(shell test `uname` = FreeBSD -a `uname -r | cut -d. -f1` -ge 10 && echo YES)
+CC = $(if $(FREEBSD-GE-10),clang,gcc)
 
 SRCS = bitvector.c hashing.c socket.c timefuncs.c ptrhash.c utf8.c ios.c \
 	dirpath.c htable.c bitvector-ops.c int2str.c dump.c random.c \
--- a/llt/dirpath.c
+++ b/llt/dirpath.c
@@ -95,7 +95,7 @@
   /* OpenBSD currently has no way of determining a processes pathname */
   return NULL;
 }
-#elif defined(__FreeBSD__)
+#elif defined(FREEBSD)
 #include <sys/types.h>
 #include <sys/sysctl.h>
 
--- a/llt/dtypes.h
+++ b/llt/dtypes.h
@@ -23,6 +23,8 @@
 #  define MACOSX
 #elif defined(__OpenBSD__)
 #  define OPENBSD
+#elif defined(__FreeBSD__)
+#  define FREEBSD
 #elif defined(_WIN32)
 #  define WIN32
 #else
@@ -29,7 +31,7 @@
 #  error "unknown platform"
 #endif
 
-#if defined(OPENBSD)
+#if defined(OPENBSD) || defined(FREEBSD)
 #if defined(__x86_64__)
 #  define __SIZEOF_POINTER__ 8
 #else
@@ -70,7 +72,7 @@
 #  define BIG_ENDIAN     __BIG_ENDIAN
 #  define PDP_ENDIAN     __PDP_ENDIAN
 #  define BYTE_ORDER     __BYTE_ORDER
-#elif defined(MACOSX) || defined(OPENBSD)
+#elif defined(MACOSX) || defined(OPENBSD) || defined(FREEBSD)
 #  include <machine/endian.h>
 #  define __LITTLE_ENDIAN  LITTLE_ENDIAN
 #  define __BIG_ENDIAN     BIG_ENDIAN
--- a/llt/timefuncs.c
+++ b/llt/timefuncs.c
@@ -106,7 +106,7 @@
 #endif
 }
 
-#if defined(LINUX) || defined(MACOSX) || defined(OPENBSD)
+#if defined(LINUX) || defined(MACOSX) || defined(OPENBSD) || defined(FREEBSD)
 extern char *strptime(const char *s, const char *format, struct tm *tm);
 double parsetime(const char *str)
 {
--- a/tiny/Makefile
+++ b/tiny/Makefile
@@ -1,4 +1,5 @@
-CC = gcc
+FREEBSD-GE-10 = $(shell test `uname` = FreeBSD -a `uname -r | cut -d. -f1` -ge 10 && echo YES)
+CC = $(if $(FREEBSD-GE-10),clang,gcc)
 
 NAME = lisp
 SRC = $(NAME).c