From 24109550cda5a4deaad6ec35be93e6270b9a2c29 Mon Sep 17 00:00:00 2001 From: Justin Ethier Date: Fri, 26 Aug 2016 03:04:39 -0400 Subject: [PATCH] Autodetect configuration items --- Makefile.config | 47 ++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 44 insertions(+), 3 deletions(-) diff --git a/Makefile.config b/Makefile.config index d57c7a83..0440b892 100644 --- a/Makefile.config +++ b/Makefile.config @@ -4,9 +4,6 @@ # # 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 @@ -38,3 +35,47 @@ INCDIR ?= $(PREFIX)/include/cyclone DATADIR ?= $(PREFIX)/share/cyclone DESTDIR ?= + +# Automatically detect platform-specific flags, instead of using autoconf +#CYC_PLATFORM_HAS_MEMSTREAM ?= 1 +CYC_PLATFORM_HAS_MEMSTREAM := $(shell echo "main(){char *buf; int len; open_memstream(&buf, &len);}" | gcc -xc - >/dev/null 2>/dev/null && echo 1 || echo 0) + +# code from chibi's makefile to detect platform +ifndef PLATFORM +ifeq ($(shell uname),Darwin) +PLATFORM=macosx +else +ifeq ($(shell uname),FreeBSD) +PLATFORM=bsd +else +ifeq ($(shell uname),NetBSD) +PLATFORM=bsd +else +ifeq ($(shell uname),OpenBSD) +PLATFORM=bsd +else +ifeq ($(shell uname),DragonFly) +PLATFORM=bsd +else +ifeq ($(shell uname -o),Msys) +PLATFORM=mingw +SOLIBDIR = $(BINDIR) +DIFFOPTS = -b +else +ifeq ($(shell uname -o),Cygwin) +PLATFORM=cygwin +SOLIBDIR = $(BINDIR) +DIFFOPTS = -b +else +ifeq ($(shell uname -o),GNU/Linux) +PLATFORM=linux +else +PLATFORM=unix +endif +endif +endif +endif +endif +endif +endif +endif