-
Notifications
You must be signed in to change notification settings - Fork 73
/
Makefile
66 lines (52 loc) · 1.42 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
CC ?= gcc
LD ?= gcc
DEP_CC ?= gcc
AR ?= ar
RANLIB ?= ranlib
STRIP ?= strip
CFLAGS += -O2 -Wall -Werror -Wno-error=maybe-uninitialized -Wno-error=address-of-packed-member
LDFLAGS +=
# libmincrypt
LIB_NAME = mincrypt
SLIB = lib$(LIB_NAME).a
LIB_SRCS = \
libmincrypt/dsa_sig.c \
libmincrypt/p256.c \
libmincrypt/p256_ec.c \
libmincrypt/p256_ecdsa.c \
libmincrypt/rsa.c \
libmincrypt/sha.c \
libmincrypt/sha256.c
LIB_OBJS = $(LIB_SRCS:%.c=%.o)
LIB_INCS = -Iinclude
LDFLAGS += -L. -l$(LIB_NAME)
# mkbootimg
MKBOOTIMG_SRCS = mkbootimg.c
MKBOOTIMG_OBJS = $(MKBOOTIMG_SRCS:%.c=%.o)
# unpackbootimg
UNPACKBOOTIMG_SRCS = unpackbootimg.c
UNPACKBOOTIMG_OBJS = $(UNPACKBOOTIMG_SRCS:%.c=%.o)
SRCS = \
$(MKBOOTIMG_SRCS) \
$(UNPACKBOOTIMG_SRCS) \
$(LIB_SRCS)
.PHONY: default all clean
default: all
all: $(LIB_NAME) mkbootimg unpackbootimg
$(LIB_NAME): $(LIB_OBJS)
$(AR) rc $(SLIB) $(LIB_OBJS)
$(RANLIB) $(SLIB)
mkbootimg: $(MKBOOTIMG_SRCS)
$(CC) $(CFLAGS) $(LIB_INCS) -o mkbootimg $< $(LDFLAGS)
unpackbootimg: $(UNPACKBOOTIMG_SRCS)
$(CC) $(CFLAGS) $(LIB_INCS) -o unpackbootimg $< $(LDFLAGS)
%.o: %.c .depend
$(CC) -c $(CFLAGS) $(LIB_INCS) $< -o $@
clean:
$(RM) -f *.o *.a mkbootimg unpackbootimg .depend
ifneq ($(wildcard .depend),)
include .depend
endif
.depend:
@$(RM) .depend
@$(foreach SRC, $(SRCS), $(DEP_CC) $(LIB_INCS) $(SRC) $(CFLAGS) -MT $(SRC:%.c=%.o) -MM >> .depend;)