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