]> CyberLeo.Net >> Repos - CDN/Mosi.git/blob - Makefile
worlds/i386/SABA: update to new layout
[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 makefs      != which makefs
16 makefs_opts ?= -t ffs -o version=2,optimization=space -b 8 -f 8
17 tunefs      != which tunefs
18 mkuzip      != which mkuzip
19 mkuzip_opts ?= -s 65536
20 mkisofs     != which mkisofs
21 mkisofs_opts?= -quiet -D -R -no-pad -p CyberLeo
22
23 # Default device for burn target
24 dev         ?= null
25
26 # Check current user
27 curruser    != id -u
28 checkroot    = @if [ $(curruser) -gt 0 ]; then printf "\033[1;31mI need root\033[0m\n"; exit 1; fi
29 checkdeps    = @if [ ! -x "$(mkisofs)" -o ! -x "$(mkuzip)" ]; then printf "\033[1;31mCheck depends! mkisofs: $(mkisofs) mkuzip: $(mkuzip)\033[0m\n"; exit 1; fi
30
31 # Default target
32 all: $(worktree)/card.img
33
34 image: $(worktree)/card.img
35
36 firmware: $(worktree)/card.img
37
38 # Check that we're running as root
39 checkroot:
40         $(checkroot)
41
42 # Burn to device
43 burn: $(worktree)/card.img
44         $(checkroot)
45         script/burn $(.ALLSRC) $(dev)
46
47 # Push to build target
48 push:
49         script/push cyberleo@sc1425:mosi/
50
51 # Generate components
52 $(worktree)/card.img: $(worktree)/boot.img $(worktree)/root.img
53         $(checkroot)
54         ${gencard} -b $(worktree)/boot.img -r $(worktree)/root.img -c $(worktree)/conf -s ${image_sect} -o $(worktree)/card.img
55         @printf " \033[1;32m*\033[0m Complete\n"
56
57 $(worktree)/boot.img: $(worktree)/boot
58         $(checkroot)
59         #${genufs} -p $(boot_pad) -l boot -o $(worktree)/boot.img $(worktree)/boot
60         ${makefs} ${makefs_opts} $(worktree)/boot.img $(worktree)/boot
61         ${tunefs} -L boot $(worktree)/boot.img
62
63 $(worktree)/root.img: $(worktree)/root.iso
64         $(checkroot)
65         $(checkdeps)
66         ${genuzip} $(.ALLSRC) $(.TARGET)
67
68 $(worktree)/root.iso: $(worktree)/root
69         $(checkroot)
70         $(checkdeps)
71         ${geniso} -n root $(.ALLSRC) $(.TARGET)
72
73 $(worktree): $(worktree)/root
74
75 $(worktree)/boot: $(srctree)/root
76         $(checkroot)
77         $(gentree) -b $(srctree) -t $(worktree)
78
79 $(worktree)/root: $(srctree)/root
80         $(checkroot)
81         $(gentree) -b $(srctree) -t $(worktree)
82
83 # Scrub everything clean
84 clean:
85         $(checkroot)
86         rm -Rf $(worktree)