Home | History | Annotate | Line # | Download | only in libgfortran
Makefile revision 1.3
      1 #	$NetBSD: Makefile,v 1.3 2026/01/19 09:41:06 mrg Exp $
      2 
      3 # XXX libgfortran also has a libcaf_single thing in here.
      4 
      5 # This needs to be before bsd.init.mk
      6 .if defined(BSD_MK_COMPAT_FILE)
      7 .include <${BSD_MK_COMPAT_FILE}>
      8 .endif
      9 
     10 .include <bsd.init.mk>
     11 
     12 LIB=		gfortran
     13 
     14 # Match GCC 14.
     15 SHLIB_MAJOR=	5
     16 SHLIB_MINOR=	0
     17 
     18 DIST=		${GCCDIST}
     19 GNUHOSTDIST=    ${DIST}
     20 GFORTRAN=	${DIST}/libgfortran
     21 
     22 # These are earlier than included file paths, to avoid getting eg
     23 # libbacktrace's read.c instead of io/read.c.
     24 .PATH: ${DIST}/libgfortran
     25 .PATH: ${DIST}/libgfortran/generated
     26 .PATH: ${DIST}/libgfortran/intrinsics
     27 .PATH: ${DIST}/libgfortran/runtime
     28 .PATH: ${DIST}/libgfortran/io
     29 .PATH: ${DIST}/libgfortran/ieee
     30 .PATH: ${.CURDIR}/arch/${GCC_MACHINE_ARCH}
     31 
     32 # remove prefixes, .inc and .h files
     33 GFORTRAN_SRCS=	${G_libgfortran_la_SOURCES:C,^.*/,,:C,.*\.inc$,,:C,.*\.h$,,}
     34 
     35 .include "../Makefile.gthr"
     36 .include "${.CURDIR}/arch/${GCC_MACHINE_ARCH}/defs.mk"
     37 .include "../libbacktrace/Makefile.sources"
     38 
     39 GFORTRAN_BACKTRACE_SRCS=	${BACKTRACE_SRCS:backtrace.c=libbacktrace-backtrace.c}
     40 
     41 BUILDSYMLINKS+= ${GNUHOSTDIST}/libbacktrace/backtrace.c libbacktrace-backtrace.c
     42 
     43 # gcc builddir before libgcc
     44 # libgcc builddir after libgcc
     45 
     46 .if ${HAVE_QUADMATH} != no
     47 CPPFLAGS_QUADMATH=-I${DIST}/libquadmath
     48 .else
     49 CPPFLAGS_QUADMATH=
     50 .endif
     51 
     52 .for _s in ${GFORTRAN_SRCS}
     53 CPPFLAGS.${_s}+=	-I. \
     54 		-I${.CURDIR}/arch/${GCC_MACHINE_ARCH} \
     55 		-I${GFORTRAN} \
     56 		-I${GFORTRAN}/io \
     57 		-I${DIST}/gcc \
     58 		-I${DIST}/gcc/config \
     59 		${CPPFLAGS_QUADMATH} \
     60 		-I${DIST}/libgcc \
     61 		-I${DIST}/libbacktrace \
     62 		-I${DIST}/../lib/libbacktrace/arch/${GCC_MACHINE_ARCH} \
     63 		-I${.CURDIR}/arch/${GCC_MACHINE_ARCH}
     64 .endfor
     65 
     66 .for _s in ${GFORTRAN_BACKTRACE_SRCS}
     67 CPPFLAGS.${_s}+=	-I. \
     68 		${BACKTRACE_CPPFLAGS}
     69 .endfor
     70 
     71 SRCS=		${GFORTRAN_SRCS} ${GFORTRAN_BACKTRACE_SRCS}
     72 
     73 FFLAGS+=	-I. -fno-repack-arrays -fno-underscoring -I${.CURDIR}/arch/${GCC_MACHINE_ARCH}
     74 
     75 LIBDPLIBS+=	m ${NETBSDSRCDIR}/lib/libm
     76 .if ${HAVE_QUADMATH} != no
     77 LIBDPLIBS+=	quadmath ${.CURDIR}/../libquadmath
     78 .endif
     79 
     80 DPSRCS+=	kinds.h kinds.inc c99_protos.inc fpu-target.inc \
     81 		selected_int_kind.inc selected_real_kind.inc
     82 
     83 ${GFORTRAN_SRCS:M*.F90}: ${DPSRCS}
     84 
     85 INTLIST='1 2 4 8 16'
     86 REALLIST='4 8 10 16'
     87 
     88 fpu-target.h: ${GFORTRAN}/${G_FPU_HOST_HEADER}
     89 	cp ${GFORTRAN}/${G_FPU_HOST_HEADER} $@
     90 
     91 fpu-target.inc: fpu-target.h ${DIST}/gcc/fortran/libgfortran.h
     92 	${TOOL_GREP} -h '^#define GFC_FPE_' ${.ALLSRC} > ${.TARGET}
     93 
     94 c99_protos.inc: ${GFORTRAN}/c99_protos.h
     95 	${TOOL_GREP} '^#' < ${.ALLSRC} > ${.TARGET} || rm ${.TARGET}
     96 LIBS+=	${BACKENDOBJ}/libbackend.a
     97 kinds.h: ${GFORTRAN}/mk-kinds-h.sh
     98 	${HOST_SH} ${GFORTRAN}/mk-kinds-h.sh \
     99 		    ${INTLIST} \
    100 		    ${REALLIST} \
    101 		    "${FC} ${FFLAGS}" \
    102 		    no > \
    103 	    ${.TARGET} || rm ${.TARGET}
    104 
    105 kinds.inc: kinds.h ${GFORTRAN}/kinds-override.h
    106 	cat kinds.h ${GFORTRAN}/kinds-override.h | \
    107 		    ${TOOL_GREP} '^#' | \
    108 		    ${TOOL_GREP} -v include > \
    109 	    ${.TARGET} || rm ${.TARGET}
    110 
    111 selected_int_kind.inc: ${GFORTRAN}/mk-sik-inc.sh
    112 	${HOST_SH} ${GFORTRAN}/mk-sik-inc.sh \
    113 		    ${INTLIST} \
    114 		    "${FC} ${FFLAGS}" > \
    115 	    ${.TARGET} || rm ${.TARGET}
    116 
    117 selected_real_kind.inc: ${GFORTRAN}/mk-srk-inc.sh
    118 	${HOST_SH} ${GFORTRAN}/mk-srk-inc.sh \
    119 		    ${REALLIST} \
    120 		    "${FC} ${FFLAGS}" > \
    121 	    ${.TARGET} || rm ${.TARGET}
    122 
    123 fpu.c: fpu-target.h
    124 
    125 COPTS.date_and_time.c+=	${CC_WNO_FORMAT_TRUNCATION}
    126 COPTS.list_read.c+=	-Wno-error=pointer-arith
    127 COPTS.transfer.c+=	-Wno-error=pointer-arith
    128 COPTS.write.c+=		-Wno-error=pointer-arith
    129 
    130 # ieee_arithmetic needs ieee_exceptions.mod to be already built
    131 ieee_arithmetic.o ieee_arithmetic.pico ieee_arithmetic.po ieee_arithmetic.go: ieee_exceptions.pico ieee_exceptions.po ieee_exceptions.o ieee_exceptions.go
    132 
    133 # these .mod's gets built multiple times, so serialise those
    134 .for _mod in ieee_arithmetic ieee_exceptions ieee_features
    135 ${_mod}.mod: ${_mod}.o
    136 ${_mod}.o: ${_mod}.pico
    137 ${_mod}.pico: ${_mod}.po
    138 ${_mod}.po: ${_mod}.go
    139 .endfor
    140 
    141 CLEANFILES+=	fpu-target.h fpu-target.inc c99_protos.inc \
    142 		kinds.h kinds.inc \
    143 		selected_int_kind.inc selected_real_kind.inc \
    144 		ieee_arithmetic.mod ieee_exceptions.mod ieee_features.mod
    145 
    146 .for _f in ${G_i_matmul_c:C,^.*/,,}
    147 FOPTS.${_f}+=	-ffast-math -ftree-vectorize -funroll-loops --param max-unroll-times=4
    148 .endfor
    149 
    150 #.if ${MACHINE} == "amd64"
    151 .for _f in ${G_i_matmulavx128_c:C,^.*/,,}
    152 FOPTS.${_f}+=	-ffast-math -ftree-vectorize -funroll-loops --param max-unroll-times=4 -mprefer-avx128
    153 .endfor
    154 #.endif
    155 
    156 .for _f in ${G_i_matmull_c:C,^.*/,,}
    157 FOPTS.${_f}+=	-funroll-loops
    158 .endfor
    159 
    160 .for _f in ${G_gfor_specific_src:C,^.*/,,}
    161 FOPTS.${_f}+=	-fallow-leading-underscore -fbuilding-libgfortran
    162 .endfor
    163 
    164 .for _f in selected_real_kind.f90 selected_int_kind.f90
    165 FOPTS.${_f}+=	-fallow-leading-underscore -fbuilding-libgfortran
    166 .endfor
    167 
    168 .for _f in ${G_gfor_ieee_src:C,^.*/,,}
    169 FOPTS.${_f}+=	-Wno-unused-dummy-argument -Wno-c-binding-type -ffree-line-length-0 -fallow-leading-underscore -fsignaling-nans -fbuilding-libgfortran
    170 .endfor
    171 
    172 .for _f in ${G_gfor_ieee_helper_src:C,^.*/,,}
    173 FOPTS.${_f}+=	-fsignaling-nans
    174 .endfor
    175 
    176 # Don't install these more than once.
    177 .ifndef MLIBDIR
    178 INCS=		${G_nodist_finclude_HEADERS}
    179 INCSDIR=	${GCC_INCSDIR}/finclude
    180 
    181 # This is where GCC looks for it.
    182 FILES=		libgfortran.spec
    183 FILESDIR=	${LIBDIR}
    184 .endif
    185 
    186 .if ${MACHINE} == "vax"
    187 . for _f in unpack_i1.c unpack_i2.c unpack_i4.c unpack_i8.c unpack_r4.c unpack_r8.c unpack_c4.c unpack_c8.c
    188 COPTS.${_f}+=	${CC_WNO_MAYBE_UNINITIALIZED}
    189 . endfor
    190 # Ugh infinity/nan stuff
    191 . for _f in read.c erfc_scaled.c c99_functions.c trigd.c
    192 COPTS.${_f}+=	-Wno-error
    193 . endfor
    194 .endif
    195 
    196 # XXX
    197 .if ${MACHINE} == "riscv"
    198 COPTS.ISO_Fortran_binding.c+=	-Wno-error=format
    199 .endif
    200 
    201 .include <bsd.lib.mk>
    202