-
-
Notifications
You must be signed in to change notification settings - Fork 46
/
Makefile.config
117 lines (100 loc) · 3.73 KB
/
Makefile.config
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# 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