From 1d4d710b3be93dc317853c07fff520c005757b29 Mon Sep 17 00:00:00 2001 From: Justin Ethier Date: Thu, 25 Aug 2016 23:48:31 -0400 Subject: [PATCH] Selectively-compile open_memstream --- Makefile | 4 +++- Makefile.config | 10 +++++++--- mem-streams.c | 2 ++ 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index d5145528..14cdc88c 100644 --- a/Makefile +++ b/Makefile @@ -71,8 +71,10 @@ libcyclone.a: runtime.c include/cyclone/runtime.h include/cyclone/types.h gc.c d # echo $(CC_EXEC) # echo $(CC_LIB) $(CC) $(CFLAGS) -c dispatch.c -o dispatch.o - $(CC) $(CFLAGS) -c mem-streams.c -o mem-streams.o $(CC) $(CFLAGS) -std=gnu99 -c gc.c -o gc.o + $(CC) $(CFLAGS) -c \ + -DCYC_HAVE_OPEN_MEMSTREAM=$(CYC_PLATFORM_HAS_MEMSTREAM) \ + mem-streams.c -o mem-streams.o $(CC) $(CFLAGS) -c \ -DCYC_INSTALL_DIR=\"$(PREFIX)\" \ -DCYC_INSTALL_LIB=\"$(LIBDIR)\" \ diff --git a/Makefile.config b/Makefile.config index c023b6e1..d57c7a83 100644 --- a/Makefile.config +++ b/Makefile.config @@ -4,15 +4,19 @@ # # Configuration options for the makefile +# Platform-specific flags, set to 0 if not supported +CYC_PLATFORM_HAS_MEMSTREAM ?= 1 + +# Compiler options +CFLAGS ?= -O2 -Wall -Iinclude -L. +COMP_CFLAGS ?= -O2 -Wall -I$(PREFIX)/include -L$(PREFIX)/lib # Use these lines instead for debugging or profiling #CFLAGS = -g -Wall #CFLAGS = -g -pg -Wall -CFLAGS ?= -O2 -Wall -Iinclude -L. -COMP_CFLAGS ?= -O2 -Wall -I$(PREFIX)/include -L$(PREFIX)/lib CC ?= cc LIBS = -pthread -lcyclone -lck -lm -# Commands "baked into" cycone for invoking the C compiler +# Commands "baked into" cyclone for invoking the C compiler CC_PROG ?= "$(CC) ~src-file~ $(COMP_CFLAGS) -c -o ~exec-file~.o" CC_EXEC ?= "$(CC) ~exec-file~.o ~obj-files~ $(LIBS) $(COMP_CFLAGS) -o ~exec-file~" CC_LIB ?= "$(CC) ~src-file~ $(COMP_CFLAGS) -c -o ~exec-file~.o" diff --git a/mem-streams.c b/mem-streams.c index 8bd339a9..497b4ff6 100644 --- a/mem-streams.c +++ b/mem-streams.c @@ -37,7 +37,9 @@ port_type Cyc_io_open_output_string(void *data) { make_port(p, NULL, 0); errno = 0; +#if CYC_HAVE_OPEN_MEMSTREAM p.fp = open_memstream(&(p.mem_buf), &(p.mem_buf_len)); +#endif if (p.fp == NULL){ Cyc_rt_raise2(data, "Unable to open memory stream", obj_int2obj(errno)); }