]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - gnu/lib/libgcc/Makefile
MFC @r257698.
[FreeBSD/FreeBSD.git] / gnu / lib / libgcc / Makefile
1 # $FreeBSD$
2
3 GCCDIR= ${.CURDIR}/../../../contrib/gcc
4 GCCLIB= ${.CURDIR}/../../../contrib/gcclibs
5
6 SHLIB_NAME=     libgcc_s.so.1
7 SHLIBDIR?=      /lib
8
9 .include <bsd.own.mk>
10 #
11 # libgcc is linked in last and thus cannot depend on ssp symbols coming
12 # from earlier libraries. Disable stack protection for this library.
13 #
14 MK_SSP= no
15
16 .include "${.CURDIR}/../../usr.bin/cc/Makefile.tgt"
17
18 .if ${TARGET_CPUARCH} == "arm" && ${MK_ARM_EABI} != "no"
19 CFLAGS+=        -DTARGET_ARM_EABI
20 .endif
21
22 .PATH: ${GCCDIR}/config/${GCC_CPU} ${GCCDIR}/config ${GCCDIR}
23
24 CFLAGS+=        -DIN_GCC -DIN_LIBGCC2 -D__GCC_FLOAT_NOT_NEEDED \
25                 -DHAVE_GTHR_DEFAULT \
26                 -I${GCCLIB}/include \
27                 -I${GCCDIR}/config -I${GCCDIR} -I. \
28                 -I${.CURDIR}/../../usr.bin/cc/cc_tools
29
30 # Added to quiesce warning around gcc_assert() for an inline macro that uses
31 # a static variable.  This code has been moved around in gcc, but is still in
32 # use in the latest trunk version of the compiler.
33 #
34 # gnu/lib/libgcc/../../../contrib/gcc/unwind-dw2.c:208:36:
35 #      warning: static variable 'dwarf_reg_size_table' is used in an inline
36 #               function with external linkage [-Wstatic-in-inline]
37 # gcc_assert (index < (int) sizeof(dwarf_reg_size_table));
38 #                                  ^
39 .if ${COMPILER_TYPE} == "clang"
40 CFLAGS+=        -Wno-static-in-inline
41 .endif
42
43 LDFLAGS+=       -nodefaultlibs
44 LDADD+=         -lc
45
46 OBJS=           # added to below in various ways depending on TARGET_CPUARCH
47
48 #---------------------------------------------------------------------------
49 #
50 # When upgrading GCC, get the following defintions straight from Makefile.in
51 #
52 # Library members defined in libgcc2.c.
53 LIB2FUNCS= _muldi3 _negdi2 _lshrdi3 _ashldi3 _ashrdi3 \
54         _cmpdi2 _ucmpdi2 \
55         _enable_execute_stack _trampoline __main _absvsi2 _absvdi2 _addvsi3 \
56         _addvdi3 _subvsi3 _subvdi3 _mulvsi3 _mulvdi3 _negvsi2 _negvdi2 _ctors \
57         _ffssi2 _ffsdi2 _clz _clzsi2 _clzdi2 _ctzsi2 _ctzdi2 _popcount_tab \
58         _popcountsi2 _popcountdi2 _paritysi2 _paritydi2 _powisf2 _powidf2 \
59         _powixf2 _powitf2 _mulsc3 _muldc3 _mulxc3 _multc3 _divsc3 _divdc3 \
60         _divxc3 _divtc3
61 .if ${COMPILER_TYPE} != "clang" || ${TARGET_CPUARCH} != "arm"
62 LIB2FUNCS+= _clear_cache
63 .endif
64
65 # The floating-point conversion routines that involve a single-word integer.
66 .for mode in sf df xf
67 LIB2FUNCS+= _fixuns${mode}si
68 .endfor
69
70 # Likewise double-word routines.
71 .if ${TARGET_CPUARCH} != "arm" || ${MK_ARM_EABI} == "no"
72 # These are implemented in an ARM specific file but will not be filtered out
73 .for mode in sf df xf tf
74 LIB2FUNCS+= _fix${mode}di _fixuns${mode}di
75 LIB2FUNCS+= _floatdi${mode} _floatundi${mode}
76 .endfor
77 .endif
78
79 LIB2ADD = $(LIB2FUNCS_EXTRA)
80 LIB2ADD_ST = $(LIB2FUNCS_STATIC_EXTRA)
81
82 # Additional sources to handle exceptions; overridden by targets as needed.
83 LIB2ADDEH = unwind-dw2.c unwind-dw2-fde-glibc.c unwind-sjlj.c gthr-gnat.c \
84         unwind-c.c
85 LIB2ADDEHSTATIC = $(LIB2ADDEH)
86 LIB2ADDEHSHARED = $(LIB2ADDEH)
87
88 # List of extra C and assembler files to add to static and shared libgcc2.
89 # Assembler files should have names ending in `.asm'.
90 LIB2FUNCS_EXTRA =
91
92 # List of extra C and assembler files to add to static libgcc2.
93 # Assembler files should have names ending in `.asm'.
94 LIB2FUNCS_STATIC_EXTRA =
95
96 # Defined in libgcc2.c, included only in the static library.
97 # KAN: Excluded _sf_to_tf and _df_to_tf as TPBIT_FUNCS are not
98 # built on any of our platforms.
99 LIB2FUNCS_ST = _eprintf __gcc_bcmp
100
101 FPBIT_FUNCS = _pack_sf _unpack_sf _addsub_sf _mul_sf _div_sf \
102     _fpcmp_parts_sf _compare_sf _eq_sf _ne_sf _gt_sf _ge_sf \
103     _lt_sf _le_sf _unord_sf _si_to_sf _sf_to_si _negate_sf _make_sf \
104     _sf_to_df _thenan_sf _sf_to_usi _usi_to_sf
105
106 DPBIT_FUNCS = _pack_df _unpack_df _addsub_df _mul_df _div_df \
107     _fpcmp_parts_df _compare_df _eq_df _ne_df _gt_df _ge_df \
108     _lt_df _le_df _unord_df _si_to_df _df_to_si _negate_df _make_df \
109     _df_to_sf _thenan_df _df_to_usi _usi_to_df
110
111 TPBIT_FUNCS = _pack_tf _unpack_tf _addsub_tf _mul_tf _div_tf \
112     _fpcmp_parts_tf _compare_tf _eq_tf _ne_tf _gt_tf _ge_tf \
113     _lt_tf _le_tf _unord_tf _si_to_tf _tf_to_si _negate_tf _make_tf \
114     _tf_to_df _tf_to_sf _thenan_tf _tf_to_usi _usi_to_tf
115
116 # These might cause a divide overflow trap and so are compiled with
117 # unwinder info.
118 LIB2_DIVMOD_FUNCS = _divdi3 _moddi3 _udivdi3 _umoddi3 _udiv_w_sdiv _udivmoddi4
119
120 #-----------------------------------------------------------------------
121 #
122 #       Platform specific bits.
123 #       When upgrading GCC, get the following definitions from config/<cpu>/t-*
124 #
125 .if ${TARGET_CPUARCH} == "arm"
126 #       from config/arm/t-strongarm-elf
127 CFLAGS+=        -Dinhibit_libc -fno-inline
128 .if ${COMPILER_TYPE} == "clang"
129 CFLAGS+=        -fheinous-gnu-extensions
130 .endif
131
132 LIB1ASMSRC =    lib1funcs.asm
133 LIB1ASMFUNCS =  _dvmd_tls _bb_init_func
134 .if ${MK_ARM_EABI} != "no"
135 LIB2ADDEH =     unwind-arm.c libunwind.S pr-support.c unwind-c.c
136 # Some compilers generate __aeabi_ functions libgcc_s is missing
137 DPADD+=         ${LIBGCC}
138 LDADD+=         -lgcc
139 .else
140 LIB2FUNCS_EXTRA = floatunsidf.c floatunsisf.c
141 .endif
142 .endif
143
144 .if ${TARGET_CPUARCH} == mips
145 LIB2FUNCS_EXTRA = floatunsidf.c floatunsisf.c
146 # ABIs other than o32 need this
147 .if ${TARGET_ARCH} != "mips" && ${TARGET_ARCH} != "mipsel"
148 LIB2FUNCS_EXTRA+= floatdidf.c fixunsdfsi.c
149 LIB2FUNCS_EXTRA+= floatdisf.c floatundidf.c
150 LIB2FUNCS_EXTRA+= fixsfdi.c floatundisf.c
151 LIB2FUNCS_EXTRA+= fixdfdi.c fixunssfsi.c
152 .endif
153 .endif
154
155 .if ${TARGET_CPUARCH} == "ia64"
156 #       from config/ia64/t-ia64
157 LIB1ASMSRC   = lib1funcs.asm
158 LIB1ASMFUNCS = __divxf3 __divdf3 __divsf3 \
159         __divdi3 __moddi3 __udivdi3 __umoddi3 \
160         __divsi3 __modsi3 __udivsi3 __umodsi3 __save_stack_nonlocal \
161         __nonlocal_goto __restore_stack_nonlocal __trampoline \
162         _fixtfdi _fixunstfdi _floatditf
163 LIB2ADDEH = unwind-ia64.c unwind-sjlj.c unwind-c.c
164 .endif
165
166 .if ${TARGET_ARCH} == "powerpc"
167 #       from config/rs6000/t-ppccomm
168 LIB2FUNCS_EXTRA = tramp.asm
169 LIB2FUNCS_STATIC_EXTRA = eabi.asm
170 .endif
171
172 .if ${TARGET_ARCH} == "powerpc64"
173 #       from config/rs6000/t-ppccomm
174 LIB2FUNCS_EXTRA = tramp.asm
175 .endif
176
177 .if ${TARGET_CPUARCH} == "sparc64"
178 #       from config/sparc/t-elf
179 LIB1ASMSRC =   lb1spc.asm
180 LIB1ASMFUNCS = _mulsi3 _divsi3 _modsi3
181 .endif
182
183 #-----------------------------------------------------------------------
184
185 # Remove any objects from LIB2FUNCS and LIB2_DIVMOD_FUNCS that are
186 # defined as optimized assembly code in LIB1ASMFUNCS.
187 .if defined(LIB1ASMFUNCS)
188 .for sym in ${LIB1ASMFUNCS}
189 LIB2FUNCS:=     ${LIB2FUNCS:S/${sym}//g}
190 LIB2_DIVMOD_FUNCS:= ${LIB2_DIVMOD_FUNCS:S/${sym}//g}
191 .endfor
192 .endif
193
194 COMMONHDRS=     tm.h tconfig.h options.h unwind.h gthr-default.h
195
196 #-----------------------------------------------------------------------
197 #
198 # Helpful shortcuts for compiler invocations.
199 #
200 HIDE =  -fvisibility=hidden -DHIDE_EXPORTS
201 CC_T =  ${CC} -c ${CFLAGS} ${HIDE} -fPIC
202 CC_P =  ${CC} -c ${CFLAGS} ${HIDE} -p -fPIC
203 CC_S =  ${CC} -c ${CFLAGS} ${PICFLAG} -DSHARED
204
205 #-----------------------------------------------------------------------
206 #
207 # Functions from libgcc2.c
208 #
209 STD_CFLAGS =
210 DIV_CFLAGS =    -fexceptions -fnon-call-exceptions
211
212 STD_FUNCS =     ${LIB2FUNCS}
213 DIV_FUNCS =     ${LIB2_DIVMOD_FUNCS}
214
215 STD_CFILE =     libgcc2.c
216 DIV_CFILE =     libgcc2.c
217
218 OBJ_GRPS =      STD DIV
219
220 #-----------------------------------------------------------------------
221 #
222 # Floating point emulation functions
223 #
224 .if ${TARGET_CPUARCH} == "armNOT_YET" || \
225     ${TARGET_CPUARCH} == "powerpc" || ${TARGET_CPUARCH} == "sparc64"
226
227 FPBIT_CFLAGS =  -DFINE_GRAINED_LIBRARIES -DFLOAT
228 DPBIT_CFLAGS =  -DFINE_GRAINED_LIBRARIES
229
230 FPBIT_CFILE =   config/fp-bit.c
231 DPBIT_CFILE =   config/fp-bit.c
232
233 OBJ_GRPS +=     FPBIT DPBIT
234 .endif
235
236 #-----------------------------------------------------------------------
237 #
238 # Generic build rules for object groups defined above
239 #
240 .for T in ${OBJ_GRPS}
241 ${T}_OBJS_T =   ${${T}_FUNCS:S/$/.o/}
242 ${T}_OBJS_P =   ${${T}_FUNCS:S/$/.po/}
243 ${T}_OBJS_S =   ${${T}_FUNCS:S/$/.So/}
244 OBJS +=         ${${T}_FUNCS:S/$/.o/}
245
246 ${${T}_OBJS_T}: ${${T}_CFILE} ${COMMONHDRS}
247         ${CC_T} ${${T}_CFLAGS} -DL${.PREFIX} -o ${.TARGET} ${.ALLSRC:M*.c}
248 ${${T}_OBJS_P}: ${${T}_CFILE} ${COMMONHDRS}
249         ${CC_P} ${${T}_CFLAGS} -DL${.PREFIX} -o ${.TARGET} ${.ALLSRC:M*.c}
250 ${${T}_OBJS_S}: ${${T}_CFILE} ${COMMONHDRS}
251         ${CC_S} ${${T}_CFLAGS} -DL${.PREFIX} -o ${.TARGET} ${.ALLSRC:M*.c}
252 .endfor
253
254 #-----------------------------------------------------------------------
255 #
256 # Extra objects coming from separate files
257 #
258 .if !empty(LIB2ADD)
259 OBJS  +=        ${LIB2ADD:R:S/$/.o/}
260 SOBJS +=        ${LIB2ADD:R:S/$/.So/}
261 POBJS +=        ${LIB2ADD:R:S/$/.po/}
262 .endif
263
264 #-----------------------------------------------------------------------
265 #
266 # Objects that should be in static library only.
267 #
268 SYMS_ST =       ${LIB2FUNCS_ST} ${LIB2ADD_ST}
269 STAT_OBJS_T =   ${SYMS_ST:S/$/.o/}
270 STAT_OBJS_P =   ${SYMS_ST:S/$/.po/}
271 STATICOBJS  =   ${SYMS_ST:S/$/.o/}
272
273 ${STAT_OBJS_T}: ${STD_CFILE} ${COMMONHDRS}
274         ${CC_T} -DL${.PREFIX} -o ${.TARGET} ${.ALLSRC:M*.c}
275 ${STAT_OBJS_P}: ${STD_CFILE} ${COMMONHDRS}
276         ${CC_P} -DL${.PREFIX} -o ${.TARGET} ${.ALLSRC:M*.c}
277
278 #-----------------------------------------------------------------------
279 #
280 # Assembler files.
281 #
282 .if defined(LIB1ASMSRC)
283 ASM_T =         ${LIB1ASMFUNCS:S/$/.o/}
284 ASM_P =         ${LIB1ASMFUNCS:S/$/.po/}
285 ASM_S =         ${LIB1ASMFUNCS:S/$/.So/}
286 ASM_V =         ${LIB1ASMFUNCS:S/$/.vis/}
287 OBJS +=         ${LIB1ASMFUNCS:S/$/.o/}
288
289 ${ASM_T}: ${LIB1ASMSRC} ${.PREFIX}.vis
290         ${CC} -x assembler-with-cpp -c ${CFLAGS} -DL${.PREFIX} \
291             -o ${.TARGET} -include ${.PREFIX}.vis ${.ALLSRC:N*.h:N*.vis}
292 ${ASM_P}: ${LIB1ASMSRC} ${.PREFIX}.vis
293         ${CC} -x assembler-with-cpp -p -c ${CFLAGS} -DL${.PREFIX} \
294             -o ${.TARGET} -include ${.PREFIX}.vis ${.ALLSRC:N*.h:N*.vis}
295 ${ASM_S}: ${LIB1ASMSRC}
296         ${CC} -x assembler-with-cpp -c ${PICFLAG} ${CFLAGS} -DL${.PREFIX} \
297             -o ${.TARGET} ${.ALLSRC:N*.h}
298 ${ASM_V}: ${LIB1ASMSRC}
299         ${CC} -x assembler-with-cpp -c ${CFLAGS} -DL${.PREFIX} \
300             -o ${.PREFIX}.vo ${.ALLSRC:N*.h}
301         ( ${NM} -pg ${.PREFIX}.vo | \
302                 awk 'NF == 3 && $$2 !~ /^[UN]$$/ { print "\t.hidden ", $$3 }'\
303         ) > ${.TARGET}
304
305 CLEANFILES += ${ASM_V} ${ASM_V:R:S/$/.vo/}
306 .endif
307
308 #-----------------------------------------------------------------------
309 #
310 # Exception handling / unwinding support.
311 #
312 EH_OBJS_T = ${LIB2ADDEHSTATIC:R:S/$/.o/}
313 EH_OBJS_P = ${LIB2ADDEHSTATIC:R:S/$/.po/}
314 EH_OBJS_S = ${LIB2ADDEHSHARED:R:S/$/.So/}
315 EH_CFLAGS = -fexceptions -D__GLIBC__=3 -DElfW=__ElfN
316 SOBJS    += ${EH_OBJS_S}
317
318 .for _src in ${LIB2ADDEHSTATIC}
319 ${_src:R:S/$/.o/}: ${_src} ${COMMONHDRS}
320         ${CC_T} ${EH_CFLAGS} -o ${.TARGET} ${.IMPSRC}
321 ${_src:R:S/$/.po/}: ${_src} ${COMMONHDRS}
322         ${CC_P} ${EH_CFLAGS} -o ${.TARGET} ${.IMPSRC}
323 .endfor
324 .for _src in ${LIB2ADDEHSHARED}
325 ${_src:R:S/$/.So/}: ${_src} ${COMMONHDRS}
326         ${CC_S} ${EH_CFLAGS} -o ${.TARGET} ${.IMPSRC}
327 .endfor
328
329
330 #-----------------------------------------------------------------------
331 #
332 # Generated headers
333 #
334 ${COMMONHDRS}: ${.CURDIR}/../../usr.bin/cc/cc_tools/Makefile
335         ${MAKE} -f ${.ALLSRC} MFILE=${.ALLSRC} GCCDIR=${GCCDIR} ${.TARGET}
336
337 CLEANFILES += ${COMMONHDRS}
338 CLEANFILES += cs-*.h option*
339
340 #-----------------------------------------------------------------------
341 #
342 # Build symbol version map
343 #
344 SHLIB_MKMAP      = ${GCCDIR}/mkmap-symver.awk
345 SHLIB_MKMAP_OPTS =
346 SHLIB_MAPFILES   = ${GCCDIR}/libgcc-std.ver
347 .if ${TARGET_CPUARCH} == "arm" && ${MK_ARM_EABI} != "no"
348 SHLIB_MAPFILES  += ${GCCDIR}/config/arm/libgcc-bpabi.ver
349 .endif
350 VERSION_MAP      = libgcc.map
351
352 libgcc.map: ${SHLIB_MKMAP} ${SHLIB_MAPFILES} ${SOBJS} ${OBJS:R:S/$/.So/}
353         (  ${NM} -pg ${SOBJS};echo %% ; \
354           cat ${SHLIB_MAPFILES} \
355             | sed -e '/^[   ]*#/d' \
356                   -e 's/^%\(if\|else\|elif\|endif\|define\)/#\1/' \
357             | ${CC} ${CFLAGS} -E -xassembler-with-cpp -; \
358         ) | awk -f ${SHLIB_MKMAP} ${SHLIB_MKMAP_OPTS} > ${.TARGET}
359
360 CLEANFILES +=   libgcc.map
361
362 #-----------------------------------------------------------------------
363 #
364 # Build additional static libgcc_eh[_p].a libraries.
365 #
366 libgcc_eh.a:    ${EH_OBJS_T}
367         @${ECHO} building static gcc_eh library
368         @rm -f ${.TARGET}
369         @${AR} ${ARFLAGS} ${.TARGET} `lorder ${EH_OBJS_T} | tsort -q`
370         ${RANLIB} ${.TARGET}
371
372 all:    libgcc_eh.a
373
374 .if ${MK_PROFILE} != "no"
375 libgcc_eh_p.a:  ${EH_OBJS_P}
376         @${ECHO} building profiled gcc_eh library
377         @rm -f ${.TARGET}
378         @${AR} ${ARFLAGS} ${.TARGET} `lorder ${EH_OBJS_P} | tsort -q`
379         ${RANLIB} ${.TARGET}
380 all:    libgcc_eh_p.a
381 .endif
382
383 _libinstall: _lib-eh-install
384
385 _lib-eh-install:
386 .if ${MK_INSTALLLIB} != "no"
387         ${INSTALL} -C -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
388                 ${_INSTALLFLAGS} libgcc_eh.a ${DESTDIR}${LIBDIR}
389 .endif
390 .if ${MK_PROFILE} != "no"
391         ${INSTALL} -C -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
392                 ${_INSTALLFLAGS} libgcc_eh_p.a ${DESTDIR}${LIBDIR}
393 .endif
394
395 CLEANFILES+=    libgcc_eh.a libgcc_eh_p.a ${EH_OBJS_T} ${EH_OBJS_P}
396
397 .include <bsd.lib.mk>
398
399 .SUFFIXES: .vis .vo