# # spec file for package cross-avr-gcc # # Copyright (c) 2010 SUSE LINUX Products GmbH, Nuernberg, Germany. # This file and all modifications and additions to the pristine # package are under the same license as the package itself. # # Please submit bugfixes or comments via http://bugs.opensuse.org/ # # rpm build documentation: # http://en.opensuse.org/Portal:Packaging # RPM Guide (search for rpm guide) # http://docs.fedoraproject.org/en-US/Fedora_Draft_Documentation/0.1/html/RPM_Guide/ # # cross gcc installation instructions: # http://gcc.gnu.org/install/ # http://gcc.gnu.org/install/configure.html # http://gcc.gnu.org/install/build.html # # Some more specifics to avr-gcc: # http://lists.nongnu.org/archive/html/avr-gcc-list/2011-11/msg00006.html # http://lists.nongnu.org/archive/html/avr-gcc-list/2011-11/msg00007.html # # Also try uninstalling all other avr compilers first. # # Build scripts from wrightflyer: # http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&t=42631 # # Note prefix=/usr: # An rpm is compiled, but the compiler doesn't find its as or ld (can be fixed # by symlinking to the correct ones from /usr/lib64/gcc/avr/4.6.2/), and the # linker doesn't find e.g. crtm328p.o. There probably is a fix, but I don't know # it. # Of course putting binutils and gcc into the same root will handle it. # Please don't remove the respective code from spec file, it's been tested, and # eventually one doesn't have to start from zero. # # Note gcc 4.7 snapshots: # The version used for gcc internal files is 4.7.0: # lib/gcc/avr/4.7.0/ # That means it is not possible to install 2 different snapshots with the # same prefix, or any snapshot with the final 4.7.0. # # PPL / CLooG: # http://gcc.gnu.org/wiki/Graphite # # norootforbuild ### spec file configuration ### # Build Comments for this build: # prefix = /opt/cross/avr # No supplied gmp / mpc / mpfr (use system ones). # clean PATH # No -m32 or -m64 in CFLAGS! # CFLAGS strictly only for configure, but not for make. # With system ppl and cloog libraries. # gcc 4.7 testing snapshort; no program suffix. %define vers 4.3.6 %define prefix /opt/cross/avr #define prefix /usr %define sysroot /opt/cross/avr %define pgprefix avr- %define pgsuffix -436 # Use the gmp / mpc / mpfr sources in this package (otherwise, expect the -devel # packages with headers and libXX.a to be installed). %define with_own_gmp_mpc_mpfr 0 # Use system ppl, cloog libraries. %define sys_ppl_cloog 1 # gcc build directory, to build outside its source directory. # http://gcc.gnu.org/install/configure.html # Says to always build outside the source dir, everything else is either # not well tested or unsupported. # This gccbuilddir is parallel to the gcc source tree dir, in RPM_BUILD_DIR. %define gccbuilddir build-gcc-%{vers} ### ### end spec file configuration # The rpm version can't have hyphens. %define rpmvers %(echo %{vers} | tr - .) # This is used to simplify tests. True if prefix is /usr %define prefix_is_usr %(test %{prefix} = %{_usr} && echo 1 || echo 0) # Make system macros pick up on new prefix. %define _prefix %prefix # Directory gcc uses to store its libgcc, cc1, etc. # Equal to %{vers} if X.Y.Z, or to X.Y.0 if %{vers} = X.Y-99999 %define cclibvers %(echo %{vers} | sed 's/-[0-9]*/.0/') Name: avr-gcc%{pgsuffix} Version: %{rpmvers} Release: 8 Summary: The GNU C/C++ Compiler for Atmel AVR with xmega support BuildRequires: chrpath BuildRequires: texinfo libexpat-devel expat BuildRequires: bison flex BuildRequires: cross-avr-binutils BuildRequires: avr-libc %if ! %with_own_gmp_mpc_mpfr BuildRequires: gmp-devel >= 4.2 mpc-devel >= 0.8.0 mpfr-devel >= 2.3.1 %endif %if %{sys_ppl_cloog} BuildRequires: ppl-devel >= 0.11 cloog-devel >= 0.15 %endif # For any updates see # http://wiki.opensuse.org/openSUSE:Packaging_Conventions_RPM_Macros BuildRequires: fdupes Requires: avr-libc Requires: cross-avr-binutils PreReq: %install_info_prereq # .osc/_buildconfig_* contains this nonsense: # ## from CrossToolchain:avr # Substitute: cross-avr-gcc cross-avr-gcc43 # # this causes /usr/bin/build to edit changes into the spec file. # -> we compensate by providing this symbol Provides: avr-gcc47 = %{version} Source0: http://ftp.gwdg.de/pub/misc/gcc/snapshots/LATEST-4.7/gcc-%{vers}.tar.bz2 %if %with_own_gmp_mpc_mpfr # Libraries used for building gcc (required, either as source, or installed # with headers and libXXX.a): Source1: gmp-5.0.1.tar.bz2 Source2: mpc-0.8.2.tar.bz2 Source3: mpfr-3.0.0.tar.bz2 %endif # Historic shell scripts for building previous versions: Source10: buildavr-no-insight.sh Source11: getfiles.sh Source12: get-patches.sh ## gcc-patch-cross-cflags-upstream25672.diff is suse specific, not present in wrightflyer builds #Patch11: gcc-patch-cross-cflags-upstream25672.diff URL: http://gcc.gnu.org/ Group: Development/Libraries/C and C++ License: GPLv3+ AutoReqProv: on BuildRoot: %{_tmppath}/%{name}-%{vers}-build %description This compiler supports the C and C++ languages on AVR microprocessors. Also install cross-avr-binutils and avr-libc. gcc built for Atmel AVR. Default-build as per GNU. This package can be installed in parallel with another avr-gcc already installed. %prep %setup -q -n gcc-%{vers} %if %with_own_gmp_mpc_mpfr %setup -q -n gcc-%{vers} -D -T -a 1 %setup -q -n gcc-%{vers} -D -T -a 2 %setup -q -n gcc-%{vers} -D -T -a 3 %endif # Delete gcc build dir first, it may be left over from previous build. cd "$RPM_BUILD_DIR" test -d "%{gccbuilddir}" && %__rm -rf "%{gccbuilddir}" %build # Copy the build scripts previously used (and pack them later as doc). %__chmod 644 %SOURCE10 %SOURCE11 %SOURCE12 %__cp -p %SOURCE10 %SOURCE11 %SOURCE12 . # The critical part is that some versions of gcc need the sources of these # libraries available, and others don't. The compiled libraries and headers are # always required to be on the system (if not, the sources are definitely # required and the build will compile them first). # See # http://lists.nongnu.org/archive/html/avr-gcc-list/2011-10/msg00073.html # If these library sources are not in the gcc source directory, building # happens with the 3-stage process for non-cross compilers which later fails, # and which takes 1:05h instead of 0:15h. (gcc 4.6.2) %if %with_own_gmp_mpc_mpfr %__mv gmp-5.0.1 gmp %__mv mpc-0.8.2 mpc %__mv mpfr-3.0.0 mpfr %endif # Setting CFLAGS is required for configure, but fatal for make! #export CFLAGS="$RPM_OPT_FLAGS" #export target=avr # Create and enter build dir. cd "$RPM_BUILD_DIR" %__mkdir "%{gccbuilddir}" cd "%{gccbuilddir}" # This makes no difference (all those directories are in the default system # shared library path already). (gcc 4.6.2) #export LD_LIBRARY_PATH="%{prefix}/lib:/usr/lib64:$LD_LIBRARY_PATH" #export LD_RUN_PATH="%{prefix}/lib:/usr/lib64:$LD_RUN_PATH" # Make sure nothing extra is in here. # See # http://lists.nongnu.org/archive/html/avr-gcc-list/2011-11/msg00006.html unset LD_LIBRARY_PATH export LD_LIBRARY_PATH # Clean up PATH PATH=/sbin:/usr/sbin:/usr/local/sbin:/bin:/usr/bin:/usr/local/bin %if %{prefix_is_usr} # Find the AVR assembler. PATH=$PATH:%{sysroot}/bin %endif export PATH # These flags work for 4.6.2: # -O2 -g -fmessage-length=0 -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables # Using -m64 for configure (and not for make) causes the target libgcc to be # built for x86_64-unknown-linux-gnu - not useful. (gcc 4.6.2) # Using -m32 is also fatal for getting a working cross gcc. (on x86_64 host, gcc # 4.6.2) # Remove -m* from RPM_OPT_FLAGS for use in CFLAGS. AVR_CFLAGS= for opt in $RPM_OPT_FLAGS; do case $opt in -m*) ;; # discard *) AVR_CFLAGS="$AVR_CFLAGS $opt" ;; esac done echo "RPM_OPT_FLAGS: $RPM_OPT_FLAGS" echo "Removing flags: -m*" echo "Using flags: $AVR_CFLAGS" # gcc (4.6.2) installs cc1, cc1plus into libexecdir, which is /usr/lib on # openSUSE, leading to the crazy concept of host-size-independent libgcc # being installed into /usr/lib64 while all the x86_64-dependent binaries are # installed in /usr/lib. # --> configure with libexecdir = libdir echo "($0) configuring GCC source" CFLAGS="$AVR_CFLAGS" \ ../gcc-%{vers}/configure \ -v \ --prefix=%{prefix} \ --exec-prefix=%{_exec_prefix} \ --libdir=%{_libdir} \ --libexecdir=%{_libdir} \ --mandir=%{_mandir} \ --infodir=%{_infodir} \ --with-gnu-ld \ --with-gnu-as \ --target=avr \ --enable-languages="c,c++" \ --program-prefix=%{pgprefix} \ %if %(test -n "%{pgsuffix}" && echo 1 || echo 0) --program-suffix=%{pgsuffix} \ %endif --with-sys-root=%{sysroot} \ --disable-nls \ --disable-libssp \ --with-dwarf2 \ %if %{sys_ppl_cloog} --with-ppl \ --with-cloog \ %else --without-ppl \ --without-cloog \ %endif # This doesn't make gcc find its system headers (avr-libc headers) in # /opt/cross/avr/avr/include, and causes this gcc to call its assembler as # /usr/bin/as - which is the x86 one. # --with-sys-root= unfortunately doesn't seem to make gcc look in # sys-root/include for the avr-libc headers. #%if %{prefix_is_usr} # --with-gxx-include-dir=%{sysroot}/include \ #%endif echo "($0) compiling GCC source" # Parallel make with jobs=6 works, dropping compile time >50% (6 core Phenom). %{__make} %{?jobs:-j%{jobs}} %install cd ../%{gccbuilddir} %__make install DESTDIR=$RPM_BUILD_ROOT %__gzip -f $RPM_BUILD_ROOT%{prefix}/share/man/man*/*.* %fdupes -s $RPM_BUILD_ROOT%{prefix}/ # man pages in section 1 are already named prefix-XX-suffix. # Rename man pages in section 7. pushd $RPM_BUILD_ROOT%{_mandir}/man7 for f in *.7.gz; do %__mv $f %{pgprefix}$(basename $f .7.gz)%{pgsuffix}.7.gz done popd # Modify and rename info files. # The file name in the info file has to be the same as the actual file name, or # the info index is not updated properly. pushd $RPM_BUILD_ROOT%{_infodir} for file in *info*; do ## Modify file name in info file. name=$(basename $file .info) # base name (no .info) to change in info file pref=%{pgprefix} # name prefix to add in info file suff=%{pgsuffix} # name suffix to add in info file sed < "$file" > "$file.new" " s,/$name.info,/$pref$name$suff.info, s,\* $name: ($name)\.,* $pref$name$suff: ($pref$name$suff).,i s,\* cpplib: ($name)\.,* $pref$name$suff: ($pref$name$suff).,i s/File: $name.info/File: $pref$name$suff.info/ " \ && cat "$file.new" > "$file" \ && rm "$file.new" ## Rename info file. %__mv $file %{pgprefix}$(basename $file .info)%{pgsuffix}.info done popd # Compress info files (but not the dir file). %__gzip $RPM_BUILD_ROOT%{_infodir}/*.info # Strip binaries. for file in $RPM_BUILD_ROOT%{_bindir}/*; do test -f $file && %__strip $file || true done for file in cc1 cc1plus collect2 lto1 install-tools/fixincl; do dir=$RPM_BUILD_ROOT%{_libdir}/gcc/avr/%{cclibvers} test -f $dir/$file && %__strip $dir/$file || true done # Symlink as and ld from binutils for this particular gcc, if prefix = /usr. # Without this, this gcc runs the system's as/ld. %if %prefix_is_usr for file in as ld; do %__ln_s %{sysroot}/avr/bin/$file $RPM_BUILD_ROOT%{_libdir}/gcc/avr/%{vers} done %endif # Symlinks to prefix in /usr, if prefix is not /usr. %if ! %prefix_is_usr pushd . # Symlinks from /usr/bin to %prefix/bin. %__install -d $RPM_BUILD_ROOT%{_usr}/bin for f in c++ cpp g++ gcc gcov do %__ln_s %{prefix}/bin/%{pgprefix}$f%{pgsuffix} $RPM_BUILD_ROOT%{_usr}/bin done %__ln_s %{prefix}/bin/%{pgprefix}gcc-%{cclibvers} $RPM_BUILD_ROOT%{_usr}/bin # Symlinks from /usr/share/man/man1 to prefix/share/man/man1. %__install -d $RPM_BUILD_ROOT%{_usr}/share/man/man1 for f in cpp g++ gcc gcov do %__ln_s %{prefix}/share/man/man1/%{pgprefix}$f%{pgsuffix}.1.gz \ $RPM_BUILD_ROOT%{_usr}/share/man/man1 done # Symlinks from /usr/share/man/man7 to prefix/share/man/man7. %__install -d $RPM_BUILD_ROOT%{_usr}/share/man/man7 cd $RPM_BUILD_ROOT%{prefix}/share/man/man7 for f in *; do %__ln_s %{prefix}/share/man/man7/$f $RPM_BUILD_ROOT%{_usr}/share/man/man7 done # Symlinks from /usr/share/info to prefix/share/info. %__install -d $RPM_BUILD_ROOT%{_usr}/share/info cd $RPM_BUILD_ROOT%{prefix}/share/info for f in *; do test $f = dir && continue %__ln_s %{prefix}/share/info/$f $RPM_BUILD_ROOT%{_usr}/share/info done popd %endif # Install symlinks to binaries into a versioned directory, without the program # suffix, so this compiler version can be run by avr-gcc by putting the # versioned directory first in path. # Needed for Arduino IDE. %__install -d $RPM_BUILD_ROOT%{_libdir}/gcc/avr/%{cclibvers}/bin pushd $RPM_BUILD_ROOT%{_libdir}/gcc/avr/%{cclibvers}/bin %__ln_s ../../../../../bin for file in ../../../../../bin/*; do case "$file" in *%{vers}) continue; esac if [ -f "$file" ]; then %__ln_s "$file" "$(basename "$file" %{pgsuffix})" fi done # binutils for file in ar as ld nm objcopy objdump ranlib strip; do %__ln_s %{sysroot}/bin/avr-$file . done popd %post # Update info file index. (The SUSE macros don't work properly.) if [ -n "%{pgprefix}%{pgsuffix}" -a -x /sbin/install-info ]; then for file in %_infodir/%{pgprefix}*%{pgsuffix}*.info.gz do /sbin/install-info --quiet --info-dir=%_infodir "$file" done %if ! %prefix_is_usr %define infdir %{_usr}/share/info for file in %infdir/%{pgprefix}*%{pgsuffix}*.info.gz do /sbin/install-info --quiet --info-dir=%infdir "$file" done %endif fi %preun # Update info file index. if [ -n "%{pgprefix}%{pgsuffix}" -a -x /sbin/install-info ]; then for file in %_infodir/%{pgprefix}*%{pgsuffix}*.info.gz do /sbin/install-info --quiet --delete --info-dir=%_infodir "$file" done %if ! %prefix_is_usr %define infdir %{_usr}/share/info for file in %infdir/%{pgprefix}*%{pgsuffix}*.info.gz do /sbin/install-info --quiet --delete --info-dir=%infdir "$file" done %endif fi %clean %if ! %{dont_clean_build_root} %__rm -rf "$RPM_BUILD_ROOT" cd "$RPM_BUILD_DIR" test -d "%{gccbuilddir}" && %__rm -rf "%{gccbuilddir}" %endif %files %defattr (-, root, root) %doc ChangeLog* COPYING* LAST_UPDATED README %if %(test -f NEWS && echo 1 || echo 0) %doc NEWS %endif %doc getfiles.sh get-patches.sh buildavr-no-insight.sh ## prefix = /opt/cross/avr %if ! %prefix_is_usr %doc %{_infodir}/* %doc %{_mandir}/man*/* %{_bindir}/* %{_libdir}/gcc/avr/%{cclibvers} %exclude %{_libdir}/libiberty.a # In /usr: %doc %{_usr}/share/man/man*/* %doc %{_usr}/share/info/* %{_usr}/ ## prefix = /usr %else #/usr/avr # directories are created, but are empty # libiberty.a is part of binutils on the host system, and part of avr-insight # in /opt/cross/avr, so don't package it here with avr-gcc. %doc %{_infodir}/* %doc %{_mandir}/man*/* %{_bindir}/* %exclude %{_libdir}/libiberty.a %{_libdir}/gcc/avr/%{cclibvers} %endif %exclude %{_infodir}/dir %changelog * Mon Nov 07 2011 Volker Kuhlmann - Adapted to also handle gcc 4.7 snapshots. - Make gcc 4.3.6 packages too. * Sun Nov 06 2011 Volker Kuhlmann - Finished upgrade to 4.6.2. - General upgrade of spec file. - Allow installation in parallel with other avr-gcc. * Tue Oct 18 2011 max@suse.com - Fix libmpfr dependency. * Thu Aug 5 2010 mhopf@novell.com - Use 4.3.3_20100125 as version number again, had been accidentally nuked directly after the change. * Thu Aug 5 2010 jw@novell.com - using versioned Provides, as suggested by *.note Strange: the version number is back at 4.3.3, Matthias, is your work reverted now? * Mon Jul 19 2010 jw@novell.com - fixed usage of %%fdupes. * Tue Mar 23 2010 mhopf@novell.com - Use 4.3.3_20100125 as version number so that it is larger than 4.3.3_20081022 from cross-avr-gcc43 in openSUSE 11.1 * Tue Mar 23 2010 mhopf@novell.com - Add mpfr-devel to build requires. * Tue Mar 23 2010 mhopf@novell.com - Use gmp-devel = 4.3.1 -gmp as build requires (gmp is installed automatically, we use libgmp3) - gcc-patch-cross-cflags-upstream25672.diff: Fix long-standing bug in gcc in setting cross-compile CFLAGS correctly. * Sun Mar 7 2010 jw@novell.com - provide cross-avr-gcc43, as the symbol cross-avr-gcc is automagically changed. * Sun Mar 7 2010 jw@novell.com - no /opt/cross/share/dir file here, it conflicts with our binutils * Sat Mar 6 2010 jw@suse.de - More rumgefummel at the spec-file: bringing symlinks to /usr/bin/ gzipped man pages to standard locations, while still keeping the installation at /opt/cross/avr * Thu Mar 4 2010 jw@novell.com - Release: 25jan2010 - using build instructions from http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&t=42631