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