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