--- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ ifeq ($(KERNELRELEASE),) MAKEFLAGS += --no-print-directory -SHELL := /bin/bash +SHELL := /usr/bin/env bash BACKPORT_DIR := $(shell pwd) KMODDIR ?= updates @@ -19,6 +19,7 @@ KLIB_BUILD ?= $(KLIB)/build/ KERNEL_CONFIG := $(KLIB_BUILD)/.config KERNEL_MAKEFILE := $(KLIB_BUILD)/Makefile CONFIG_MD5 := $(shell md5sum $(KERNEL_CONFIG) 2>/dev/null | sed 's/\s.*//') +STAMP_KERNEL_CONFIG := .kernel_config_md5_$(CONFIG_MD5) export KLIB KLIB_BUILD BACKPORT_DIR KMODDIR KMODPATH_ARG @@ -36,7 +37,8 @@ mrproper: @rm -f .kernel_config_md5 Kconfig.versions Kconfig.kernel @rm -f backport-include/backport/autoconf.h -.DEFAULT: +.SILENT: $(STAMP_KERNEL_CONFIG) +$(STAMP_KERNEL_CONFIG): @set -e ; test -f .local-symbols || ( \ echo "/--------------" ;\ echo "| You shouldn't run make in the backports tree, but only in" ;\ @@ -60,56 +62,60 @@ mrproper: echo "| (that isn't currently running.)" ;\ echo "\\--" ;\ false) - @set -e ; if [ "$$(cat .kernel_config_md5 2>/dev/null)" != "$(CONFIG_MD5)" ] ;\ - then \ - echo -n "Generating local configuration database from kernel ..." ;\ - grep -v -f .local-symbols $(KERNEL_CONFIG) | grep = | ( \ - while read l ; do \ - if [ "$${l:0:7}" != "CONFIG_" ] ; then \ - continue ;\ - fi ;\ - l=$${l:7} ;\ - n=$${l%%=*} ;\ - v=$${l#*=} ;\ - if [ "$$v" = "m" ] ; then \ - echo config $$n ;\ - echo ' tristate' ;\ - elif [ "$$v" = "y" ] ; then \ - echo config $$n ;\ - echo ' bool' ;\ - else \ - continue ;\ - fi ;\ - echo " default $$v" ;\ - echo "" ;\ - done \ - ) > Kconfig.kernel ;\ - kver=$$($(MAKE) --no-print-directory -C $(KLIB_BUILD) kernelversion | \ - sed 's/^\(\(3\|2\.6\)\.[0-9]\+\).*/\1/;t;d') ;\ - test "$$kver" != "" || echo "Kernel version parse failed!" ;\ - test "$$kver" != "" ;\ - kvers="$$(seq 14 39 | sed 's/^/2.6./')" ;\ - kvers="$$kvers $$(seq 0 99 | sed 's/^/3./')" ;\ - print=0 ;\ - for v in $$kvers ; do \ - if [ "$$print" = "1" ] ; then \ - echo config KERNEL_$$(echo $$v | tr . _) ;\ - echo " def_bool y" ;\ - fi ;\ - if [ "$$v" = "$$kver" ] ; then print=1 ; fi ;\ - done > Kconfig.versions ;\ - # RHEL as well, sadly we need to grep for it ;\ - RHEL_MAJOR=$$(grep '^RHEL_MAJOR' $(KERNEL_MAKEFILE) | \ - sed 's/.*=\s*\([0-9]*\)/\1/;t;d') ;\ - RHEL_MINOR=$$(grep '^RHEL_MINOR' $(KERNEL_MAKEFILE) | \ - sed 's/.*=\s*\([0-9]*\)/\1/;t;d') ;\ - for v in $$(seq 0 $$RHEL_MINOR) ; do \ - echo config BACKPORT_RHEL_KERNEL_$${RHEL_MAJOR}_$$v ;\ - echo " def_bool y" ;\ - done >> Kconfig.versions ;\ - echo " done." ;\ - fi ;\ - echo "$(CONFIG_MD5)" > .kernel_config_md5 + @rm -f .kernel_config_md5_* + @touch $@ + +Kconfig.kernel: $(STAMP_KERNEL_CONFIG) .local-symbols + @printf "Generating local configuration database from kernel ..." + @grep -v -f .local-symbols $(KERNEL_CONFIG) | grep = | ( \ + while read l ; do \ + if [ "$${l:0:7}" != "CONFIG_" ] ; then \ + continue ;\ + fi ;\ + l=$${l:7} ;\ + n=$${l%%=*} ;\ + v=$${l#*=} ;\ + if [ "$$v" = "m" ] ; then \ + echo config $$n ;\ + echo ' tristate' ;\ + elif [ "$$v" = "y" ] ; then \ + echo config $$n ;\ + echo ' bool' ;\ + else \ + continue ;\ + fi ;\ + echo " default $$v" ;\ + echo "" ;\ + done \ + ) > $@ + @echo " done." + +Kconfig.versions: Kconfig.kernel + @kver=$$($(MAKE) --no-print-directory -C $(KLIB_BUILD) kernelversion | \ + sed 's/^\(\(3\|2\.6\)\.[0-9]\+\).*/\1/;t;d') ;\ + test "$$kver" != "" || echo "Kernel version parse failed!" ;\ + test "$$kver" != "" ;\ + kvers="$$(seq 14 39 | sed 's/^/2.6./')" ;\ + kvers="$$kvers $$(seq 0 99 | sed 's/^/3./')" ;\ + print=0 ;\ + for v in $$kvers ; do \ + if [ "$$print" = "1" ] ; then \ + echo config KERNEL_$$(echo $$v | tr . _) ;\ + echo " def_bool y" ;\ + fi ;\ + if [ "$$v" = "$$kver" ] ; then print=1 ; fi ;\ + done > $@ + @RHEL_MAJOR=$$(grep '^RHEL_MAJOR' $(KERNEL_MAKEFILE) | \ + sed 's/.*=\s*\([0-9]*\)/\1/;t;d') ;\ + RHEL_MINOR=$$(grep '^RHEL_MINOR' $(KERNEL_MAKEFILE) | \ + sed 's/.*=\s*\([0-9]*\)/\1/;t;d') ;\ + for v in $$(seq 0 $$RHEL_MINOR) ; do \ + echo config BACKPORT_RHEL_KERNEL_$${RHEL_MAJOR}_$$v ;\ + echo " def_bool y" ;\ + done >> $@ + +.DEFAULT: + @$(MAKE) Kconfig.versions @$(MAKE) -f Makefile.real "$@" .PHONY: defconfig-help --- a/Makefile.real +++ b/Makefile.real @@ -59,7 +59,7 @@ defconfig-%:: backport-include/backport/autoconf.h: .config Kconfig.versions Kconfig.kernel @$(MAKE) oldconfig - @echo -n "Building backport-include/backport/autoconf.h ..." + @printf "Building backport-include/backport/autoconf.h ..." @grep -f .local-symbols .config | ( \ echo "#ifndef COMPAT_AUTOCONF_INCLUDED" ;\ echo "#define COMPAT_AUTOCONF_INCLUDED" ;\ @@ -80,7 +80,12 @@ backport-include/backport/autoconf.h: .c esac ;\ done ;\ echo "#endif /* COMPAT_AUTOCONF_INCLUDED */" ;\ - ) > backport-include/backport/autoconf.h + ) > $@.new + @if cmp -s $@ $@.new; then \ + rm -f $@.new; \ + else \ + mv $@.new $@; \ + fi @echo " done." .PHONY: modules ='#n83'>83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166
# Bootmagic
There are three separate but related features that allow you to change the behavior of your keyboard without reflashing. While each of them have similar functionality, it is accessed in different ways depending on how your keyboard is configured.
**Bootmagic** is a system for configuring your keyboard while it initializes. To trigger a Bootmagic command, hold down the Bootmagic key and one or more command keys.
**Bootmagic Keycodes** are prefixed with `MAGIC_`, and allow you to access the Bootmagic functionality *after* your keyboard has initialized. To use the keycodes, assign them to your keymap as you would any other keycode.
**Command**, formerly known as **Magic**, is another feature that allows you to control different aspects of your keyboard. While it shares some functionality with Bootmagic, it also allows you to do things that Bootmagic does not, such as printing version information to the console. For more information, see [Command](feature_command.md).
On some keyboards Bootmagic is disabled by default. If this is the case, it must be explicitly enabled in your `rules.mk` with:
```make
BOOTMAGIC_ENABLE = full
```
?> You may see `yes` being used in place of `full`, and this is okay. However, `yes` is deprecated, and ideally `full` (or `lite`) should be used instead.
Additionally, you can use [Bootmagic Lite](#bootmagic-lite) (a scaled down, very basic version of Bootmagic) by adding the following to your `rules.mk` file:
```make
BOOTMAGIC_ENABLE = lite
```
## Hotkeys
Hold down the Bootmagic key (Space by default) and the desired hotkey while plugging in your keyboard. For example, holding Space+`B` should cause it to enter the bootloader.
|Hotkey |Description |
|------------------|---------------------------------------------|
|Escape |Ignore Bootmagic configuration in EEPROM |
|`B` |Enter the bootloader |
|`D` |Toggle debugging over serial |
|`X` |Toggle key matrix debugging |
|`K` |Toggle keyboard debugging |
|`M` |Toggle mouse debugging |