forked from AppImage/AppImageKit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.runtime
50 lines (42 loc) · 1.62 KB
/
Makefile.runtime
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
46
47
48
49
50
CC = gcc
CFLAGS = -std=gnu99 -Wall -Wno-unused-parameter -Wno-unused-result -Wformat-security -Os -g
STRIP = strip
MAGIC = echo "8: 414902" | xxd -r -
MKDIR = mkdir -p
COPY = cp -f
COPY_FILE = $(COPY)
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) $^ -DGIT_COMMIT=\"$(git describe --tags --always --abbrev=7)\" \
-I./squashfuse/ -D_FILE_OFFSET_BITS=64
# 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
# Now statically link against libsquashfuse_ll, libsquashfuse and liblzma
# TODO: generate runtime in function of the compressor we choose to avoid embeded unnecessary compression.
runtime: runtime.o notify.o elf.o getsection.o
$(CC) $(CFLAGS) $^ ./squashfuse/.libs/libsquashfuse_ll.a \
./squashfuse/.libs/libsquashfuse.a ./squashfuse/.libs/libfuseprivate.a \
-lfuse -lpthread -lz -linotifytools -ldl `pkg-config --libs liblzma liblz4` -o runtime
install: runtime embed
$(MKDIR) build
$(COPY_FILE) 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