mirror of
https://github.com/justinethier/cyclone.git
synced 2025-05-23 20:15:05 +02:00
This commit separates include/library search directory options from "normal" compiler/linker options and places options passed via the `-COPT`/`-CLNK` command-line flags in-between. This allows overwriting the default search paths, since contrary to all other options, the search paths must be prepend for an -I/-L option to take precedence over an existing one. This should (hopefully) make it entirely unnecessary to ever build Cyclone twice in order to have all changes in the current source tree take effect. Fixes #476
116 lines
3.5 KiB
Text
116 lines
3.5 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 -I$(PREFIX)/include
|
|
# 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_LIBDIRS) -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
|
|
CYC_PLATFORM_HAS_MEMSTREAM := $(shell echo "main(){char *buf; int len; open_memstream(&buf, &len);}" | $(CC) -xc - >/dev/null 2>/dev/null && echo 1 || echo 0)
|
|
CYC_PLATFORM_HAS_FMEMOPEN := $(shell echo "main(){char *buf; fmemopen(&buf, 0, \"r\");}" | $(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
|