# commented gcc package Makefile # # feedback welcome * Mandatory: expanded CVS Id $NetBSD$ # $NetBSD: Makefile,v 1.76 2004/03/25 23:34:01 jlam Exp $ * Distname section (Mandatory) ================ * Mandatory: basename of the distribution file to be downloaded DISTNAME= gcc-2.95.3 * Optionnal: when a new revision of the package is done, declare this variable and increment it until a new release of the software is done PKGREVISION= 5 * Mandatory: categories into which the package falls CATEGORIES= lang * Mandatory: location from which the software can be downloaded, here we use a defined master site, see Packages.txt for complete defined master sites list MASTER_SITES= ${MASTER_SITE_GNU:=gcc/} * Patch section (Optional) ============= * Optional: NetBSD preferred master site PATCH_SITES= ${MASTER_SITE_LOCAL} * Mandatory: patches that have to be applyed PATCHFILES= gcc-2.95.3-diff-2002-08-29.gz * Mainainer section (Mandatory) ================= * Mandatory: package maintainer, either real package's creator or tech-pkg@NetBSD.org MAINTAINER= tech-pkg@NetBSD.org * Optional: if project has a homepage, add this variable HOMEPAGE= http://www.gnu.org/software/gcc/gcc.html * Mandatory: short package description COMMENT= GNU Compiler Collection, version 2 * Package itself (Mandatory) ============== * Optional: specify which platforms package can't be built / installed on, see also ONLY_FOR_PLATFORM NOT_FOR_PLATFORM= Darwin-*-* *-*-x86_64 * Recommended: use buildlink3 framework, see section Packate.txt section 8. "buildlink3" is a pkgsrc framework that controls what headers and libraries are seen by a package's configure and build processes. USE_BUILDLINK3= YES * Optional: setting USE_PKGINSTALL to "YES" to do some special operations when installing / deinstalling a package, i.e. adding / deleting users. USE_PKGINSTALL= YES * Optional: set MAKE_PROGRAM to "gmake" and add a dependency on it. USE_GNU_TOOLS+= make * Optional: additional make flags MAKEFLAGS+= GMAKE_LOCALE=no * Recommended: program's distfile contains its own configure script, so we set HAS_CONFIGURE, if it had a GNU autoconf script, we would have used GNU_CONFIGURE instead. HAS_CONFIGURE= YES * Optional: configure script location CONFIGURE_SCRIPT= ${WRKSRC}/configure * Optional: additional configure arguments CONFIGURE_ARGS= --host=${MACHINE_GNU_PLATFORM} CONFIGURE_ARGS+= --prefix=${GCC_PREFIX} CONFIGURE_ARGS+= --enable-shared * Optional: usually those two are set to ${WRKSRC} by mk/bsd.pkg.mk CONFIGURE_DIRS= ${WRKDIR}/objdir BUILD_DIRS= ${CONFIGURE_DIRS} * Optional: substitute references to DISTNAME with ${DISTNAME} and GCC_PREFIX with ${GCC_PREFIX} on files/* FILES_SUBST+= DISTNAME=${DISTNAME} GCC_PREFIX=${GCC_PREFIX} * Optional: substitute references to DISTNAME with ${DISTNAME} on the MESSAGE file MESSAGE_SUBST+= DISTNAME=${DISTNAME} * Optional: substitute references to DISTNAME with ${DISTNAME} on the PLIST file PLIST_SUBST+= DISTNAME=${DISTNAME} * Optional: there's info files to install from this package, we want this directory to be the target installation directory for info files provided by this package. Target directory is defined with a make(1) string substitution system, like we'd have done with sed(1), ${PREFIX} is stripped from beginning of ${GCC_PREFIX}. INFO_DIR= ${GCC_PREFIX:S|^${PREFIX}/||}/info * Optional: info files list INFO_FILES= chill.info cpp.info g77.info gcc.info * Optional: but mandatory if you have to deal with arch-specific rules, include bsd.prefs.mk so variables like ${OPSYS}, containing the host OS, are set, are set. See mk/bsd.prefs.mk for further details. .include "../../mk/bsd.prefs.mk" * Optional: use make(1) conditionals with predefined variables .if ${OPSYS} == "SunOS" * Optional: this variable contains packages list that may conflict with our package CONFLICTS+= gcc-[0-9]* pgcc-[0-9]* * Optional: another make(1) variable manipulation system, M select only those words that match the rest of the modifier. The rest of the conditional is quite self-explanatory . if ${CC:M*gcc*} == "" ALL_TARGET= bootstrap . endif # we know it's a GNU toolchain on Linux and the BSDs. .elif ${OPSYS:M*BSD} != "" || ${OPSYS} == "Linux" CONFIGURE_ARGS+= --with-gnu-as CONFIGURE_ARGS+= --with-gnu-ld .else # play it safe, force a bootstrap build if we don't know for sure it # is gcc. . if ${CC:M*gcc*} == "" ALL_TARGET= bootstrap . endif .endif * Optional: fill some variables needed by the software GCC_PREFIX= ${PREFIX}/${DISTNAME} * Optional: the :C modifier is just like the :S modifier except that the old and new strings, instead of being simple strings, are a regular expression (see regex(3)) string pattern and an ed(1)-style string replacement. GCC_VERSION= ${PKGVERSION:C|nb.*||} * Optional: here, ${MACHINE_GNU_PLATFORM} is replaced with value set in bsd.prefs.mk, ${LOWER_ARCH}-${LOWER_VENDOR}-${LOWER_OPSYS}${APPEND_ELF}${LOWER_OPSYS_VERSUFFIX} GCC_ARCHDIR= ${GCC_PREFIX}/lib/gcc-lib/${MACHINE_GNU_PLATFORM}/${GCC_VERSION} * Optional: To use one or more files as source for the PLIST used in generating the binary package, set the variable PLIST_SRC to the names of that file(s). PLIST_SRC= ${WRKDIR}/PLIST_DYNAMIC * Optional: package's Makefile let you associate complex actions to pre / post target building. On the following, after extracting ${DISTFILES}, we will copy and remove some files. Please note shell tools are not called directly but with their mk/defs.${OPSYS}.mk definitions. post-extract: * Optional: just operate like you'd do on a shell script ${MKDIR} ${WRKSRC} ${CP} ${FILESDIR}/xm-netbsd.h ${WRKSRC}/gcc/config ${CP} ${FILESDIR}/xm-target64.h ${WRKSRC}/gcc/config for file in ${FILESDIR}/*_* ; do \ arch=`${BASENAME} $${file} | ${SED} -e "s/_.*//"`; \ dest=`${BASENAME} $${file} | ${SED} -e "s/$${arch}_//"`; \ ${MKDIR} ${WRKSRC}/gcc/config/$${arch}; \ ${CP} $${file} ${WRKSRC}/gcc/config/$${arch}/$${dest}; \ done ${RM} ${WRKSRC}/gcc/config/alpha/netbsd-elf.h ${RM} ${WRKSRC}/gcc/config/arm/t-netbsd ${RM} ${WRKSRC}/gcc/config/mips/x-netbsd ${RM} ${WRKSRC}/libf2c/libF77/dtime_.c ${RM} ${WRKSRC}/libf2c/libF77/etime_.c * Optional: here, we need to execute contrib/egcs_update --touch before the configure script is launched. pre-configure: ${MKDIR} ${BUILD_DIRS} cd ${WRKSRC} && contrib/egcs_update --touch * Optional: and finally, we make some post build substitutions post-build: @${SED} ${FILES_SUBST_SED} ${FILESDIR}/gcc.mk > ${WRKDIR}/gcc.mk .if ${OPSYS} == "SunOS" # # remove empty file and directories that show up when one does: # make install; make deinstall; make install # post-install: -cd ${GCC_ARCHDIR}/include && ${RM} -f fixed && ${RMDIR} v7 v9 .else post-install: . if exists(/usr/include/g++/FlexLexer.h) ${LN} -fs /usr/include/g++/FlexLexer.h \ ${GCC_PREFIX}/include/g++-3/FlexLexer.h . endif ${RM} -f ${GCC_ARCHDIR}/include/curses.h ${GCC_PREFIX}/bin/cc .endif ${INSTALL_DATA_DIR} ${PREFIX}/share/examples/${DISTNAME} ${INSTALL_DATA} ${WRKDIR}/gcc.mk ${PREFIX}/share/examples/${DISTNAME}/mk.conf ${LN} -s gcc ${GCC_PREFIX}/bin/cc ${CP} -f ${PKGDIR}/PLIST ${PLIST_SRC} ${FIND} ${GCC_PREFIX} \( -type f -o -type l \) -print \ | ${SORT} | ${SED} -e "s,${PREFIX}/,,g" \ >> ${PLIST_SRC} ${FIND} ${GCC_PREFIX} -type d -print \ | ${SORT} -r | ${SED} -e "s,${PREFIX}/,@dirrm ,g" \ >> ${PLIST_SRC} * Mandatory: finally, include mk/bsd.pkg.mk that contains all the magic behind the scenes that you need to build and install a package. .include "../../mk/bsd.pkg.mk" Optional: cc / gcc related # Make bootstrap with compiler != gcc possible. LDFLAGS= ${_STRIPFLAG_CC}