-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
45 lines (37 loc) · 1.13 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
CC = gcc-10
CFLAGS = -std=gnu99 -Wall -Os
STRIP = strip
MAGIC = echo "8: 414902" | xxd -r -
MKDIR = mkdir -p
COPY = cp -f
LIBS = -lfuse3 -lsquashfuse -lsquashfuse_ll -lzstd -lpthread -ldl
all: runtime
.PHONY: all embed mrproper
# Prepare 1024 bytes of space for updateinformation
1024_blank_bytes:
#printf '\0%.0s' {0..1023} > $@
echo "03FF: 00" | xxd -r > $@
stat $@
# Compile runtime but do not link
runtime.o: runtime.c
$(CC) -c $(CFLAGS) $^
# Add .upd_info and .sha256_sig sections
embed: 1024_blank_bytes runtime
objcopy --add-section .upd_info=1024_blank_bytes \
--set-section-flags .upd_info=noload,readonly runtime
objcopy --add-section .sha256_sig=1024_blank_bytes \
--set-section-flags .sha256_sig=noload,readonly runtime
stat runtime
runtime: runtime.o
$(CC) $(CFLAGS) $^ $(LIBS) -o runtime
install: runtime embed
$(MKDIR) build
$(COPY) runtime build
$(STRIP) build/runtime
# Insert AppImage magic bytes at offset 8
# verify with : xxd -ps -s 0x8 -l 3 build/runtime
$(MAGIC) build/runtime
clean:
rm -f *.o 1024_blank_bytes
mrproper: clean
rm -f runtime