1# $FreeBSD: src/gnu/lib/libgcc/Makefile,v 1.58.8.1 2009/04/15 03:14:26 kensmith Exp $ 2# $OpenBSD: Makefile,v 1.30 2018/01/04 19:46:31 kettenis Exp $ 3 4.include <bsd.own.mk> 5 6GCCLIB= ${.CURDIR}/../../../gcc 7GCCDIR= ${GCCLIB}/gcc 8 9.include "../Makefile.tgt" 10 11.if defined(CROSSDIR) 12LD=${CROSSDIR}/usr/${GCC_TARGET}/bin/ld 13RANLIB=${CROSSDIR}/usr/${GCC_TARGET}/bin/ranlib 14.endif 15 16.if defined(CROSS_TARGET) 17#Building cc for target, CC should already be the cross compiler 18.elif ${.OBJDIR} != ${.CURDIR} 19CC=${.OBJDIR}/../cc/cc -B ${.OBJDIR}/../cc1 20.else 21CC=${.CURDIR}/../cc/cc -B ${.CURDIR}/../cc1 22.endif 23 24.include "${.CURDIR}/../Makefile.ver" 25 26LIB= gcc 27LIBDIR= /usr/lib/gcc-lib/${GCC_TARGET}/${BASEVER} 28 29NOPROFILE= Yes 30NOPIC= Yes 31 32.include "${.CURDIR}/../Makefile.tgt" 33 34.PATH: ${GCCDIR}/config/${GCC_CPU} ${GCCDIR}/config ${GCCDIR} 35 36CFLAGS+= -DIN_GCC -DIN_LIBGCC2 -D__GCC_FLOAT_NOT_NEEDED \ 37 -DHAVE_GTHR_DEFAULT \ 38 -I${GCCLIB}/include \ 39 -I${GCCDIR}/config -I${GCCDIR} -I. \ 40 -I${.CURDIR}/../cc_tools \ 41 -fno-stack-protector 42 43LDFLAGS+= -nodefaultlibs 44LDADD+= -lc 45 46OBJS= # added to below in various ways depending on TARGET_ARCH 47 48#--------------------------------------------------------------------------- 49# 50# When upgrading GCC, get the following defintions straight from Makefile.in 51# 52# Library members defined in libgcc2.c. 53LIB2FUNCS= _muldi3 _negdi2 _lshrdi3 _ashldi3 _ashrdi3 \ 54 _cmpdi2 _ucmpdi2 _clear_cache \ 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 62# The floating-point conversion routines that involve a single-word integer. 63.for mode in sf df xf 64SWFLOATFUNCS+= _fixuns${mode}si 65.endfor 66 67# Likewise double-word routines. 68.for mode in sf df xf tf 69DWFLOATFUNCS+= _fix${mode}di _fixuns${mode}di 70DWFLOATFUNCS+= _floatdi${mode} _floatundi${mode} 71.endfor 72 73LIB2ADD = $(LIB2FUNCS_EXTRA) 74LIB2ADD_ST = $(LIB2FUNCS_STATIC_EXTRA) 75 76# Additional sources to handle exceptions; overridden by targets as needed. 77LIB2ADDEH = unwind-dw2.c unwind-sjlj.c gthr-gnat.c \ 78 unwind-c.c unwind-dw2-fde-openbsd.c 79LIB2ADDEHSTATIC = $(LIB2ADDEH) 80LIB2ADDEHSHARED = $(LIB2ADDEH) 81 82# List of extra C and assembler files to add to static and shared libgcc2. 83# Assembler files should have names ending in `.asm'. 84LIB2FUNCS_EXTRA = 85 86# List of extra C and assembler files to add to static libgcc2. 87# Assembler files should have names ending in `.asm'. 88LIB2FUNCS_STATIC_EXTRA = 89 90# Defined in libgcc2.c, included only in the static library. 91LIB2FUNCS_ST = _eprintf __gcc_bcmp 92 93FPBIT_FUNCS = _pack_sf _unpack_sf _addsub_sf _mul_sf _div_sf \ 94 _fpcmp_parts_sf _compare_sf _eq_sf _ne_sf _gt_sf _ge_sf \ 95 _lt_sf _le_sf _unord_sf _si_to_sf _sf_to_si _negate_sf _make_sf \ 96 _sf_to_df _sf_to_tf _thenan_sf _sf_to_usi _usi_to_sf _sf_to_tf 97 98DPBIT_FUNCS = _pack_df _unpack_df _addsub_df _mul_df _div_df \ 99 _fpcmp_parts_df _compare_df _eq_df _ne_df _gt_df _ge_df \ 100 _lt_df _le_df _unord_df _si_to_df _df_to_si _negate_df _make_df \ 101 _df_to_sf _df_to_tf _thenan_df _df_to_usi _usi_to_df 102 103TPBIT_FUNCS = _pack_tf _unpack_tf _addsub_tf _mul_tf _div_tf \ 104 _fpcmp_parts_tf _compare_tf _eq_tf _ne_tf _gt_tf _ge_tf \ 105 _lt_tf _le_tf _unord_tf _si_to_tf _tf_to_si _negate_tf _make_tf \ 106 _tf_to_df _tf_to_sf _thenan_tf _tf_to_usi _usi_to_tf 107 108# These might cause a divide overflow trap and so are compiled with 109# unwinder info. 110LIB2_DIVMOD_FUNCS = _divdi3 _moddi3 _udivdi3 _umoddi3 _udiv_w_sdiv _udivmoddi4 111 112#----------------------------------------------------------------------- 113# 114# Platform specific bits. 115# When upgrading GCC, get the following definitions from config/<cpu>/t-* 116# 117.if ${TARGET_ARCH} == "alpha" 118CFLAGS+= -mieee 119LIB2FUNCS_EXTRA = qrnnd.asm 120.endif 121 122.if ${TARGET_ARCH} == "arm" 123# from config/arm/t-strongarm-elf 124CFLAGS+= -Dinhibit_libc -fno-inline 125LIB1ASMSRC = lib1funcs.asm 126LIB1ASMFUNCS = _dvmd_tls _bb_init_func 127LIB1ASMFUNCS+= _aeabi_lcmp _aeabi_ulcmp _aeabi_ldivmod _aeabi_uldivmod 128LIB1ASMFUNCS+= _cmpsf2 _fixunssfsi _negsf2 129LIB1ASMFUNCS+= _cmpdf2 _fixunsdfsi _negdf2 130LIB2FUNCS_EXTRA = floatunsidf.c floatunsisf.c 131LIB2ADDEH = unwind-arm.c libunwind.S pr-support.c unwind-c.c 132SWFLOATFUNCS = 133DWFLOATFUNCS = _floatundisf _floatundidf 134 135# Not now 136#LIB1ASMFUNCS = _udivsi3 _divsi3 _umodsi3 _modsi3 _dvmd_tls _bb_init_func 137#LIB1ASMFUNCS+= _call_via_rX _interwork_call_via_rX \ 138# _lshrdi3 _ashrdi3 _ashldi3 \ 139# _negdf2 _addsubdf3 _muldivdf3 _cmpdf2 _unorddf2 _fixdfsi _fixunsdfsi \ 140# _truncdfsf2 _negsf2 _addsubsf3 _muldivsf3 _cmpsf2 _unordsf2 \ 141# _fixsfsi _fixunssfsi _floatdidf _floatdisf 142.endif 143 144.if ${TARGET_ARCH} == "hppa" 145CFLAGS+= -fPIC -DELF=1 -DLINUX=1 146LIB1ASMFUNCS = _divI _divU _remI _remU _div_const _mulI _dyncall 147LIB1ASMSRC = pa/milli64.S 148LIB2FUNCS_EXTRA = fptr.c 149.endif 150 151.if ${TARGET_ARCH} == "hppa64" 152CFLAGS+= -fPIC -Dpa64=1 -DELF=1 153LIB1ASMFUNCS = _divI _divU _remI _remU _div_const _mulI 154LIB1ASMSRC = pa/milli64.S 155LIB2FUNCS_EXTRA = fptr.c 156.endif 157 158.if ${TARGET_ARCH} == "ia64" 159LIB1ASMSRC = ia64/lib1funcs.asm 160LIB1ASMFUNCS = __divxf3 __divdf3 __divsf3 \ 161 __divdi3 __moddi3 __udivdi3 __umoddi3 \ 162 __divsi3 __modsi3 __udivsi3 __umodsi3 __save_stack_nonlocal \ 163 __nonlocal_goto __restore_stack_nonlocal __trampoline \ 164 _fixtfdi _fixunstfdi _floatditf 165LIB2ADDEH = unwind-ia64.c unwind-sjlj.c unwind-c.c 166.endif 167 168.if ${TARGET_ARCH} == "mips64" || ${TARGET_ARCH} == "mips64el" 169LIB2FUNCS_EXTRA = sync.S 170.endif 171 172.if ${TARGET_ARCH} == "sh" 173CFLAGS+= -fpic -DNO_FPSCR_VALUES 174LIB1ASMSRC = sh/lib1funcs.asm 175LIB1ASMFUNCS = _ashiftrt _ashiftrt_n _ashiftlt _lshiftrt _movmem \ 176 _movmem_i4 _mulsi3 _sdivsi3 _sdivsi3_i4 _udivsi3 _udivsi3_i4 _set_fpscr \ 177 _udiv_qrnnd_16 _ic_invalidate _ic_invalidate_array 178.endif 179 180.if ${TARGET_ARCH} == "powerpc" 181# from config/rs6000/t-ppccomm 182LIB2FUNCS_EXTRA = tramp.asm darwin-ldouble.c 183LIB2FUNCS_STATIC_EXTRA = eabi.asm 184.endif 185 186#----------------------------------------------------------------------- 187 188# Remove any objects from LIB2FUNCS and LIB2_DIVMOD_FUNCS that are 189# defined as optimized assembly code in LIB1ASMFUNCS. 190.if defined(LIB1ASMFUNCS) 191.for sym in ${LIB1ASMFUNCS} 192LIB2FUNCS:= ${LIB2FUNCS:S/${sym}//g} 193LIB2_DIVMOD_FUNCS:= ${LIB2_DIVMOD_FUNCS:S/${sym}//g} 194.endfor 195.endif 196 197COMMONHDRS= tm.h tconfig.h options.h unwind.h gthr-default.h 198 199#----------------------------------------------------------------------- 200# 201# Helpful shortcuts for compiler invocations. 202# 203#HIDE = -fvisibility=hidden -DHIDE_EXPORTS 204CC_T = ${CC} -c ${CFLAGS} ${HIDE} -fPIC 205CC_P = ${CC} -c ${CFLAGS} ${HIDE} -p -fPIC 206CC_S = ${CC} -c ${CFLAGS} ${PICFLAG} -DSHARED 207 208#----------------------------------------------------------------------- 209# 210# Functions from libgcc2.c 211# 212STD_CFLAGS = 213DIV_CFLAGS = -fexceptions -fnon-call-exceptions 214SW_CFLAGS = 215DW_CFLAGS = 216 217STD_FUNCS = ${LIB2FUNCS} 218DIV_FUNCS = ${LIB2_DIVMOD_FUNCS} 219SI_FUNCS = ${SWFLOATFUNCS} 220DI_FUNCS = ${DWFLOATFUNCS} 221 222STD_CFILE = libgcc2.c 223DIV_CFILE = libgcc2.c 224SI_CFILE = libgcc2.c 225DI_CFILE = libgcc2.c 226 227OBJ_GRPS = STD DIV SI DI 228 229#----------------------------------------------------------------------- 230# 231# Floating point emulation functions 232# 233.if ${TARGET_ARCH} == "armNOT_YET" || ${TARGET_ARCH} == "m88k" || \ 234 ${TARGET_ARCH} == "mips64" || ${TARGET_ARCH} == "mips64el" || \ 235 ${TARGET_ARCH} == "powerpc" || \ 236 ${TARGET_ARCH} == "sparc64" 237 238FPBIT_CFLAGS = -DFINE_GRAINED_LIBRARIES -DFLOAT 239DPBIT_CFLAGS = -DFINE_GRAINED_LIBRARIES 240 241.if ${TARGET_ARCH} == "mips64" || ${TARGET_ARCH} == "mips64el" 242SI_CFLAGS += -DLIBGCC2_UNITS_PER_WORD=4 243DI_CFLAGS += -DLIBGCC2_UNITS_PER_WORD=4 244 245TI_FUNCS = ${DWFLOATFUNCS:S/di/ti/} 246TI_CFILE = libgcc2.c 247 248FPBIT_CFLAGS += -DTMODES 249DPBIT_CFLAGS += -DTMODES 250.endif 251 252.if ${TARGET_ARCH} == "mips64el" 253FPBIT_CFLAGS += -DFLOAT_BIT_ORDER_MISMATCH 254DPBIT_CFLAGS += -DFLOAT_BIT_ORDER_MISMATCH 255.endif 256 257FPBIT_CFILE = config/fp-bit.c 258DPBIT_CFILE = config/fp-bit.c 259 260OBJ_GRPS += FPBIT DPBIT 261.endif 262 263.if ${TARGET_ARCH} == "mips64" || ${TARGET_ARCH} == "mips64el" 264 265TPBIT_CFLAGS = -DFINE_GRAINED_LIBRARIES -DTFLOAT 266 267.if ${TARGET_ARCH} == "mips64el" 268TPBIT_CFLAGS += -DFLOAT_BIT_ORDER_MISMATCH 269.endif 270 271TPBIT_CFILE = config/fp-bit.c 272 273OBJ_GRPS += TPBIT 274.endif 275 276#----------------------------------------------------------------------- 277# 278# Generic build rules for object groups defined above 279# 280.for T in ${OBJ_GRPS} 281${T}_OBJS_T = ${${T}_FUNCS:S/$/.o/} 282${T}_OBJS_P = ${${T}_FUNCS:S/$/.po/} 283${T}_OBJS_S = ${${T}_FUNCS:S/$/.So/} 284OBJS += ${${T}_FUNCS:S/$/.o/} 285 286${${T}_OBJS_T}: ${${T}_CFILE} ${COMMONHDRS} 287 ${CC_T} ${${T}_CFLAGS} -DL${.PREFIX} -o ${.TARGET} ${.ALLSRC:M*.c} 288${${T}_OBJS_P}: ${${T}_CFILE} ${COMMONHDRS} 289 ${CC_P} ${${T}_CFLAGS} -DL${.PREFIX} -o ${.TARGET} ${.ALLSRC:M*.c} 290${${T}_OBJS_S}: ${${T}_CFILE} ${COMMONHDRS} 291 ${CC_S} ${${T}_CFLAGS} -DL${.PREFIX} -o ${.TARGET} ${.ALLSRC:M*.c} 292.endfor 293 294#----------------------------------------------------------------------- 295# 296# Special versions of the floating-point conversion routines. 297# 298.if !empty{TI_FUNCS} 299TI_OBJS_T = ${TI_FUNCS:S/$/.o/} 300OBJS += ${TI_FUNCS:S/$/.o/} 301 302${TI_OBJS_T}: ${TI_CFILE} ${COMMONHDRS} 303 ${CC_T} ${TI_CFLAGS} -DL${.PREFIX:S/ti/di/} -o ${.TARGET} ${.ALLSRC:M*.c} 304${TI_OBJS_P}: ${TI_CFILE} ${COMMONHDRS} 305 ${CC_P} ${TI_CFLAGS} -DL${.PREFIX:S/ti/di/} -o ${.TARGET} ${.ALLSRC:M*.c} 306${TI_OBJS_T}: ${TI_CFILE} ${COMMONHDRS} 307 ${CC_S} ${TI_CFLAGS} -DL${.PREFIX:S/ti/di/} -o ${.TARGET} ${.ALLSRC:M*.c} 308.endif 309 310#----------------------------------------------------------------------- 311# 312# Extra objects coming from separate files 313# 314.if !empty(LIB2ADD) 315OBJS += ${LIB2ADD:R:S/$/.o/} 316SOBJS += ${LIB2ADD:R:S/$/.So/} 317POBJS += ${LIB2ADD:R:S/$/.po/} 318.endif 319 320#----------------------------------------------------------------------- 321# 322# Objects that should be in static library only. 323# 324SYMS_ST = ${LIB2FUNCS_ST} ${LIB2ADD_ST} 325STAT_OBJS_T = ${SYMS_ST:S/$/.o/} 326STAT_OBJS_P = ${SYMS_ST:S/$/.po/} 327STATICOBJS = ${SYMS_ST:S/$/.o/} 328 329${STAT_OBJS_T}: ${STD_CFILE} ${COMMONHDRS} 330 ${CC_T} -DL${.PREFIX} -o ${.TARGET} ${.ALLSRC:M*.c} 331${STAT_OBJS_P}: ${STD_CFILE} ${COMMONHDRS} 332 ${CC_P} -DL${.PREFIX} -o ${.TARGET} ${.ALLSRC:M*.c} 333 334#----------------------------------------------------------------------- 335# 336# Assembler files. 337# 338.if defined(LIB1ASMSRC) 339ASM_T = ${LIB1ASMFUNCS:S/$/.o/} 340ASM_P = ${LIB1ASMFUNCS:S/$/.po/} 341ASM_S = ${LIB1ASMFUNCS:S/$/.So/} 342ASM_V = ${LIB1ASMFUNCS:S/$/.vis/} 343OBJS += ${LIB1ASMFUNCS:S/$/.o/} 344 345${ASM_T}: ${LIB1ASMSRC} ${.PREFIX}.vis 346 ${CC} -x assembler-with-cpp -c ${CFLAGS} -DL${.PREFIX} \ 347 -o ${.TARGET} -include ${.PREFIX}.vis ${.ALLSRC:N*.h:N*.vis} 348${ASM_P}: ${LIB1ASMSRC} ${.PREFIX}.vis 349 ${CC} -x assembler-with-cpp -p -c ${CFLAGS} -DL${.PREFIX} \ 350 -o ${.TARGET} -include ${.PREFIX}.vis ${.ALLSRC:N*.h:N*.vis} 351${ASM_S}: ${LIB1ASMSRC} 352 ${CC} -x assembler-with-cpp -c ${PICFLAG} ${CFLAGS} -DL${.PREFIX} \ 353 -o ${.TARGET} ${.ALLSRC:N*.h} 354${ASM_V}: ${LIB1ASMSRC} 355 ${CC} -x assembler-with-cpp -c ${CFLAGS} -DL${.PREFIX} \ 356 -o ${.PREFIX}.vo ${.ALLSRC:N*.h} 357 ( nm -pg ${.PREFIX}.vo | \ 358 awk 'NF == 3 && $$2 !~ /^[FUN]$$/ { print "\t.hidden ", $$3 }'\ 359 ) > ${.TARGET} 360 361CLEANFILES += ${ASM_V} ${ASM_V:R:S/$/.vo/} 362.endif 363 364#----------------------------------------------------------------------- 365# 366# Exception handling / unwinding support. 367# 368EH_OBJS_T = ${LIB2ADDEHSTATIC:R:S/$/.o/} 369EH_OBJS_P = ${LIB2ADDEHSTATIC:R:S/$/.po/} 370EH_OBJS_S = ${LIB2ADDEHSHARED:R:S/$/.So/} 371EH_CFLAGS = -fexceptions 372.if ${TARGET_ARCH} == "sh" 373EH_CFLAGS+= -fno-stack-protector # necessary for unwind-dw2.c 374.endif 375SOBJS += ${EH_OBJS_S} 376OBJS += ${EH_OBJS_T} 377 378.for _src in ${LIB2ADDEHSTATIC} 379${_src:R:S/$/.o/}: ${_src} ${COMMONHDRS} 380 ${CC_T} ${EH_CFLAGS} -o ${.TARGET} ${.IMPSRC} 381${_src:R:S/$/.po/}: ${_src} ${COMMONHDRS} 382 ${CC_P} ${EH_CFLAGS} -o ${.TARGET} ${.IMPSRC} 383.endfor 384 385#----------------------------------------------------------------------- 386# 387# Generated headers 388# 389${COMMONHDRS}: ${.CURDIR}/../cc_tools/Makefile 390 ${MAKE} -f ${.ALLSRC} MFILE=${.ALLSRC} GCCDIR=${GCCDIR} ${.TARGET} 391 392CLEANFILES += ${COMMONHDRS} 393CLEANFILES += cs-*.h option* 394 395beforeinstall: 396 ${INSTALL} -d -o ${BINOWN} -g ${BINGRP} -m ${DIRMODE} \ 397 ${DESTDIR}${LIBDIR} 398 399.include <bsd.lib.mk> 400 401 402.SUFFIXES: .vis .vo .asm 403 404.if ${TARGET_ARCH} == "alpha" || ${TARGET_ARCH} == "powerpc" 405.asm.o: 406 ${CC_T} ${CFLAGS} -xassembler-with-cpp -o ${.TARGET} ${.IMPSRC} 407.endif 408