2 CFLAGS = -std=gnu99 -Wall -Wno-unused-parameter -Wno-unused-result -Wformat-security -Os -g
4 MAGIC = echo "8: 414902" | xxd -r -
10 .PHONY: all embed mrproper
12 # Prepare 1024 bytes of space for updateinformation
14 #printf '\0%.0s' {0..1023} > $@
15 echo "03FF: 00" | xxd -r > $@
18 # Compile runtime but do not link
20 $(CC) -c $(CFLAGS) $^ -DGIT_COMMIT=\"$(git describe --tags --always --abbrev=7)\" \
21 -I./squashfuse/ -D_FILE_OFFSET_BITS=64
23 # Add .upd_info and .sha256_sig sections
24 embed: 1024_blank_bytes runtime
25 objcopy --add-section .upd_info=1024_blank_bytes \
26 --set-section-flags .upd_info=noload,readonly runtime
27 objcopy --add-section .sha256_sig=1024_blank_bytes \
28 --set-section-flags .sha256_sig=noload,readonly runtime
31 # Now statically link against libsquashfuse_ll, libsquashfuse and liblzma
32 # TODO: generate runtime in function of the compressor we choose to avoid embeded unnecessary compression.
33 runtime: runtime.o notify.o elf.o getsection.o
34 $(CC) $(CFLAGS) $^ ./squashfuse/.libs/libsquashfuse_ll.a \
35 ./squashfuse/.libs/libsquashfuse.a ./squashfuse/.libs/libfuseprivate.a \
36 -lfuse -lpthread -lz -linotifytools -ldl `pkg-config --libs liblzma liblz4` -o runtime
38 install: runtime embed
40 $(COPY_FILE) runtime build
41 $(STRIP) build/runtime
42 # Insert AppImage magic bytes at offset 8
43 # verify with : xxd -ps -s 0x8 -l 3 build/runtime
44 $(MAGIC) build/runtime
47 rm -f *.o 1024_blank_bytes