From 74041edf5623ac14660169a98b9d1915affb6471 Mon Sep 17 00:00:00 2001 From: Rick Hanson Date: Sat, 11 Apr 2015 15:21:02 -0400 Subject: [PATCH] Make FreeBSD a "first class citizen" among femtolisp's build OSes. It looks like FreeBSD should do what OpenBSD does in femtolisp's code. The biggest change here (I think) is that of determining the correct value of CC in the Makefile(s). As of version 10, FreeBSD's base compiler is clang; so there is now some logic in the Makefile(s) to determine if the build is occurring on a FreeBSD system >= 10.0. If so, then the value of CC will be "clang"; otherwise, it will be "gcc", as before. --- Makefile | 7 ++++--- flisp.c | 2 ++ llt/Makefile | 3 ++- llt/dirpath.c | 2 +- llt/dtypes.h | 6 ++++-- llt/timefuncs.c | 2 +- tiny/Makefile | 3 ++- 7 files changed, 16 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index d282c51..a467b7f 100644 --- 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.o: flmain.c flisp.h flmain.do: flmain.c flisp.h $(LLT): - cd $(LLTDIR) && make + cd $(LLTDIR) && $(MAKE) $(LIBTARGET).da: $(DOBJS) rm -rf $@ @@ -44,7 +45,7 @@ $(LIBTARGET).a: $(OBJS) 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 diff --git a/flisp.c b/flisp.c index 9f6d8eb..dd752c3 100644 --- a/flisp.c +++ b/flisp.c @@ -2307,6 +2307,8 @@ static void lisp_init(size_t initial_heapsize) 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 diff --git a/llt/Makefile b/llt/Makefile index afcc7e3..7899f79 100644 --- 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 \ diff --git a/llt/dirpath.c b/llt/dirpath.c index 6d6d779..df56dc8 100644 --- a/llt/dirpath.c +++ b/llt/dirpath.c @@ -95,7 +95,7 @@ char *get_exename(char *buf, size_t size) /* OpenBSD currently has no way of determining a processes pathname */ return NULL; } -#elif defined(__FreeBSD__) +#elif defined(FREEBSD) #include #include diff --git a/llt/dtypes.h b/llt/dtypes.h index 9fec2a3..1bab667 100644 --- a/llt/dtypes.h +++ b/llt/dtypes.h @@ -23,13 +23,15 @@ # define MACOSX #elif defined(__OpenBSD__) # define OPENBSD +#elif defined(__FreeBSD__) +# define FREEBSD #elif defined(_WIN32) # define WIN32 #else # 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 # define __LITTLE_ENDIAN LITTLE_ENDIAN # define __BIG_ENDIAN BIG_ENDIAN diff --git a/llt/timefuncs.c b/llt/timefuncs.c index 86639a0..1b4b41c 100644 --- a/llt/timefuncs.c +++ b/llt/timefuncs.c @@ -106,7 +106,7 @@ void timestring(double seconds, char *buffer, size_t len) #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) { diff --git a/tiny/Makefile b/tiny/Makefile index 70de4ca..f3971dd 100644 --- 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