mirror of
https://github.com/justinethier/cyclone.git
synced 2025-05-18 21:29:18 +02:00
GCC 14 has enabled various warnings as errors by default, e.g. -Wimplicit-function-declaration. This causes the current feature detection code for `open_memstream(3)` and `fmemopen(3)` to fail with GCC 14. This commit restores compatibility with GCC 14 in this regard. Note that it may also be beneficial to pass a feature test macro such as -D_POSIX_C_SOURCE. See the feature test macro requirements for open_memstream(3)` and `fmemopen(3)`.
117 lines
3.7 KiB
Text
117 lines
3.7 KiB
Text
# Cyclone Scheme
|
|
# Copyright (c) 2014, Justin Ethier
|
|
# All rights reserved.
|
|
#
|
|
# Configuration options for the makefile
|
|
|
|
& = $(filter-out %.h %.d,$^)
|
|
|
|
CYC_PROFILING ?=
|
|
#CYC_PROFILING ?= -g -pg
|
|
#CYC_PROFILING ?= -DCYC_HIGH_RES_TIMERS
|
|
|
|
CYC_GCC_OPT_FLAGS ?= -O2
|
|
#CYC_GCC_OPT_FLAGS ?= -g
|
|
|
|
# Change this to 1 to use a custom stack size for threads.
|
|
# Required on platforms such as Alpine Linux that use a
|
|
# very small stack by default.
|
|
CYC_PTHREAD_SET_STACK_SIZE ?=
|
|
|
|
OS = $(shell uname)
|
|
CC ?= cc
|
|
|
|
LIBS = -pthread -lcyclone -lck -lm -lcyclonebn
|
|
ifneq ($(OS),FreeBSD)
|
|
# libdl is part of libc on FreeBSD
|
|
LIBS += -ldl
|
|
endif
|
|
|
|
# Compiler options
|
|
CFLAGS += $(CYC_PROFILING) $(CYC_GCC_OPT_FLAGS) -fPIC -Wall -Wno-shift-negative-value -Wno-unused-command-line-argument -Iinclude
|
|
BASE_CFLAGS ?= $(CYC_PROFILING) $(CYC_GCC_OPT_FLAGS) -fPIC -Wall -Wno-shift-negative-value -Wno-unused-command-line-argument
|
|
# Used by Cyclone to compile programs, no need for PIC there
|
|
BASE_PROG_CFLAGS ?= $(CYC_PROFILING) $(CYC_GCC_OPT_FLAGS) -Wall
|
|
COMP_CFLAGS ?= $(BASE_CFLAGS)
|
|
COMP_LIBDIRS ?= -L$(PREFIX)/lib
|
|
COMP_INCDIRS ?= -I$(PREFIX)/include
|
|
COMP_PROG_CFLAGS ?= $(BASE_PROG_CFLAGS)
|
|
|
|
# Use these lines instead for debugging or profiling
|
|
#CFLAGS = -g -Wall
|
|
#CFLAGS = -g -pg -Wall
|
|
|
|
# Linker options
|
|
LDFLAGS += -L. $(CYC_PROFILING)
|
|
LIBRARY_OUTPUT_FILE = libcyclone.a
|
|
ifeq ($(OS),Darwin)
|
|
LDFLAGS += -Wl,-undefined -Wl,dynamic_lookup
|
|
CREATE_LIBRARY_COMMAND = $(LIBTOOL)
|
|
CREATE_LIBRARY_FLAGS = -static -o
|
|
else
|
|
LDFLAGS += -Wl,--export-dynamic
|
|
COMP_CFLAGS += -Wl,--export-dynamic
|
|
CREATE_LIBRARY_COMMAND = $(AR)
|
|
CREATE_LIBRARY_FLAGS = rcs
|
|
endif
|
|
|
|
# /usr/local is not in the search path by default on FreeBSD, so if libtommath and/or
|
|
# concurrencykit was installed via Ports, it won't be picked up without explicitly looking
|
|
# for it here
|
|
ifeq ($(OS),FreeBSD)
|
|
COMP_LIBDIRS += -L/usr/local/lib
|
|
COMP_INCDIRS += -I/usr/local/include
|
|
endif
|
|
|
|
|
|
# Commands "baked into" cyclone for invoking the C compiler
|
|
CC_PROG ?= "$(CC) ~src-file~ $(COMP_PROG_CFLAGS) ~cc-extra~ $(COMP_INCDIRS) -c -o ~exec-file~.o"
|
|
CC_EXEC ?= "$(CC) ~exec-file~.o ~obj-files~ $(LIBS) $(COMP_CFLAGS) ~ld-extra~ $(COMP_LIBDIRS) -o ~exec-file~"
|
|
CC_LIB ?= "$(CC) ~src-file~ $(COMP_CFLAGS) ~cc-extra~ $(COMP_INCDIRS) -c -o ~exec-file~.o"
|
|
CC_SO ?= "$(CC) -shared $(LDFLAGS) -o ~exec-file~.so ~exec-file~.o"
|
|
|
|
AR ?= ar
|
|
LIBTOOL ?= libtool
|
|
#CD ?= cd
|
|
RM ?= rm -f
|
|
#LS ?= ls
|
|
#CP ?= cp
|
|
#LN ?= ln
|
|
INSTALL ?= install
|
|
MKDIR ?= $(INSTALL) -d
|
|
RMDIR ?= rm -rf
|
|
|
|
PREFIX ?= /usr/local
|
|
BINDIR ?= $(PREFIX)/bin
|
|
LIBDIR ?= $(PREFIX)/lib
|
|
INCDIR ?= $(PREFIX)/include/cyclone
|
|
DATADIR ?= $(PREFIX)/share/cyclone
|
|
|
|
DESTDIR ?=
|
|
|
|
# Automatically detect platform-specific flags, instead of using autoconf
|
|
#CYC_PLATFORM_HAS_MEMSTREAM ?= 1
|
|
HASH := \# # Needed for compatibility with GNU Make < 4.3 <https://lists.gnu.org/archive/html/info-gnu/2020-01/msg00004.html>
|
|
CYC_PLATFORM_HAS_MEMSTREAM := $(shell printf "$(HASH)include <stdio.h>\n%s\n" "int main(void){char *buf; size_t len; open_memstream(&buf, &len); return 0;}" | $(CC) -xc - >/dev/null 2>/dev/null && echo 1 || echo 0)
|
|
CYC_PLATFORM_HAS_FMEMOPEN := $(shell printf "$(HASH)include <stdio.h>\n%s\n" "int main(void){char *buf; fmemopen(&buf, 0, \"r\"); return 0;}" | $(CC) -xc - >/dev/null 2>/dev/null && echo 1 || echo 0)
|
|
|
|
# code from chibi's makefile to detect platform
|
|
ifndef PLATFORM
|
|
ifeq ($(OS),Darwin)
|
|
PLATFORM=macosx
|
|
else ifneq (,$(findstring $(OS),FreeBSD NetBSD OpenBSD 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
|