722ef42897a5e55881531226c8770fd94a634c86
[feed/telephony.git] / libs / re / patches / 100-re.mk.patch
1 --- /Users/alfredh/src/re-0.3.0/mk/re.mk 2011-08-30 13:07:12.000000000 +0200
2 +++ re/mk/re.mk 2011-10-07 21:27:53.000000000 +0200
3 @@ -5,34 +5,37 @@
4 #
5 # Imported variables:
6 #
7 -# PROJECT Project name
8 -# VERSION Version number
9 -# CC Compiler
10 -# GCOV If non-empty, enable GNU Coverage testing
11 -# GPROF If non-empty, enable GNU Profiling
12 -# OPT_SPEED If non-empty, optimize for speed
13 -# OPT_SIZE If non-empty, optimize for size
14 -# USE_OPENSSL If non-empty, link to libssl library
15 -# USE_ZLIB If non-empty, link to libz library
16 -# SYSROOT System root of library and include files
17 -# SYSROOT_ALT Alternative system root of library and include files
18 -# EXTRA_CFLAGS Extra compiler flags appended to CFLAGS
19 -# EXTRA_LFLAGS Extra linker flags appended to LFLAGS
20 +# ARCH Target architecture
21 +# CC Compiler
22 +# CROSS_COMPILE Cross-compiler prefix (optional)
23 +# EXTRA_CFLAGS Extra compiler flags appended to CFLAGS
24 +# EXTRA_LFLAGS Extra linker flags appended to LFLAGS
25 +# GCOV If non-empty, enable GNU Coverage testing
26 +# GPROF If non-empty, enable GNU Profiling
27 +# OPT_SIZE If non-empty, optimize for size
28 +# OPT_SPEED If non-empty, optimize for speed
29 +# PROJECT Project name
30 +# RELEASE Release build
31 +# SYSROOT System root of library and include files
32 +# SYSROOT_ALT Alternative system root of library and include files
33 +# USE_OPENSSL If non-empty, link to libssl library
34 +# USE_ZLIB If non-empty, link to libz library
35 +# VERSION Version number
36 #
37 # Exported variables:
38 #
39 -# CC Compiler
40 -# CCACHE Compiler ccache tool
41 -# CFLAGS Compiler flags
42 -# DFLAGS Dependency generator flags
43 -# LFLAGS Common linker flags
44 -# SH_LFLAGS Linker flags for shared libraries
45 -# MOD_LFLAGS Linker flags for dynamic modules
46 -# APP_LFLAGS Linker flags for applications using modules
47 -# LIBS Libraries to link against
48 -# LIB_SUFFIX Suffix for shared libraries
49 -# MOD_SUFFIX Suffix for dynamic modules
50 -# BIN_SUFFIX Suffix for binary executables
51 +# APP_LFLAGS Linker flags for applications using modules
52 +# BIN_SUFFIX Suffix for binary executables
53 +# CC Compiler
54 +# CCACHE Compiler ccache tool
55 +# CFLAGS Compiler flags
56 +# DFLAGS Dependency generator flags
57 +# LFLAGS Common linker flags
58 +# LIBS Libraries to link against
59 +# LIB_SUFFIX Suffix for shared libraries
60 +# MOD_LFLAGS Linker flags for dynamic modules
61 +# MOD_SUFFIX Suffix for dynamic modules
62 +# SH_LFLAGS Linker flags for shared libraries
63 #
64
65
66 @@ -177,65 +180,27 @@
67 #
68 # OS section
69 #
70 +
71 MACHINE := $(shell $(CC) -dumpmachine)
72 -OS := $(shell uname -s | sed -e s/SunOS/solaris/ | tr "[A-Z]" "[a-z]")
73 -#ARCH := $(shell echo $(MACHINE) | sed -e 's/\([^-]*\)-.*/\1/')
74
75 -# TODO get ARCH from first tuple in CC -dumpmachine which is more future proof
76 -ifeq ($(MACHINE), i386-mingw32)
77 - OS := win32
78 - ARCH := i386
79 -endif
80 -ifeq ($(MACHINE), i486-mingw32)
81 - OS := win32
82 - ARCH := i486
83 +ifeq ($(CROSS_COMPILE),)
84 +OS := $(shell uname -s | sed -e s/SunOS/solaris/ | tr "[A-Z]" "[a-z]")
85 endif
86 -ifeq ($(MACHINE), i586-mingw32msvc)
87 +
88 +
89 +#
90 +# Try to guess the OS
91 +#
92 +
93 +ifneq ($(strip $(filter i386-mingw32 i486-mingw32 i586-mingw32msvc mingw32, \
94 + $(MACHINE))),)
95 OS := win32
96 - ARCH := i586
97 -endif
98 ifeq ($(MACHINE), mingw32)
99 - OS := win32
100 - ARCH := i386
101 CROSS_COMPILE :=
102 endif
103 -ifeq ($(MACHINE), i686-pc-cygwin)
104 - OS := cygwin
105 - ARCH := i686
106 -endif
107 -ifeq ($(MACHINE), mipsel-linux-uclibc)
108 - OS := linux
109 - ARCH := mipsel
110 -endif
111 -ifeq ($(MACHINE), bfin-linux-uclibc)
112 - OS := linux
113 - ARCH := bfin
114 -endif
115 -ifeq ($(MACHINE), bfin-uclinux)
116 - OS := linux
117 - ARCH := bfin
118 -endif
119 -ifeq ($(MACHINE), arm-apple-darwin)
120 - OS := darwin
121 - ARCH := arm
122 - CROSS_COMPILE ?= $(MACHINE)-
123 - CFLAGS += -F/Developer/SDKs/MacOSX10.4u.sdk/System/Library/Frameworks
124 -endif
125 -ifeq ($(MACHINE), arm-apple-darwin9)
126 - OS := darwin
127 - ARCH := arm
128 - CROSS_COMPILE ?= $(MACHINE)-
129 - ROOT := /Developer//Platforms/iPhoneOS.platform/Developer
130 - SDK := $(ROOT)/SDKs/iPhoneOS3.0.sdk
131 - CFLAGS += -F$(SDK)/System/Library/Frameworks/
132 - CFLAGS += -I$(SDK)/usr/include
133 - CFLAGS += -I$(SDK)/usr/lib/gcc/arm-apple-darwin9/4.2.1/include
134 - CFLAGS += -isysroot $(SDK)
135 - LFLAGS += -F$(SDK)/System/Library/Frameworks
136 - LFLAGS += -L$(SDK)/usr/lib
137 - LFLAGS += -L$(SDK)/usr/lib/gcc/arm-apple-darwin9/4.2.1/
138 endif
139
140 +
141 # default
142 LIB_SUFFIX := .so
143 MOD_SUFFIX := .so
144 @@ -276,8 +241,6 @@
145 AR := ar
146 AFLAGS := cru
147 LIB_SUFFIX := .dylib
148 - ARCH := $(shell echo $(MACHINE) | \
149 - sed -e 's/\([^-]*\)-.*/\1/')
150 endif
151 ifeq ($(OS),netbsd)
152 CFLAGS += -fPIC -DNETBSD
153 @@ -347,30 +310,121 @@
154 endif
155
156
157 +ifeq ($(OS),)
158 +$(warning Could not detect OS)
159 +endif
160 +
161 +
162 ##############################################################################
163 #
164 # Architecture section
165 #
166 +# detect $(HOST_ARCH) -- Host architecture
167 +# detect $(ARCH) -- Target architecture
168 +#
169 +
170 +
171 +#
172 +# detect $(HOST_ARCH)
173 +#
174
175 ifeq ($(OS),solaris)
176 + GETARCH=isainfo -n
177 +ifeq ($(GETARCH),)
178 GETARCH=uname -p
179 +endif
180 else
181 GETARCH=uname -m
182 endif
183
184 +HOST_ARCH := $(shell $(GETARCH) |sed -e s/i.86/i386/ -e s/sun4[uv]/sparc64/ \
185 + -e s/armv[3-5].*/arm/ -e s/armv6.*/arm6/ \
186 + -e "s/Power Macintosh/ppc/" \
187 + -e "s/cobalt/mips2/" \
188 + -e s/amd64/x86_64/ -e s/sparcv9/sparc64/ )
189 +
190 +ifeq ($(HOST_ARCH),sparc)
191 +ifeq ($(shell uname -m),sun4u)
192 + HOST_ARCH := sparc64
193 +endif
194 +ifeq ($(shell uname -m),sun4v)
195 + HOST_ARCH := sparc64
196 +endif
197 +endif
198 +
199 +
200 +#
201 +# detect $(ARCH)
202 +#
203 +
204 ifeq ($(ARCH),)
205 -ARCH := $(shell $(GETARCH) | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \
206 - -e s/armv4l/arm/ -e "s/Power Macintosh/ppc/" \
207 - -e "s/cobalt/mips2/" \
208 - -e s/amd64/x86_64/ )
209 -endif
210 -# fix sparc -> sparc64
211 -ifeq ($(ARCH),sparc)
212 - ifeq ($(shell uname -m),sun4u)
213 - ARCH := sparc64
214 - endif
215 +ifeq ($(CC_NAME),gcc)
216 +PREDEF := $(shell $(CC) -dM -E -x c $(EXTRA_CFLAGS) $(CFLAGS) /dev/null)
217 +
218 +ifneq ($(strip $(filter i386 __i386__ __i386 _M_IX86 __X86__ _X86_, \
219 + $(PREDEF))),)
220 +ARCH := i386
221 endif
222
223 +ifneq ($(strip $(filter __i486__,$(PREDEF))),)
224 +ARCH := i486
225 +endif
226 +
227 +ifneq ($(strip $(filter __i586__,$(PREDEF))),)
228 +ARCH := i586
229 +endif
230 +
231 +ifneq ($(strip $(filter __i686__ ,$(PREDEF))),)
232 +ARCH := i686
233 +endif
234 +
235 +ifneq ($(strip $(filter __amd64__ __amd64 __x86_64__ __x86_64, \
236 + $(PREDEF))),)
237 +ARCH := x86_64
238 +endif
239 +
240 +ifneq ($(strip $(filter __arm__ __thumb__,$(PREDEF))),)
241 +
242 +ifneq ($(strip $(filter __ARM_ARCH_6__,$(PREDEF))),)
243 +ARCH := arm6
244 +else
245 +ARCH := arm
246 +endif
247 +
248 +endif
249 +
250 +ifneq ($(strip $(filter __mips__ __mips, $(PREDEF))),)
251 +ARCH := mips
252 +endif
253 +
254 +ifneq ($(strip $(filter __powerpc __powerpc__ __POWERPC__ __ppc__ \
255 + _ARCH_PPC, $(PREDEF))),)
256 +ARCH := ppc
257 +endif
258 +
259 +ifneq ($(strip $(filter __ppc64__ _ARCH_PPC64 , $(PREDEF))),)
260 +ARCH := ppc64
261 +endif
262 +
263 +ifneq ($(strip $(filter __sparc__ __sparc __sparcv8 , $(PREDEF))),)
264 +
265 +ifneq ($(strip $(filter __sparcv9 __sparc_v9__ , $(PREDEF))),)
266 +ARCH := sparc64
267 +else
268 +ARCH := sparc
269 +endif
270 +
271 +endif
272 +
273 +endif
274 +endif
275 +
276 +
277 +ifeq ($(ARCH),)
278 +$(warning Could not detect ARCH)
279 +endif
280 +
281 +
282 CFLAGS += -DARCH=\"$(ARCH)\"
283
284 ifeq ($(ARCH),mipsel)
285 @@ -549,6 +603,7 @@
286 @echo " MODULES: $(MODULES)"
287 # @echo " SRCS: $(SRCS)"
288 @echo " MACHINE: $(MACHINE)"
289 + @echo " HOST_ARCH: $(HOST_ARCH)"
290 @echo " ARCH: $(ARCH)"
291 @echo " OS: $(OS)"
292 @echo " BUILD: $(BUILD)"