[BACK]Return to bootstrap.mk CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / pkgsrc / lang / ghc7

Annotation of pkgsrc/lang/ghc7/bootstrap.mk, Revision 1.18

1.18    ! joerg       1: # $NetBSD: bootstrap.mk,v 1.17 2015/02/07 09:35:55 pho Exp $
1.1       obache      2: # -----------------------------------------------------------------------------
1.17      pho         3: # Select a bindist of bootstrapping compiler on a per-platform basis.
1.1       obache      4: #
                      5: # BOOT_ARCHIVE
                      6: #   This variable is set to the name of compressed archive file of a
                      7: #   bootstrapping compiler for the current platform.
                      8: #
                      9: # BOOT_TARBALL
                     10: #   Similar to BOOT_ARCHIVE, but "*.tar" not "*.tar.xz".
                     11: #
                     12: .include "../../mk/bsd.prefs.mk"
                     13: .if ${MACHINE_ARCH} == "i386" && ${OPSYS} == "FreeBSD"
1.9       obache     14: BOOT_ARCHIVE:= ${PKGNAME}-boot-i386-unknown-freebsd.tar.xz
1.1       obache     15:
                     16: .elif ${MACHINE_ARCH} == "i386" && ${OPSYS} == "NetBSD"
1.9       obache     17: BOOT_ARCHIVE:= ${PKGNAME}-boot-i386-unknown-netbsd.tar.xz
1.1       obache     18:
                     19: .elif ${MACHINE_ARCH} == "powerpc" && ${OPSYS} == "Darwin"
1.13      pho        20: BOOT_ARCHIVE:= ${PKGNAME}-boot-powerpc-apple-darwin.tar.xz
1.1       obache     21: # Existence of libelf makes LeadingUnderscore being "NO", which is
                     22: # incorrect for this platform. See ${WRKSRC}/aclocal.m4
                     23: # (FP_LEADING_UNDERSCORE)
                     24: CONFLICTS+=    libelf-[0-9]*
                     25:
                     26: .elif ${MACHINE_ARCH} == "x86_64" && ${OPSYS} == "Linux"
1.9       obache     27: BOOT_ARCHIVE:= ${PKGNAME}-boot-x86_64-unknown-linux.tar.xz
1.1       obache     28:
                     29: .elif ${MACHINE_ARCH} == "x86_64" && ${OPSYS} == "NetBSD"
1.9       obache     30: BOOT_ARCHIVE:= ${PKGNAME}-boot-x86_64-unknown-netbsd.tar.xz
1.1       obache     31:
                     32: .elif !empty(MACHINE_PLATFORM:MSunOS-5.11-i386)
1.10      jperkin    33: BOOT_ARCHIVE:=  ${PKGNAME}-boot-i386-unknown-solaris2.tar.xz
1.1       obache     34:
                     35: .elif !empty(MACHINE_PLATFORM:MSunOS-5.11-x86_64)
1.9       obache     36: BOOT_ARCHIVE:=  ${PKGNAME}-boot-x86_64-unknown-solaris2.tar.xz
1.1       obache     37:
                     38: .else
1.18    ! joerg      39: BOOT_ARCHIVE:= ${PKGNAME}-boot-unknown.tar.xz
1.1       obache     40: PKG_FAIL_REASON+=      "internal error: unsupported platform"
                     41: .endif
                     42:
1.17      pho        43: # FreeBSD < 10 surprisingly doesn't have a native iconv so we need to
                     44: # use pkgsrc libiconv for this OPSYS. And if a bootkit depends on
                     45: # pkgsrc libiconv, the "normal" build must do the same because GHC
                     46: # always needs to link executables with libiconv, just like libgmp
                     47: # when integer-gmp is used. For this reason it might be desirable to
                     48: # create two separate bootkits, one for < 10 and another for >= 10.
                     49: .if ${OPSYS} == "FreeBSD"
                     50: USE_BUILTIN.iconv=     no
                     51: .endif
                     52:
1.11      obache     53: # current bootstrap binary kit for SmartOS is built with ncurses5
                     54: .if !empty(MACHINE_PLATFORM:MSunOS-5.11-*) && !empty(OS_VARIANT:U:MSmartOS)
                     55: BUILD_DEPENDS+=        ncurses>=5.0:../../devel/ncurses
                     56: .endif
                     57:
1.10      jperkin    58: BOOT_TARBALL=  ${BOOT_ARCHIVE:C/\.xz$//}
1.2       obache     59:
1.1       obache     60:
                     61: # -----------------------------------------------------------------------------
                     62: # The "pre-configure" hook
                     63: #
                     64: # Install a bootstrapping compiler directly into TOOLS_DIR so that
                     65: # ./configure can find it.
                     66: #
                     67: USE_TOOLS+=    gmake xzcat xz
                     68:
                     69: pre-configure:
1.4       obache     70:        @${TEST} -f ${DISTDIR:Q}/${DIST_SUBDIR:Q}/${BOOT_ARCHIVE} || \
                     71:        ${FAIL_MSG}  "Put your trusted bootstrap archive as ${DISTDIR}/${DIST_SUBDIR}/${BOOT_ARCHIVE}"
1.13      pho        72:
1.1       obache     73:        @${PHASE_MSG} "Extracting bootstrapping compiler for ${PKGNAME}"
                     74:        ${RUN} ${MKDIR} ${WRKDIR:Q}/build-extract
                     75:        ${RUN} cd ${WRKDIR:Q}/build-extract && \
                     76:                ${EXTRACT_CMD_DEFAULT} ${DISTDIR:Q}/${DIST_SUBDIR:Q}/${BOOT_ARCHIVE}
                     77:
1.13      pho        78: # It is important to install the stage-0 compiler with our rpath flags
                     79: # configured, otherwise it will produce executables with no rpath and
                     80: # fail in the configure phase.
1.1       obache     81:        @${PHASE_MSG} "Preparing bootstrapping compiler for ${PKGNAME}"
1.4       obache     82:        ${RUN} cd ${WRKDIR:Q}/build-extract/${PKGNAME_NOREV}-boot && \
1.13      pho        83:                ${PKGSRC_SETENV} ${CONFIGURE_ENV} ${SH} ./configure \
1.1       obache     84:                        --prefix=${TOOLS_DIR:Q} && \
                     85:                ${MAKE_PROGRAM} install
                     86:
                     87:
                     88: # -----------------------------------------------------------------------------
                     89: # An unusual target "bootstrap"
                     90: #
                     91: # Build a bootstrapping compiler using an already installed GHC. This
                     92: # can certainly impossible if you don't have one. It's absolutely
                     93: # important to build it with the fewest possible run-time
                     94: # dependencies, otherwise the resulting binary can easily get
                     95: # unusable.
                     96: #
                     97:
1.16      pho        98: # We don't want our bootkits to have a run-time dependency on
                     99: # libgcc. In fact GHC's implementation of Haskell exception handling
                    100: # does not depend on libgcc's facilities so it is attractive to do the
                    101: # same for "normal" build... but we can't. This is because Haskell
                    102: # programs may call C functions via FFI, and those C functions may
                    103: # call C++ functions in turn, possibly in a different shared library.
                    104: .include "../../mk/compiler.mk"
                    105: .if make(bootstrap) && !empty(CC_VERSION:Mgcc-*)
                    106: # But on some platforms, gcc automagically inserts a dependency on a
                    107: # shared libgcc when -lpthread is given, which is seemingly
                    108: # unavoidable.
                    109: LDFLAGS+=      -static-libgcc
                    110: .endif
                    111:
                    112: # Gather information about packages on which bootkit depends. It will
                    113: # be used in the post-bootstrap phase.
1.14      pho       114: BOOT_GHC_DEPS:=                curses iconv
                    115: BOOT_GHC_PKGSRC_DEPS:= # empty
                    116: .for pkg in ${BOOT_GHC_DEPS}
                    117:
1.16      pho       118: # NOTE: pkglint(1) complains for including these builtin.mk files,
                    119: # telling that we must include buildlink3.mk instead. But then how do
                    120: # we get variables like USE_BUILTIN.${pkg} defined before including
                    121: # ../../mk/bsd.pkg.mk, given that ../../mk/bsd.buildlink3.mk isn't
                    122: # protected against multiple inclusion?
1.14      pho       123: CHECK_BUILTIN.${pkg}:= yes
                    124: .  if ${pkg} == "curses"
                    125: .    include "../../mk/curses.builtin.mk"
                    126: .  elif ${pkg} == "iconv"
                    127: .    include "../../converters/libiconv/builtin.mk"
                    128: .  endif
                    129: CHECK_BUILTIN.${pkg}:= no
                    130:
1.15      pho       131: # BOOT_GHC_PKGSRC_DEPS is a list of packages whose pkgsrc version is
                    132: # preferred over native one, either by user or ../../mk/platform
1.14      pho       133: .  if ${PREFER.${pkg}} == "pkgsrc"
                    134: BOOT_GHC_PKGSRC_DEPS+= ${pkg}
                    135: .  endif
                    136: .endfor
                    137:
1.16      pho       138: # Compiler wrappers must not remove -I/-L flags for the installed
                    139: # GHC's libdir, otherwise the GHC we are going to use for building our
1.12      pho       140: # bootstraping kit will not work at all. Ideally it should be added to
                    141: # BUILDLINK_PASSTHRU_DIRS only .if make(bootstrap), but then running
                    142: # "${MAKE} wrapper" before "${MAKE} bootstrap" will result in a
                    143: # cryptic error which we can't easily catch.
1.14      pho       144: BOOT_GHC_LIBDIR_CMD=           ghc --print-libdir
                    145: .if !defined(BOOT_GHC_LIBDIR)
                    146: BOOT_GHC_LIBDIR!=              ${BOOT_GHC_LIBDIR_CMD} 2>/dev/null || ${ECHO}
1.12      pho       147: .endif
1.14      pho       148: MAKEVARS+=                     BOOT_GHC_LIBDIR
                    149: BUILDLINK_PASSTHRU_DIRS+=      ${BOOT_GHC_LIBDIR}
1.1       obache    150:
1.12      pho       151: # Default values for BUILDLINK_INCDIRS.<pkg> are only generated in the
                    152: # barrier. See ../../mk/buildlink3/bsd.buildlink3.mk and
                    153: # ../../mk/bsd.pkg.barrier.mk
                    154: .PHONY: bootstrap
                    155: .if make(bootstrap)
                    156: _BARRIER_CMDLINE_TARGETS+=     bootstrap
                    157: .endif
                    158: .if !defined(_PKGSRC_BARRIER)
                    159: bootstrap: barrier
                    160: .else
1.14      pho       161: bootstrap: pre-bootstrap .WAIT ${WRKDIR}/${BOOT_ARCHIVE} .WAIT post-bootstrap
1.12      pho       162: .endif
1.8       obache    163:
                    164: .PHONY: pre-bootstrap
1.12      pho       165: pre-bootstrap: wrapper
1.14      pho       166: .if empty(BOOT_GHC_LIBDIR)
                    167:        @if ${BOOT_GHC_LIBDIR_CMD} 2>/dev/null 1>&2; then \
                    168:                ${ERROR_MSG} "Running \"${BOOT_GHC_LIBDIR_CMD}\" has failed during wrapper phase."; \
1.12      pho       169:                ${FAIL_MSG}  "Plase run \"${MAKE} clean\" and try again."; \
                    170:        else \
1.14      pho       171:                ${ERROR_MSG} "Failed to run \"${BOOT_GHC_LIBDIR_CMD}\":"; \
                    172:                ${BOOT_GHC_LIBDIR_CMD}; \
1.12      pho       173:                ${ERROR_MSG} "You don't seem to have a working GHC in your PATH."; \
                    174:                ${FAIL_MSG}  "Please install one and then run \"${MAKE} clean bootstrap\"."; \
                    175:        fi
                    176: .endif
1.14      pho       177: # ${_COOKIE.configure} is not defined yet so we can't use .if here.
1.12      pho       178:        @if ${TEST} -f ${_COOKIE.configure}; then \
                    179:                ${ERROR_MSG} "You have already configured the package in a way\
1.8       obache    180:                that building bootstrapping compiler is impossible."; \
1.12      pho       181:                ${FAIL_MSG}  "Please run \"${MAKE} clean\" first."; \
                    182:        fi
1.8       obache    183:
1.1       obache    184: ${WRKDIR}/lndir:
                    185:        @${PHASE_MSG} "Building lndir(1) to duplicate the source tree."
                    186:        cd ${WRKSRC:Q}/utils/lndir && \
1.10      jperkin   187:                ${PKG_CC:Q} lndir.c -o ${.TARGET}
1.1       obache    188:
                    189: ${WRKDIR}/stamp-lndir-boot: ${WRKDIR}/lndir
1.4       obache    190:        @${PHASE_MSG} "Duplicating the source tree for bootstrapping ${PKGNAME_NOREV}"
1.1       obache    191:        ${MKDIR} ${WRKDIR:Q}/build-boot
                    192:        cd ${WRKDIR:Q}/build-boot && \
1.4       obache    193:                ${WRKDIR}/lndir -silent ../${PKGNAME_NOREV:Q}
1.1       obache    194:        ${TOUCH} ${.TARGET}
                    195:
                    196: ${WRKDIR}/stamp-configure-boot: ${WRKDIR}/stamp-lndir-boot
1.4       obache    197:        @${PHASE_MSG} "Configuring bootstrapping compiler ${PKGNAME_NOREV}"
1.1       obache    198:        ${MKDIR} ${WRKDIR:Q}/build-boot
                    199:        cd ${WRKDIR:Q}/build-boot && \
1.12      pho       200:                ${PKGSRC_SETENV} ${CONFIGURE_ENV} ${SH} ./configure ${CONFIGURE_ARGS} && \
                    201:                ${CP} -f ${FILESDIR:Q}/bootstrap.build.mk mk/build.mk && \
                    202:                ${ECHO} >> mk/build.mk && \
                    203:                ${ECHO} "libraries/terminfo_CONFIGURE_OPTS += \
                    204:                        --configure-option=--with-curses-includes=${BUILDLINK_PREFIX.curses:Q}/${BUILDLINK_INCDIRS.curses:Q} \
                    205:                        --configure-option=--with-curses-libraries=${BUILDLINK_PREFIX.curses:Q}/${BUILDLINK_LIBDIRS.curses:Q}" \
                    206:                        >> mk/build.mk
1.1       obache    207:        ${TOUCH} ${.TARGET}
                    208:
                    209: ${WRKDIR}/stamp-build-boot: ${WRKDIR}/stamp-configure-boot
1.4       obache    210:        @${PHASE_MSG} "Building bootstrapping compiler ${PKGNAME_NOREV}"
1.1       obache    211:        ${RUN} cd ${WRKDIR:Q}/build-boot && ${BUILD_MAKE_CMD}
                    212:        ${TOUCH} ${.TARGET}
                    213:
                    214: ${WRKDIR}/${BOOT_TARBALL}: ${WRKDIR}/stamp-build-boot
1.4       obache    215:        @${PHASE_MSG} "Creating binary distribution of bootstrapping ${PKGNAME_NOREV}"
1.1       obache    216:        ${RUN} cd ${WRKDIR:Q}/build-boot && ${BUILD_MAKE_CMD} binary-dist
                    217:        ${MV} -f ${WRKDIR:Q}/build-boot/${BOOT_TARBALL} ${.TARGET}
                    218:
                    219: # This can take up half an hour. Memory usage is also very high, about 680 MiB.
                    220: ${WRKDIR}/${BOOT_ARCHIVE}: ${WRKDIR}/${BOOT_TARBALL}
1.4       obache    221:        @${PHASE_MSG} "Compressing binary distribution of bootstrapping ${PKGNAME_NOREV}"
1.1       obache    222:        ${XZ} --verbose -9 --extreme ${WRKDIR:Q}/${BOOT_TARBALL}
1.14      pho       223:
                    224: .PHONY: post-bootstrap
                    225: post-bootstrap:
                    226:        @${ECHO} "=========================================================================="
                    227:        @${ECHO} "Done creating ${BOOT_ARCHIVE}"
                    228:        @${ECHO} "  in ${WRKDIR}"
                    229:        @${ECHO}
                    230:        @${ECHO} "Now you can copy it into ${DISTDIR}/${DIST_SUBDIR} to use it as your"
                    231:        @${ECHO} "bootstrap kit. You may want to take a backup in case \"lintpkgsrc -r\""
                    232:        @${ECHO} "removes it."
                    233:        @${ECHO}
                    234:        @${ECHO} "Your bootstrap kit has the following run-time dependencies:"
                    235: .for pkg in ${BOOT_GHC_DEPS}
                    236:        @${PRINTF} "  * %-8s" "${pkg}:"
                    237: .  if !empty(USE_BUILTIN.${pkg}:M[nN][oO])
                    238:        @${ECHO_N} " pkgsrc ${BUILDLINK_PKGNAME.${pkg}}"
                    239: .  else
                    240:        @${ECHO_N} " native"
                    241: .    if empty(BUILTIN_PKG.${pkg})
                    242:        @${ECHO_N} " (version/variant unknown)"
                    243: .    else
                    244:        @${ECHO_N} " ${BUILTIN_PKG.${pkg}}"
                    245: .    endif
                    246: .  endif
                    247:        @${ECHO}
                    248: .endfor
                    249: .if !empty(BOOT_GHC_PKGSRC_DEPS)
                    250:        @${ECHO}
                    251:        @${ECHO} "Please note that it is generally not a good idea for a bootkit to depend"
                    252:        @${ECHO} "on pkgsrc packages, as pkgsrc tends to move faster than operating systems"
                    253:        @${ECHO} "so your bootkit may bitrot more quickly. You may want to rebuild it"
                    254:        @${ECHO} "without setting PREFER_PKGSRC to \"yes\"."
                    255: .endif
                    256:        @${ECHO} "=========================================================================="

CVSweb <webmaster@jp.NetBSD.org>