-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
81 lines (63 loc) · 1.78 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
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
libarsc_objects :=
libarsc_objects += blob.o
libarsc_objects += cmds/dump.o
libarsc_objects += cmds/test.o
libarsc_objects += common.o
libarsc_objects += config.o
libarsc_objects += filemap.o
libarsc_objects += options.o
binary := arsc
headers :=
headers += arsc.h
headers += blob.h
headers += cmds.h
headers += common.h
headers += config.h
headers += filemap.h
headers += options.h
libarsc = libarsc.a
objects := $(binary).o $(libarsc_objects)
deps := $(objects:.o=.d)
manifests := $(shell find t -type f -name AndroidManifest.xml -print)
apks := $(patsubst %/AndroidManifest.xml,%.apk,$(manifests))
deps += $(apks:.apk=.d)
arscs := $(apks:.apk=.arsc)
CC := clang
CFLAGS := -Wall -Wextra -I. -ggdb -O0
CFLAGS += -DDEBUG
LD := $(CC)
LDFLAGS := $(CFLAGS)
LIBS := $(libarsc)
ifndef V
QUIET_DEP = @echo " DEP $@";
QUIET_CC = @echo " CC $@";
QUIET_LD = @echo " LINK $@";
QUIET_AR = @echo " AR $@";
QUIET_AAPT = @echo " AAPT $@";
QUIET_UNZIP = @echo " UNZIP $@";
endif
%.d: %.c
$(QUIET_DEP)$(CC) $(CFLAGS) -MM $< | sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' > $@
%.o: %.c
$(QUIET_CC)$(CC) $(CFLAGS) -c -o $@ $<
%.d: %/AndroidManifest.xml
$(QUIET_DEP)echo -n "$(patsubst %/AndroidManifest.xml,%,$<).apk $@ : $(shell find $(patsubst %/AndroidManifest.xml,%,$<) -type f | tr '\n' ' ')" > $@
%.apk: %/AndroidManifest.xml
$(QUIET_AAPT)aapt package -M $< -S $(patsubst %/AndroidManifest.xml,%/res,$<) -F $@ -f
%.arsc: %.apk
$(QUIET_UNZIP)unzip -p $< resources.arsc > $@
all: $(binary)
$(libarsc): $(libarsc_objects)
$(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $^
$(binary): $(binary).o $(LIBS)
$(QUIET_LD)$(LD) $(LDFLAGS) -o $@ $^
.PHONY: test
test: $(binary) $(apks) $(arscs)
clean:
$(RM) $(deps)
$(RM) $(objects)
$(RM) $(LIBS)
$(RM) $(binary)
$(RM) $(apks)
$(RM) $(arscs)
-include $(deps)