File: Makefile

package info (click to toggle)
qdl 2.4-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 388 kB
  • sloc: ansic: 4,810; makefile: 87; xml: 75; sh: 70
file content (92 lines) | stat: -rw-r--r-- 2,935 bytes parent folder | download
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
QDL := qdl
RAMDUMP := qdl-ramdump
VERSION := $(or $(VERSION), $(shell git describe --dirty --always --tags 2>/dev/null), "unknown-version")

PKG_CONFIG ?= pkg-config
CFLAGS += -O2 -Wall -g `$(PKG_CONFIG) --cflags libxml-2.0 libusb-1.0`
LDFLAGS += `$(PKG_CONFIG) --libs libxml-2.0 libusb-1.0`
ifeq ($(OS),Windows_NT)
LDFLAGS += -lws2_32
endif
prefix := /usr/local

QDL_SRCS := firehose.c io.c qdl.c sahara.c util.c patch.c program.c read.c sha2.c sim.c ufs.c usb.c ux.c oscompat.c vip.c sparse.c gpt.c
QDL_OBJS := $(QDL_SRCS:.c=.o)

RAMDUMP_SRCS := ramdump.c sahara.c io.c sim.c usb.c util.c ux.c oscompat.c
RAMDUMP_OBJS := $(RAMDUMP_SRCS:.c=.o)

KS_OUT := ks
KS_SRCS := ks.c sahara.c util.c ux.c oscompat.c
KS_OBJS := $(KS_SRCS:.c=.o)

CHECKPATCH_SOURCES := $(shell find . -type f \( -name "*.c" -o -name "*.h" -o -name "*.sh" \) ! -name "sha2.c" ! -name "sha2.h" ! -name "*version.h" ! -name "list.h")
CHECKPATCH_ROOT := https://raw.githubusercontent.com/torvalds/linux/v6.15/scripts
CHECKPATCH_URL := $(CHECKPATCH_ROOT)/checkpatch.pl
CHECKPATCH_SP_URL := $(CHECKPATCH_ROOT)/spelling.txt
CHECKPATCH := ./.scripts/checkpatch.pl
CHECKPATCH_SP := ./.scripts/spelling.txt

MANPAGES := ks.1 qdl-ramdump.1 qdl.1

default: $(QDL) $(RAMDUMP) $(KS_OUT)

$(QDL): $(QDL_OBJS)
	$(CC) -o $@ $^ $(LDFLAGS)

$(RAMDUMP): $(RAMDUMP_OBJS)
	$(CC) -o $@ $^ $(LDFLAGS)

$(KS_OUT): $(KS_OBJS)
	$(CC) -o $@ $^ $(LDFLAGS)

compile_commands.json: $(QDL_SRCS) $(KS_SRCS)
	@echo -n $^ | jq -snR "[inputs|split(\" \")[]|{directory:\"$(PWD)\", command: \"$(CC) $(CFLAGS) -c \(.)\", file:.}]" > $@

manpages: $(KS_OUT) $(RAMDUMP) $(QDL)
	help2man -N -n "KS" -o ks.1 ./ks
	help2man -N -n "Qualcomm Download" -o qdl.1 ./qdl
	help2man -N -n "Qualcomm Download Ramdump" -o qdl-ramdump.1 ./qdl-ramdump

version.h::
	@echo "#define VERSION \"$(VERSION)\"" > .version.h
	@cmp -s .version.h version.h || cp .version.h version.h

util.o: version.h

clean:
	rm -f $(QDL) $(QDL_OBJS)
	rm -f $(RAMDUMP) $(RAMDUMP_OBJS)
	rm -f $(KS_OUT) $(KS_OBJS)
	rm -f $(MANPAGES)
	rm -f compile_commands.json
	rm -f version.h .version.h
	rm -f $(CHECKPATCH)
	rm -f $(CHECKPATCH_SP)
	if [ -d .scripts ]; then rmdir .scripts; fi

install: $(QDL) $(RAMDUMP) $(KS_OUT)
	install -d $(DESTDIR)$(prefix)/bin
	install -m 755 $^ $(DESTDIR)$(prefix)/bin

tests: default
tests:
	@./tests/run_tests.sh

# Target to download checkpatch.pl if not present
$(CHECKPATCH):
	@echo "Downloading checkpatch.pl..."
	@mkdir -p $(dir $(CHECKPATCH))
	@curl -sSfL $(CHECKPATCH_URL) -o $(CHECKPATCH)
	@curl -sSfL $(CHECKPATCH_SP_URL) -o $(CHECKPATCH_SP)
	@chmod +x $(CHECKPATCH)

check: $(CHECKPATCH)
	@echo "Running checkpatch on source files (excluding sha2.c and sha2.h)..."
	@for file in $(CHECKPATCH_SOURCES); do \
		perl $(CHECKPATCH) --no-tree -f $$file || exit 1; \
	done

check-cached: $(CHECKPATCH)
	@echo "Running checkpatch on staged changes..."
	@git diff --cached -- . | perl $(CHECKPATCH) --no-tree -