script/push, Makefile: move build target into Makefile instead of hardcoding in push...
[CDN/Mosi.git] / Makefile
1 # Settables
2 srctree     ?= src
3 worktree    ?= tree
4 boot_pad    ?= 1280
5 image_sect  ?= 1000944
6
7 # Generation scripts
8 gentree      = script/gentree
9 genufs       = script/genufs
10 geniso       = script/geniso
11 genuzip      = script/genuzip
12 gencard      = script/gencard
13
14 # Image utilities
15 mkuzip      != which mkuzip
16 mkuzip_opts ?= -s 65536
17 mkisofs     != which mkisofs
18 mkisofs_opts?= -quiet -D -R -no-pad -p CyberLeo
19
20 # Default device for burn target
21 dev         ?= null
22
23 # Check current user
24 curruser    != id -u
25 checkroot    = @if [ $(curruser) -gt 0 ]; then printf "\033[1;31mI need root\033[0m\n"; exit 1; fi
26 checkdeps    = @if [ ! -x "$(mkisofs)" -o ! -x "$(mkuzip)" ]; then printf "\033[1;31mCheck depends! mkisofs: $(mkisofs) mkuzip: $(mkuzip)\033[0m\n"; exit 1; fi
27
28 # Default target
29 all: $(worktree)/card.img
30
31 image: $(worktree)/card.img
32
33 firmware: $(worktree)/card.img
34
35 # Check that we're running as root
36 checkroot:
37         $(checkroot)
38
39 # Burn to device
40 burn: $(worktree)/card.img
41         $(checkroot)
42         script/burn $(.ALLSRC) $(dev)
43
44 # Push to build target
45 push:
46         script/push cyberleo@sc1425:mosi/
47
48 # Generate components
49 $(worktree)/card.img: $(worktree)/boot.img $(worktree)/root.img
50         $(checkroot)
51         ${gencard} -b $(worktree)/boot.img -r $(worktree)/root.img -c $(worktree)/conf -o $(worktree)/card.img
52         @printf " \033[1;32m*\033[0m Complete\n"
53
54 $(worktree)/boot.img: $(worktree)/boot
55         $(checkroot)
56         ${genufs} -p $(boot_pad) -l boot -o $(worktree)/boot.img $(worktree)/boot
57
58 $(worktree)/root.img: $(worktree)/root.iso
59         $(checkroot)
60         $(checkdeps)
61         ${genuzip} $(.ALLSRC) $(.TARGET)
62
63 $(worktree)/root.iso: $(worktree)/root
64         $(checkroot)
65         $(checkdeps)
66         ${geniso} -n root $(.ALLSRC) $(.TARGET)
67
68 $(worktree): $(worktree)/root
69
70 $(worktree)/boot: $(srctree)/root
71         $(checkroot)
72         $(gentree) -b $(srctree) -t $(worktree)
73
74 $(worktree)/root: $(srctree)/root
75         $(checkroot)
76         $(gentree) -b $(srctree) -t $(worktree)
77
78 # Scrub everything clean
79 clean:
80         $(checkroot)
81         rm -Rf $(worktree)