-
Notifications
You must be signed in to change notification settings - Fork 62
/
config.mk
145 lines (126 loc) · 2.44 KB
/
config.mk
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
PREFIX?=/usr
BINDIR=${PREFIX}/bin
LIBDIR=${PREFIX}/lib
DATADIR=${PREFIX}/share
INCDIR=${PREFIX}/include
VAPIDIR=${DATADIR}/vala/vapi/
MANDIR=${DATADIR}/man/man1
SDBVER=2.0.1
BUILD_MEMCACHE=0
INSTALL?=install
ifeq ($(INSTALL),cp)
INSTALL_DIR=mkdir -p
INSTALL_DATA=cp -f
INSTALL_PROGRAM=cp -f
INSTALL_SCRIPT=cp -f
INSTALL_MAN=cp -f
INSTALL_LIB=cp -f
else
INSTALL_DIR=$(INSTALL) -d
INSTALL_DATA=$(INSTALL) -m 644
INSTALL_PROGRAM=$(INSTALL) -m 755
INSTALL_SCRIPT=$(INSTALL) -m 755
INSTALL_MAN=$(INSTALL) -m 444
INSTALL_LIB=$(INSTALL) -c
endif
OS=$(shell uname)
OSTYPE?=$(shell uname -s)
ARCH?=$(shell uname -m)
# link time optimization
#CFLAGS_STD=-std=gnu99 -flto -O2
CFLAGS_STD=-std=gnu99
ifeq (,$(findstring AIX,${OSTYPE}))
CFLAGS_STD+=-D_XOPEN_SOURCE=700 -D_POSIX_C_SOURCE=200809L
endif
#CFLAGS+=-Wno-initializer-overrides
CFLAGS:=${CFLAGS_STD} $(CFLAGS)
# Hack to fix clang warnings
ifeq ($(CC),cc)
CFLAGS+=$(shell gcc -v 2>&1 | grep -q LLVM && echo '-Wno-initializer-overrides')
endif
CFLAGS+=-Wall
CFLAGS+=-fPIC
CFLAGS+=-Wsign-compare
# some old gcc doesnt support this
# CFLAGS+=-Wmissing-field-initializers
#CFLAGS+=-O3
# CFLAGS+=-g -Wall -O0
#CFLAGS+=-g
#LDFLAGS+=-g -flto
HAVE_VALA=$(shell valac --version 2> /dev/null)
# This is hacky
HOST_CC?=gcc
RANLIB?=ranlib
AR?=ar
CC?=gcc
EXT_EXE=
EXT_SO=.so
EXT_AR=.a
ifneq (,$(findstring MINGW32,${OSTYPE}))
OS=w32
CC=gcc
else
ifeq (${OS},w32)
WCP?=i386-mingw32
CC=${WCP}-gcc
AR?=${WCP}-ar
endif
endif
#LDFLAGS_SHARED?=-fPIC -shared
LDFLAGS_SHARED?=-shared
ifeq (${OS},w32)
EXT_EXE=.exe
EXT_AR=.lib
EXT_SO=.dll
LDFLAGS_SHARED=-shared
endif
# create .d files
ifeq (,$(findstring tcc,${CC}))
CFLAGS+=-MMD
else
CFLAGS+=-MD
endif
ifeq (${OS},w32)
OSTYPE=MINGW32
endif
ifneq (,$(findstring MINGW,${OSTYPE})$(findstring MSYS,${OSTYPE})$(findstring CYGWIN,${OSTYPE}))
EXT_SO=.dll
EXT_AR=.a
SOVER=${EXT_SO}
CFLAGS+=-DUNICODE -D_UNICODE
else
EXT_SO=.so
SOVER=${EXT_SO}.${SDBVER}
endif
ifeq (${OS},Darwin)
EXT_SO=.dylib
SOVER=.dylib
LDFLAGS+=-dynamic
LDFLAGS_SHARED+=-dynamiclib
ifeq (${ARCH},i386)
#CC+=-arch i386
CC+=-arch x86_64
endif
else
ifneq (,$(findstring CYGWIN,${OSTYPE}))
CFLAGS+=-D__CYGWIN__=1
LDFLAGS_SHARED?=-shared
else
ifneq (,$(findstring MINGW32,${OSTYPE}))
CFLAGS+=-DMINGW32=1
else
CFLAGS+=-fPIC
SOVERSION=0
LDFLAGS_SHARED?=-fPIC
endif
endif
LDFLAGS_SHARED+=-Wl,-soname,libsdb.so.$(SOVERSION)
endif
ifeq ($(MAKEFLAGS),s)
SILENT=1
else
SILENT=
endif
ifneq (${SDB_CONFIG},)
include ${SDB_CONFIG}
endif