# Defaults my_arch != uname -m # Settables arch ?= $(my_arch) conf ?= GENERIC target ?= targets/$(arch)/$(conf) srctree ?= $(target)/world worktree ?= $(target)/tree boot_pad ?= 1280 cardsize ?= 524288 # Generation scripts gentree = script/gentree genufs = script/genufs geniso = script/geniso genuzip = script/genuzip gencard = script/gencard # Image utilities makefs != which makefs makefs_opts ?= -t ffs -o version=2,optimization=space -b 8 -f 8 tunefs != which tunefs mkuzip != which mkuzip mkuzip_opts ?= -s 65536 mkisofs != which mkisofs mkisofs_opts?= -quiet -D -R -no-pad -p CyberLeo # Default device for burn target dev ?= null # Check current user curruser != id -u checkroot = @if [ $(curruser) -gt 0 ]; then printf "\033[1;31mI need root\033[0m\n"; exit 1; fi checkdeps = @if [ ! -x "$(mkisofs)" -o ! -x "$(mkuzip)" ]; then printf "\033[1;31mCheck depends! mkisofs: $(mkisofs) mkuzip: $(mkuzip)\033[0m\n"; exit 1; fi # Default target all: $(worktree)/card.img image: $(worktree)/card.img firmware: $(worktree)/card.img # Check that we're running as root checkroot: $(checkroot) # Burn to device burn: $(worktree)/card.img $(checkroot) script/burn $(.ALLSRC) $(dev) # Push to build target push: script/push cyberleo@sc1425:mosi/ # Generate components $(worktree)/card.img: $(worktree)/boot.img $(worktree)/root.img $(checkroot) ${gencard} -b $(worktree)/boot.img -r $(worktree)/root.img -c $(worktree)/conf -s ${cardsize} -o $(worktree)/card.img @printf " \033[1;32m*\033[0m Complete\n" $(worktree)/boot.img: $(worktree)/boot $(checkroot) #${genufs} -p $(boot_pad) -l boot -o $(worktree)/boot.img $(worktree)/boot ${makefs} ${makefs_opts} $(worktree)/boot.img $(worktree)/boot ${tunefs} -L boot $(worktree)/boot.img $(worktree)/root.img: $(worktree)/root.iso $(checkroot) $(checkdeps) ${genuzip} $(.ALLSRC) $(.TARGET) $(worktree)/root.iso: $(worktree)/root $(checkroot) $(checkdeps) ${geniso} -n root $(.ALLSRC) $(.TARGET) $(worktree): $(worktree)/root $(worktree)/boot: $(srctree)/root $(checkroot) $(gentree) -a $(arch) -c $(conf) $(worktree)/root: $(srctree)/root $(checkroot) $(gentree) -a $(arch) -c $(conf) # Scrub everything clean clean: $(checkroot) sh -c 'if ! rm -Rf $(worktree); then chflags -R noschg $(worktree); rm -Rf $(worktree); fi'