From bfbb55ed6430f6b4d9bb49d4f2592ef9a5713e75 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Mon, 29 Dec 2014 03:08:09 -0500 Subject: refactor (again): new download script, separate architectures, modules --- Makefile.d/.gitignore | 1 + Makefile.d/addseabios.mk | 18 ++ Makefile.d/build-release.mk | 53 ++++ Makefile.d/build.mk | 17 ++ Makefile.d/buildrom-withgrub.mk | 38 +++ Makefile.d/downloader | 498 +++++++++++++++++++++++++++++++++++++ Makefile.d/grub-mkstandalone.mk | 31 +++ Makefile.d/modules.mk | 44 ++++ Makefile.d/modules/bucts.mk | 1 + Makefile.d/modules/coreboot.mk | 61 +++++ Makefile.d/modules/dejavu.mk | 5 + Makefile.d/modules/flashrom.mk | 20 ++ Makefile.d/modules/grub.mk | 8 + Makefile.d/modules/grubinvaders.mk | 16 ++ Makefile.d/modules/i945pwm.mk | 3 + Makefile.d/modules/memtest86.mk | 7 + Makefile.d/modules/powertop.mk | 1 + Makefile.d/modules/seabios.mk | 8 + 18 files changed, 830 insertions(+) create mode 100644 Makefile.d/.gitignore create mode 100644 Makefile.d/addseabios.mk create mode 100644 Makefile.d/build-release.mk create mode 100644 Makefile.d/build.mk create mode 100644 Makefile.d/buildrom-withgrub.mk create mode 100755 Makefile.d/downloader create mode 100644 Makefile.d/grub-mkstandalone.mk create mode 100644 Makefile.d/modules.mk create mode 100644 Makefile.d/modules/bucts.mk create mode 100644 Makefile.d/modules/coreboot.mk create mode 100644 Makefile.d/modules/dejavu.mk create mode 100644 Makefile.d/modules/flashrom.mk create mode 100644 Makefile.d/modules/grub.mk create mode 100644 Makefile.d/modules/grubinvaders.mk create mode 100644 Makefile.d/modules/i945pwm.mk create mode 100644 Makefile.d/modules/memtest86.mk create mode 100644 Makefile.d/modules/powertop.mk create mode 100644 Makefile.d/modules/seabios.mk (limited to 'Makefile.d') diff --git a/Makefile.d/.gitignore b/Makefile.d/.gitignore new file mode 100644 index 0000000..7b1b05b --- /dev/null +++ b/Makefile.d/.gitignore @@ -0,0 +1 @@ +*-list.mk diff --git a/Makefile.d/addseabios.mk b/Makefile.d/addseabios.mk new file mode 100644 index 0000000..50c4af6 --- /dev/null +++ b/Makefile.d/addseabios.mk @@ -0,0 +1,18 @@ +roms/%_with_seabios.rom: roms/%.rom \ + src/$(host_arch)/seabios/out/vgabios.bin \ + src/$(host_arch)/seabios/out/bios.bin.elf \ + resources/grub/config/seabios.cfg \ + $(CBFSTOOL) + cp $< $@.tmp + $(CBFSTOOL) $@.tmp add -f src/$(host_arch)/seabios/out/vgabios.bin -n vgaroms/vgabios.bin -t raw + $(CBFSTOOL) $@.tmp add -f src/$(host_arch)/seabios/out/bios.bin.elf -n bios.bin.elf -t raw + $(CBFSTOOL) $@.tmp extract -n grub.cfg -f $@.tmp.grub.cfg + $(CBFSTOOL) $@.tmp extract -n grubtest.cfg -f $@.tmp.grubtest.cfg + $(CBFSTOOL) $@.tmp remove -n grub.cfg + $(CBFSTOOL) $@.tmp remove -n grubtest.cfg + cat resources/grub/config/seabios.cfg >> $@.tmp.grub.cfg + cat resources/grub/config/seabios.cfg >> $@.tmp.grubtest.cfg + $(CBFSTOOL) $@.tmp add -f $@.tmp.grub.cfg -n grub.cfg -t raw + $(CBFSTOOL) $@.tmp add -f $@.tmp.grubtest.cfg -n grubtest.cfg -t raw + rm -f $@.tmp.grub.cfg $@.tmp.grubtest.cfg + mv $@.tmp $@ diff --git a/Makefile.d/build-release.mk b/Makefile.d/build-release.mk new file mode 100644 index 0000000..09c0808 --- /dev/null +++ b/Makefile.d/build-release.mk @@ -0,0 +1,53 @@ + +dist_utils = \ + bucts \ + flashrom_normal \ + flashrom_lenovobios_macronix \ + flashrom_lenovobios_sst \ + cbfstool \ + nvramtool +dist_files = \ + $(MAKEFILE_LIST) \ + configure configure.ac \ + tmp/.gitignore \ + powertop.trisquel6 \ + powertop.trisquel6.init \ + powertop.trisquel7 \ + powertop.trisquel7.init \ + deps-trisquel \ + flash_lenovobios_stage1 \ + flash_lenovobios_stage2 \ + flash_libreboot6 \ + flash_macbook21applebios \ + flash_x60_libreboot5 +dist_dirs = docs bin resources + +distdir: PHONY \ + libreboot-$(VERSION)/version.txt \ + $(addprefix libreboot-$(VERSION)/utils/$(arch)/,$(dist_utils)) \ + $(addprefix libreboot-$(VERSION)/,$(dist_files) $(dist_dirs)) + +libreboot-$(VERSION)/utils/$(arch)/bucts: src/bucts/bucts + mkdir -p $(@D) + cp $< $@ +libreboot-$(VERSION)/utils/$(arch)/flashrom_%: src/flashrom/flashrom_% + mkdir -p $(@D) + cp $< $@ +libreboot-$(VERSION)/utils/$(arch)/cbfstool: src/coreboot/util/cbfstool/cbfstool + mkdir -p $(@D) + cp $< $@ +libreboot-$(VERSION)/utils/$(arch)/nvramtool: src/coreboot/util/nvramtool/nvramtool + mkdir -p $(@D) + cp $< $@ +$(addprefix libreboot-$(VERSION)/,$(dist_files)): \ +libreboot-$(VERSION)/%: % + mkdir -p $(@D) + cp $< $@ +$(addprefix libreboot-$(VERSION)/,$(dist_dirs)): \ +libreboot-$(VERSION)/%: % + mkdir -p $(@D) + cp -r $< $@ + +libreboot-$(VERSION)/version.txt: PHONY + mkdir -p $(@D) + echo $(VERSION) > $@ diff --git a/Makefile.d/build.mk b/Makefile.d/build.mk new file mode 100644 index 0000000..478fdc5 --- /dev/null +++ b/Makefile.d/build.mk @@ -0,0 +1,17 @@ +define rule_grub_cfg +tmp/grub_%(keymap)_%(romtype).cfg: \ + resources/grub/config/extra/common.cfg resources/grub/config/menuentries/common.cfg \ + resources/grub/config/extra/%(romtype).cfg resources/grub/config/menuentries/%(romtype).cfg ; + echo 'keymap %(keymap)' | cat \ + resources/grub/config/extra/common.cfg \ + resources/grub/config/extra/%(romtype).cfg \ + - \ + resources/grub/config/menuentries/common.cfg \ + resources/grub/config/menuentries/%(romtype).cfg \ + > $@ +endef +$(eval $(call multiglob,grub_cfg,keymap romtype)) + +# % = $(keymap)_$(romtype) +tmp/grub_%_test.cfg: tmp/grub_%.cfg + sed 's/grubtest.cfg/grub.cfg/' < $< > $@ diff --git a/Makefile.d/buildrom-withgrub.mk b/Makefile.d/buildrom-withgrub.mk new file mode 100644 index 0000000..11b223e --- /dev/null +++ b/Makefile.d/buildrom-withgrub.mk @@ -0,0 +1,38 @@ +# % = $(board) +resources/libreboot/config/%_vesafb_config: resources/libreboot/config/%_txtmode_config + sed 's/# CONFIG_FRAMEBUFFER_KEEP_VESA_MODE is not set/CONFIG_FRAMEBUFFER_KEEP_VESA_MODE=y/' < $< > $@ + +# Unfortunately, this rule requires exclusive use of the src/coreboot directory +.NOTPARALLEL: +define rule_rom_nokeyboard +tmp/%(board)_nokeyboard_%(romtype).rom: tmp/builddeps-stamps/$(host_arch)/coreboot \ + tmp/grub_%(romtype).elf \ + resources/libreboot/config/%(board)_%(romtype)_config + rm -f src/$(host_arch)/coreboot/.config src/$(host_arch)/coreboot/grub.elf + $(MAKE) -C src/$(host_arch)/coreboot clean + ln resources/libreboot/config/%(board)_%(romtype)_config src/$(host_arch)/coreboot/.config + ln tmp/grub_%(romtype).elf src/$(host_arch)/coreboot/grub.elf + $(MAKE) -C src/$(host_arch)/coreboot + rm -f src/$(host_arch)/coreboot/.config src/$(host_arch)/coreboot/grub.elf + mv src/$(host_arch)/coreboot/build/coreboot.rom $@ +endef +$(eval $(call multiglob,rom_nokeyboard,board romtype)) + +define rule_rom +roms/%(board)_%(keymap)_%(romtype).rom: \ + tmp/%(board)_nokeyboard_%(romtype).rom \ + tmp/grub_%(keymap)_%(romtype).cfg \ + tmp/grub_%(keymap)_%(romtype)_test.cfg \ + $(firstword $(CBFSTOOL)) + cp $< $@.tmp + $(CBFSTOOL) $@.tmp add -f tmp/grub_%(keymap)_%(romtype).cfg -n grub.cfg -t raw + $(CBFSTOOL) $@.tmp add -f tmp/grub_%(keymap)_%(romtype)_test.cfg -n grubtest.cfg -t raw + $(if $(filter %(board),$(i945boards)),\ + # Needed on i945 systems for the bucts/dd trick (documented) + # This enables the ROM to be flashed over the lenovo bios firmware + dd if='$@.tmp' of='$@.tmp.top64k' bs=1 skip=$$[$$(stat -c %s '$@.tmp') - 0x10000] count=64k && \ + dd if='$@.tmp.top64k' of='$@.tmp' bs=1 seek=$$[$$(stat -c %s '$@.tmp') - 0x20000] count=64k conv=notrunc && \ + rm -f '$@.tmp.top64k') + mv $@.tmp $@ +endef +$(eval $(call multiglob,rom,board keymap romtype)) diff --git a/Makefile.d/downloader b/Makefile.d/downloader new file mode 100755 index 0000000..ffb2388 --- /dev/null +++ b/Makefile.d/downloader @@ -0,0 +1,498 @@ +#!/bin/bash +# Makefile.d/downloader: A downloader script that handles all kinds of +# funny VCS URLs. +# Very heavily based on Pacman's 'makepkg' script. + +# Usage: Makefile.d/downloader ARCH DEPNAME::URL [DEPNAME::URL...] + +# Copyright (c) 2014 Luke Shumaker +# Copyright (c) 2006-2013 Pacman Development Team +# Copyright (c) 2002-2006 by Judd Vinet +# Copyright (c) 2005 by Aurelien Foret +# Copyright (c) 2006 by Miklos Vajna +# Copyright (c) 2005 by Christian Hamar +# Copyright (c) 2006 by Alex Smith +# Copyright (c) 2006 by Andras Voroskoi +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +export TEXTDOMAIN='pacman-scripts' +export TEXTDOMAINDIR='/usr/share/locale' + +shopt -s extglob +set -u -e -E + +# check if messages are to be printed using color +declare ALL_OFF= BOLD= BLUE= GREEN= RED= YELLOW= +if [[ -t 2 ]]; then + # prefer terminal safe colored and bold text when tput is supported + if tput setaf 0 &>/dev/null; then + ALL_OFF="$(tput sgr0)" + BOLD="$(tput bold)" + BLUE="${BOLD}$(tput setaf 4)" + GREEN="${BOLD}$(tput setaf 2)" + RED="${BOLD}$(tput setaf 1)" + YELLOW="${BOLD}$(tput setaf 3)" + else + ALL_OFF="\e[1;0m" + BOLD="\e[1;1m" + BLUE="${BOLD}\e[1;34m" + GREEN="${BOLD}\e[1;32m" + RED="${BOLD}\e[1;31m" + YELLOW="${BOLD}\e[1;33m" + fi +fi +readonly ALL_OFF BOLD BLUE GREEN RED YELLOW + +### SUBROUTINES ### + +plain() { + local mesg=$1; shift + printf "${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2 +} + +msg() { + local mesg=$1; shift + printf "${GREEN}==>${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2 +} + +msg2() { + local mesg=$1; shift + printf "${BLUE} ->${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2 +} + +warning() { + local mesg=$1; shift + printf "${YELLOW}==> $(gettext "WARNING:")${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2 +} + +error() { + local mesg=$1; shift + printf "${RED}==> $(gettext "ERROR:")${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2 +} + +dir_is_empty() { + ( + shopt -s dotglob nullglob + files=("$1"/*) + (( ${#files} == 0 )) + ) +} + +# a "netfile" has the form: +# "depname::url" +get_url() { printf -- "%s\n" "${1#*::}"; } +get_depname() { printf -- "%s\n" "${1%%::*}"; } + +get_protocol() { + local url="$(get_url "$1")" + local proto="${url%%://*}" + proto=${proto%%+*} + printf -- "%s\n" "$proto" +} + +get_urlname() { + local netfile=$1 + local url="$(get_url "$netfile")" + local proto=$(get_protocol "$netfile") + urlname=${netfile%%#*} # Strip a fragment + urlname=${urlname%/} # Strip a trailing slash + urlname=${urlname##*/} # Strip leading components + urlname=${urlname%.$proto} # Strip .git + printf -- "%s\n" "${urlname}" +} + +get_downloadname() { + local netfile=$1 + local depname="$(get_depname "$netfile")" + local urlname="$(get_urlname "$netfile")" + local proto="$(get_protocol "$netfile")" + + local name + case $proto in + git|hg|svn) name="$depname.$proto";; + http|https) name="$urlname";; + *) return 1;; + esac + + printf -- "%s\n" "$name" +} + +#### + +get_downloadclient() { + local proto=$1 + + # loop through DOWNLOAD_AGENTS variable looking for protocol + local i + for i in "${DLAGENTS[@]}"; do + local handler="${i%%::*}" + if [[ $proto = "$handler" ]]; then + local agent="${i##*::}" + break + fi + done + + # if we didn't find an agent, return an error + if [[ -z $agent ]]; then + error "$(gettext "Unknown download protocol: %s")" "$proto" + plain "$(gettext "Aborting...")" + exit 1 # $E_CONFIG_ERROR + fi + + # ensure specified program is installed + local program="${agent%% *}" + if [[ ! -x $program ]]; then + local baseprog="${program##*/}" + error "$(gettext "The download program %s is not installed.")" "$baseprog" + plain "$(gettext "Aborting...")" + exit 1 # $E_MISSING_PROGRAM + fi + + printf "%s\n" "$agent" +} + +download_file() { + local netfile=$1 + local filename="$(get_downloadname "$netfile")" + + pushd "$SRCDEST" &>/dev/null + + if [[ -f "$filename" ]]; then + msg2 "$(gettext "Found %s")" "${filename}" + return + fi + + local proto=$(get_protocol "$netfile") + + # find the client we should use for this URL + local dlcmd + dlcmd=$(get_downloadclient "$proto") || exit $? + + local url=$(get_url "$netfile") + + msg2 "$(gettext "Downloading %s...")" "$filename" + + # temporary download file, default to last component of the URL + local dlfile=$filename + + # replace %o by the temporary dlfile if it exists + if [[ $dlcmd = *%o* ]]; then + dlcmd=${dlcmd//\%o/\"$filename.part\"} + dlfile="$filename.part" + fi + # add the URL, either in place of %u or at the end + if [[ $dlcmd = *%u* ]]; then + dlcmd=${dlcmd//\%u/\"$url\"} + else + dlcmd="$dlcmd \"$url\"" + fi + + local ret=0 + eval "$dlcmd || ret=\$?" + if (( ret )); then + [[ ! -s $dlfile ]] && rm -f -- "$dlfile" + error "$(gettext "Failure while downloading %s")" "$filename" + plain "$(gettext "Aborting...")" + exit 1 + fi + + # rename the temporary download file to the final destination + if [[ $dlfile != "$filename" ]]; then + mv -f "$dlfile" "$filename" + fi +} + +extract_file() { + local netfile=$1 + local depname="$(get_depname "$netfile")" + local filename="$(get_downloadname "$netfile")" + local filepath="$SRCDEST/$filename" + local filetype=$(file -bizL "$filepath") # fix Arch flyspray #6246 + local ext=${filename##*.} + local cmd=bsdtar + + local ret=0 + msg2 "$(gettext "Extracting %s with %s")" "$filename" "$cmd" + rm -rf "$srcdir/$depname" + mkdir "$srcdir/$depname" && $cmd -xf "$filepath" -C "$srcdir/$depname" --strip-components 1 || ret=$? + if (( ret )); then + error "$(gettext "Failed to extract %s")" "$file" + plain "$(gettext "Aborting...")" + exit 1 + fi +} + +download_git() { + local netfile=$1 + + local repo="$(get_downloadname "$netfile")" + local dir="$SRCDEST/$repo" + + local url="$(get_url "$netfile")" + url=${url##git+} + url=${url%%#*} + + if [[ ! -d "$dir" ]] || dir_is_empty "$dir" ; then + msg2 "$(gettext "Cloning %s %s repo...")" "${repo}" "git" + if ! git clone --mirror "$url" "$dir"; then + error "$(gettext "Failure while downloading %s %s repo")" "${repo}" "git" + plain "$(gettext "Aborting...")" + exit 1 + fi + elif (( ! HOLDVER )); then + pushd "$dir" &>/dev/null + # Make sure we are fetching the right repo + if [[ "$url" != "$(git config --get remote.origin.url)" ]] ; then + error "$(gettext "%s is not a clone of %s")" "$dir" "$url" + plain "$(gettext "Aborting...")" + exit 1 + fi + msg2 "$(gettext "Updating %s %s repo...")" "${repo}" "git" + if ! git fetch --all -p; then + # only warn on failure to allow offline builds + warning "$(gettext "Failure while updating %s %s repo")" "${repo}" "git" + fi + popd &>/dev/null + fi +} + +extract_git() { + local netfile=$1 + + local url="$(get_url "$netfile")" + local fragment= + if [[ $url = *#* ]]; then + fragment=${url#*#} + fi + + local repo="$(get_downloadname "$netfile")" + local src="$SRCDEST/$repo" + local dst="$srcdir/$(get_depname "$netfile")" + + msg2 "$(gettext "Creating working copy of %s %s repo...")" "${repo}" "git" + rm -rf "${dst}" + + if ! git clone "$src" "$dst"; then + error "$(gettext "Failure while creating working copy of %s %s repo")" "${repo}" "git" + plain "$(gettext "Aborting...")" + exit 1 + fi + + local ref= + if [[ -n $fragment ]]; then + case ${fragment%%=*} in + commit|tag) + ref=${fragment##*=} + ;; + branch) + ref=origin/${fragment##*=} + ;; + *) + error "$(gettext "Unrecognized reference: %s")" "${fragment}" + plain "$(gettext "Aborting...")" + exit 1 + esac + fi + + if [[ -n $ref ]]; then + pushd "${dst}" &>/dev/null + if ! git checkout -b makepkg $ref; then + error "$(gettext "Failure while creating working copy of %s %s repo")" "${repo}" "git" + plain "$(gettext "Aborting...")" + exit 1 + fi + popd &>/dev/null + fi +} + +download_hg() { + local netfile=$1 + + local repo=$(get_downloadname "$netfile") + local dir="$SRCDEST/$repo" + + local url=$(get_url "$netfile") + url=${url##hg+} + url=${url%%#*} + + if [[ ! -d "$dir" ]] || dir_is_empty "$dir" ; then + msg2 "$(gettext "Cloning %s %s repo...")" "${repo}" "hg" + if ! hg clone -U "$url" "$dir"; then + error "$(gettext "Failure while downloading %s %s repo")" "${repo}" "hg" + plain "$(gettext "Aborting...")" + exit 1 + fi + elif (( ! HOLDVER )); then + msg2 "$(gettext "Updating %s %s repo...")" "${repo}" "hg" + pushd "$dir" &>/dev/null + if ! hg pull; then + # only warn on failure to allow offline builds + warning "$(gettext "Failure while updating %s %s repo")" "${repo}" "hg" + fi + popd &>/dev/null + fi +} + +extract_hg() { + local netfile=$1 + + local url="$(get_url "$netfile")" + local fragment= + if [[ $url = *#* ]]; then + fragment=${url#*#} + fi + + local repo="$(get_downloadname "$netfile")" + local src="$SRCDEST/$repo" + local dst="$srcdir/$(get_depname "$netfile")" + + msg2 "$(gettext "Creating working copy of %s %s repo...")" "${repo}" "hg" + rm -rf "${dst}" + + local ref= + if [[ -n $fragment ]]; then + case ${fragment%%=*} in + branch|revision|tag) + ref=('-u' "${fragment##*=}") + ;; + *) + error "$(gettext "Unrecognized reference: %s")" "${fragment}" + plain "$(gettext "Aborting...")" + exit 1 + esac + fi + + if ! hg clone "${ref[@]}" "$src" "$dst"; then + error "$(gettext "Failure while creating working copy of %s %s repo")" "${repo}" "hg" + plain "$(gettext "Aborting...")" + exit 1 + fi + +} + +download_svn() { + local netfile=$1 + + local url="$(get_url "$netfile")" + url=${url##svn+} + local fragment= + if [[ $url = *#* ]]; then + fragment=${url#*#} + fi + url=${url%%#*} + + local repo=$(get_downloadname "$netfile") + local dir="$SRCDEST/$repo" + + if [[ ! -d "$dir" ]] || dir_is_empty "$dir" ; then + msg2 "$(gettext "Cloning %s %s repo...")" "${repo}" "svn" + mkdir -p "$dir/.makepkg" + if ! svn checkout --config-dir "$dir/.makepkg" "$url" "$dir"; then + error "$(gettext "Failure while downloading %s %s repo")" "${repo}" "svn" + plain "$(gettext "Aborting...")" + exit 1 + fi + elif (( ! HOLDVER )); then + msg2 "$(gettext "Updating %s %s repo...")" "${repo}" "svn" + pushd "$dir" &>/dev/null + if ! svn update; then + # only warn on failure to allow offline builds + warning "$(gettext "Failure while updating %s %s repo")" "${repo}" "svn" + fi + popd &>/dev/null + fi +} + +extract_svn() { + local netfile=$1 + + local url="$(get_url "$netfile")" + url=${url##svn+} + local fragment= + if [[ $url = *#* ]]; then + fragment=${url#*#} + fi + + local repo="$(get_downloadname "$netfile")" + local src="$SRCDEST/$repo" + local dst="$srcdir/$(get_depname "$netfile")" + + msg2 "$(gettext "Creating working copy of %s %s repo...")" "${repo}" "svn" + rm -rf "${dst}" + + local ref= + if [[ -n $fragment ]]; then + case ${fragment%%=*} in + revision) + ref="${fragment##*=}" + ;; + *) + error "$(gettext "Unrecognized reference: %s")" "${fragment}" + plain "$(gettext "Aborting...")" + exit 1 + esac + fi + + cp -a "$src" "$dst" + + if [[ -n ${ref} ]]; then + pushd "$dst" &>/dev/null + if ! svn update -r ${ref}; then + error "$(gettext "Failure while creating working copy of %s %s repo")" "${repo}" "svn" + plain "$(gettext "Aborting...")" + fi + popd &>/dev/null + fi +} + +download_sources() { + msg "$(gettext "Retrieving sources...")" + + local netfile + for netfile in "$@"; do + local proto=$(get_protocol "$netfile") + case "$proto" in + git) + download_git "$netfile" + extract_git "$netfile" + ;; + hg) + download_hg "$netfile" + extract_hg "$netfile" + ;; + svn) + download_svn "$netfile" + extract_svn "$netfile" + ;; + http|https) + download_file "$netfile" + extract_file "$netfile" + ;; + *) + error "$(gettext "Unrecognized protocol: %s")" "$proto" + return 1 + ;; + esac + done +} + +declare -r HOLDVER=0 +declare -r srcdir="$PWD/src/$1"; shift +declare -r SRCDEST="$PWD/src/downloads" +declare -r DLAGENTS=('http::/usr/bin/curl -fLC - --retry 3 --retry-delay 3 -o %o %u' + 'https::/usr/bin/curl -fLC - --retry 3 --retry-delay 3 -o %o %u') + +mkdir -p "$srcdir" "$SRCDEST" +download_sources "$@" diff --git a/Makefile.d/grub-mkstandalone.mk b/Makefile.d/grub-mkstandalone.mk new file mode 100644 index 0000000..6eac0a1 --- /dev/null +++ b/Makefile.d/grub-mkstandalone.mk @@ -0,0 +1,31 @@ +include resources/utilities/grub-assemble/modules.conf + +grub_txtmode_memdisk_grafts = \ + /memtest=src/$(host_arch)/memtest86/memtest \ + /invaders.exec=src/$(host_arch)/grubinvaders/invaders.exec +grub_vesafb_memdisk_grafts = \ + /background.jpg=resources/grub/background/background.jpg \ + /dejavusansmono.pf2=resources/grub/font/dejavusansmono.pf2 + +grub_txtmode_memdisk_deps = $(foreach graft,$(grub_txtmode_memdisk_grafts),$(lastword $(subst =, ,$(graft)))) +grub_vesafb_memdisk_deps = $(foreach graft,$(grub_vesafb_memdisk_grafts) ,$(lastword $(subst =, ,$(graft)))) + +# A rule-variable is used here to avoid needing .SECONDEXPANSION +define rule_grub_elf +tmp/grub_%(romtype).elf: \ + tmp/builddeps-stamps/$(host_arch)/grub \ + $(keymapdir)/list.mk resources/utilities/grub-assemble/modules.conf \ + resources/grub/config/grub_memdisk.cfg \ + $(grub_%(romtype)_memdisk_deps) \ + $(firstword $(GRUB_MKSTANDALONE)) \ + $(foreach k,$(keymaps),$(keymapdir)/$k.gkb) + $(GRUB_MKSTANDALONE) -o $@ -O i386-coreboot \ + --fonts= --themes= --locales= \ + --modules='$(grub_modules)' \ + --install-modules='$(grub_install_modules)' \ + /boot/grub/grub.cfg="resources/grub/config/grub_memdisk.cfg" \ + $(grub_%(romtype)_memdisk_grafts) \ + $(foreach k,$(keymaps),/boot/grub/layouts/$k.gkb=$(keymapdir)/$k.gkb) + test -e $@ +endef +$(eval $(call multiglob,grub_elf,romtype)) diff --git a/Makefile.d/modules.mk b/Makefile.d/modules.mk new file mode 100644 index 0000000..cbd92ed --- /dev/null +++ b/Makefile.d/modules.mk @@ -0,0 +1,44 @@ +# Easy names for tmp/builddeps-stamps/% +$(foreach arch,$(arches),$(foreach module,$(modules), builddeps-$(arch)/$(module) )): builddeps-%: PHONY tmp/builddeps-stamps/% + +# The "all" rules +getdeps: $(foreach arch,$(arches),$(foreach module,$(modules), src/$(arch)/$(module) )) +builddeps: $(foreach arch,$(arches),$(foreach module,$(modules), builddeps-$(arch)/$(module) )) +cleandeps: $(foreach arch,$(arches),$(foreach module,$(modules), cleandeps-$(arch)/$(module) )) + rm -rf roms/* tmp/* + +# If we depend on a file in src/$(arch)/$(module)/, tell Make that we +# should generate it by calling the builddep rule. +define rule_module_files +src/%(arch)/%(module)/%: | tmp/builddeps-stamps/%(arch)/%(module) + test -e $@ +endef +$(eval $(call multiglob,modules_files,arch module)) + +# The generic rules + +# "get" rules +define rule_download +src/%(arch)/%(module): Makefile.d/downloader Makefile.d/modules/%(module).mk $(%(module)_patches) + Makefile.d/downloader %(arch) %(module)::$(%(module)_source) + $(%(module)_patch) + test -d $@ + touch $@ +endef +$(eval $(call multiglob,download,arch module)) + +# "builddeps" and "cleandeps" rules +# % = arch/module +tmp/builddeps-stamps/%: src/% + cd $< && { test -f ./Makefile || test -x ./configure || ./autogen.sh; } + cd $< && { test -f ./Makefile || ./configure $($*_configure); } + $(MAKE) -C $< + mkdir -p $(@D) + touch $@ + +# "cleandeps" rules +$(foreach arch,$(arches),$(foreach module,$(modules), cleandeps-$(arch)/$(module) )): \ +cleandeps-%: PHONY cleandeps-%-custom + rm -f tmp/builddeps-stamps/% +cleandeps-%-custom: PHONY + test ! -f src/$*/Makefile || $(MAKE) -C src/$* clean diff --git a/Makefile.d/modules/bucts.mk b/Makefile.d/modules/bucts.mk new file mode 100644 index 0000000..280dcb9 --- /dev/null +++ b/Makefile.d/modules/bucts.mk @@ -0,0 +1 @@ +bucts_source = git://git.stuge.se/bucts.git\#commit=dc27919d7a66a6e8685ce07c71aefa4f03ef7c07 diff --git a/Makefile.d/modules/coreboot.mk b/Makefile.d/modules/coreboot.mk new file mode 100644 index 0000000..1cf2309 --- /dev/null +++ b/Makefile.d/modules/coreboot.mk @@ -0,0 +1,61 @@ +coreboot_source = git+http://review.coreboot.org/coreboot\#commit=c637a887dde1c63bf3863e70cbe19dedf5f6ca02 + +coreboot_patches = resources/coreboot/patch/DEBLOB +define coreboot_patch + # Get patches from review.coreboot.org + # Text mode patch for X60 native graphics (main patch already merged in coreboot. See 6723 on coreboot gerrit) + cd $@ && git fetch http://review.coreboot.org/coreboot refs/changes/25/6725/3 && git cherry-pick FETCH_HEAD + # lenovo/x60: Enable legacy brightness controls (native graphics) + cd $@ && git fetch http://review.coreboot.org/coreboot refs/changes/48/7048/4 && git cherry-pick FETCH_HEAD + # Enable T60 native graphics + cd $@ && git fetch http://review.coreboot.org/coreboot refs/changes/45/5345/9 && git cherry-pick FETCH_HEAD + # Enable text-mode graphics for T60 + cd $@ && git fetch http://review.coreboot.org/coreboot refs/changes/50/7050/2 && git cherry-pick FETCH_HEAD + # lenovo/t60: Enable legacy brightness controls (native graphics) + cd $@ && git fetch http://review.coreboot.org/coreboot refs/changes/51/7051/1 && git cherry-pick FETCH_HEAD + # ec/lenovo/h8: permanently enable wifi/trackpoint/touchpad/bluetooth/wwan + cd $@ && git fetch http://review.coreboot.org/coreboot refs/changes/58/7058/7 && git cherry-pick FETCH_HEAD + # i945: permanently set tft_brightness to 0xff. this fixes the issue with X60 and "scrolling" backlight + cd $@ && git fetch http://review.coreboot.org/coreboot refs/changes/61/7561/2 && git cherry-pick FETCH_HEAD + # Note: macbook21 already has backlight control. + # Deblob coreboot + cd $@ && $(abspath resources/coreboot/patch/DEBLOB) +endef + + +# Generate sub-source directories by generating the parent source directory +coreboot_utils = cbfstool nvramtool crossgcc +define rule_coreboot_utils +src/%(arch)/coreboot/util/%(coreboot_util): | src/%(arch)/coreboot + test -d $@ +endef +$(eval $(call multiglob,coreboot_utils,arch coreboot_utils)) + +# The builddeps stamp needs to depend on 3 "utility" builddeps +$(foreach arch,$(arches),tmp/builddeps-stamps/$(arch)/coreboot): \ +tmp/builddeps-stamps/%/coreboot: \ + tmp/builddeps-stamps/%/coreboot-cbfstool \ + tmp/builddeps-stamps/%/coreboot-nvramtool \ + tmp/builddeps-stamps/%/coreboot-crossgcc + touch $@ + +# The 3 actual utility builddeps: +tmp/builddeps-stamps/%/coreboot-cbfstool: src/%/coreboot/util/cbfstool + $(MAKE) -C $< + mkdir -p $(@D) + touch $@ +tmp/builddeps-stamps/%/coreboot-nvramtool: src/%/coreboot/util/nvramtool + $(MAKE) -C $< + mkdir -p $(@D) + touch $@ +tmp/builddeps-stamps/%/coreboot-crossgcc: src/%/coreboot/util/crossgcc + $(MAKE) -C src/$*/coreboot crossgcc-i386 + mkdir -p $(@D) + touch $@ + +cleandeps-%/coreboot-custom: PHONY + test ! -f src/%/coreboot/Makefile || $(MAKE) -C src/%/coreboot clean + test ! -f src/%/coreboot/Makefile || $(MAKE) -C src/%/coreboot/util/cbfstool clean + test ! -f src/%/coreboot/Makefile || $(MAKE) -C src/%/coreboot/util/nvramtool clean + test ! -f src/%/coreboot/Makefile || $(MAKE) -C src/%/coreboot crossgcc-clean + rm -f tmp/builddeps-stamps/%/coreboot-* diff --git a/Makefile.d/modules/dejavu.mk b/Makefile.d/modules/dejavu.mk new file mode 100644 index 0000000..ae72876 --- /dev/null +++ b/Makefile.d/modules/dejavu.mk @@ -0,0 +1,5 @@ +dejavu_source = http://sourceforge.net/projects/dejavu/files/dejavu/2.34/dejavu-fonts-ttf-2.34.tar.bz2 + +$(foreach arch,$(arches),tmp/builddeps-stamps/$(arch)/dejavu): \ +tmp/builddeps-stamps/%/dejavu: src/%/dejavu ; mkdir -p $(@D) && touch $@ +cleandeps-%/dejavu-custom: PHONY ; diff --git a/Makefile.d/modules/flashrom.mk b/Makefile.d/modules/flashrom.mk new file mode 100644 index 0000000..c70e6e2 --- /dev/null +++ b/Makefile.d/modules/flashrom.mk @@ -0,0 +1,20 @@ +flashrom_source = svn://flashrom.org/flashrom/trunk\#revision=1854 + +flashrom_patches = $(wildcard resources/flashrom/patch/flashchips_*.c) +define flashrom_patch + cp resources/flashrom/patch/flashchips_*.c $@ + sed -i \ + -e 's/\$$(PROGRAM)\$$(EXEC_SUFFIX)/$$(PROGRAM)$$(patchname)$$(EXEC_SUFFIX)/g' \ + -e 's/flashchips\.o/flashchips$$(patchname).o/g' \ + -e 's/libflashrom\.a/libflashrom$$(patchname).a/g' \ + -e 's/\(rm .*libflashrom\)\S*\.a/\1*.a $$(PROGRAM)_*/' \ + $@/Makefile +endef + +$(foreach arch,$(arches),tmp/builddeps-stamps/$(arch)/flashrom): \ +tmp/builddeps-stamps/%/flashrom: src/%/flashrom + $(MAKE) -C $< patchname=_normal + $(MAKE) -C $< patchname=_lenovobios_macronix + $(MAKE) -C $< patchname=_lenovobios_sst + mkdir -p $(@D) + touch $@ diff --git a/Makefile.d/modules/grub.mk b/Makefile.d/modules/grub.mk new file mode 100644 index 0000000..3f392aa --- /dev/null +++ b/Makefile.d/modules/grub.mk @@ -0,0 +1,8 @@ +grub_source = git://git.savannah.gnu.org/grub.git\#commit=e2dd6daa8c33e3e7641e442dc269fcca479c6fda + +grub_patches = resources/grub/patch/gitdiff +define grub_patch + cd $@ && git apply $(abspath resources/grub/patch/gitdiff) +endef + +grub_configure = --with-platform=coreboot diff --git a/Makefile.d/modules/grubinvaders.mk b/Makefile.d/modules/grubinvaders.mk new file mode 100644 index 0000000..01d1c0c --- /dev/null +++ b/Makefile.d/modules/grubinvaders.mk @@ -0,0 +1,16 @@ +grubinvaders_source = http://www.erikyyy.de/invaders/invaders-1.0.0.tar.gz + +grubinvaders_patches = resources/grubinvaders/patch/diff.patch resources/grubinvaders/patch/compile.sh.patch +define grubinvaders_patch + # Apply patch mentioned on http://www.coreboot.org/GRUB_invaders + cd $@ && patch < $(abspath resources/grubinvaders/patch/diff.patch) + cd $@ && patch compile.sh < $(abspath resources/grubinvaders/patch/compile.sh.patch) +endef + +$(foreach arch,$(arches),tmp/builddeps-stamps/$(arch)/grubinvaders): \ +tmp/builddeps-stamps/%/grubinvaders: src/%/grubinvaders + cd $< && ./compile.sh + mkdir -p $(@D) + touch $@ +cleandeps-%/grubinvaders-custom: PHONY + test ! -d src/%/grubinvaders || { cd src/%/grubinvaders && ./clean.sh; } diff --git a/Makefile.d/modules/i945pwm.mk b/Makefile.d/modules/i945pwm.mk new file mode 100644 index 0000000..b8f2a12 --- /dev/null +++ b/Makefile.d/modules/i945pwm.mk @@ -0,0 +1,3 @@ +i945pwm_source = git://git.mtjm.eu/i945-pwm.git\#commit=d88c8b290b9473e071d24cd3b97f4a091ee398cf +cleandeps-%/i945pwm-custom: PHONY + rm -f src/%/i945pwm/i945-pwm diff --git a/Makefile.d/modules/memtest86.mk b/Makefile.d/modules/memtest86.mk new file mode 100644 index 0000000..97a644d --- /dev/null +++ b/Makefile.d/modules/memtest86.mk @@ -0,0 +1,7 @@ +memtest86_source = http://www.memtest.org/download/5.01/memtest86+-5.01.tar.gz + +memtest86_patches = resources/memtest86/patch/config.h resources/memtest86/patch/Makefile +define memtest86_patch + cp -f resources/memtest86/patch/config.h $@/config.h + cp -f resources/memtest86/patch/Makefile $@/Makefile +endef diff --git a/Makefile.d/modules/powertop.mk b/Makefile.d/modules/powertop.mk new file mode 100644 index 0000000..7491588 --- /dev/null +++ b/Makefile.d/modules/powertop.mk @@ -0,0 +1 @@ +powertop_source = git+https://github.com/fenrus75/powertop.git\#e70c89eb5d7b6b8f898bb126adefcbf3202d5acf diff --git a/Makefile.d/modules/seabios.mk b/Makefile.d/modules/seabios.mk new file mode 100644 index 0000000..17abece --- /dev/null +++ b/Makefile.d/modules/seabios.mk @@ -0,0 +1,8 @@ +seabios_source = git://git.seabios.org/seabios.git\#commit=9f505f715793d99235bd6b4afb2ca7b96ba5729b + +$(foreach arch,$(arches),tmp/builddeps-stamps/$(arch)/seabios): \ +tmp/builddeps-stamps/%/seabios: src/%/seabios resources/seabios/config/config + cp resources/seabios/config/config $