forked from anestisb/android-simg2img
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
109 lines (87 loc) · 2.74 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#
# Copyright (C) 2014 Anestis Bechtsoudis
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
PREFIX ?= /usr/local
CC ?= gcc
LD ?= gcc
DEP_CC ?= gcc
AR ?= ar
RANLIB ?= ranlib
STRIP ?= strip
CFLAGS += -O2 -Wall -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE=1
# libsparse
LIB_NAME = sparse
SLIB = lib$(LIB_NAME).a
LIB_SRCS = \
backed_block.c \
output_file.c \
sparse.c \
sparse_crc32.c \
sparse_err.c \
sparse_read.c
LIB_OBJS = $(LIB_SRCS:%.c=%.o)
LIB_INCS = -Iinclude
LDFLAGS += -L. -l$(LIB_NAME) -lm -lz
BINS = simg2img simg2simg img2simg append2simg
HEADERS = include/sparse/sparse.h
# simg2img
SIMG2IMG_SRCS = simg2img.c
SIMG2IMG_OBJS = $(SIMG2IMG_SRCS:%.c=%.o)
# simg2simg
SIMG2SIMG_SRCS = simg2simg.c
SIMG2SIMG_OBJS = $(SIMG2SIMG_SRCS:%.c=%.o)
# img2simg
IMG2SIMG_SRCS = $(LIBSPARSE_SRCS) img2simg.c
IMG2SIMG_OBJS = $(IMG2SIMG_SRCS:%.c=%.o)
# append2simg
APPEND2SIMG_SRCS = $(LIBSPARSE_SRCS) append2simg.c
APPEND2SIMG_OBJS = $(APPEND2SIMG_SRCS:%.c=%.o)
SRCS = \
$(SIMG2IMG_SRCS) \
$(SIMG2SIMG_SRCS) \
$(IMG2SIMG_SRCS) \
$(APPEND2SIMG_SRCS) \
$(LIB_SRCS)
.PHONY: default all clean install
default: all
all: $(LIB_NAME) simg2img simg2simg img2simg append2simg
install: all
install -d $(PREFIX)/bin $(PREFIX)/lib $(PREFIX)/include/sparse
install -m 0755 $(BINS) $(PREFIX)/bin
install -m 0755 $(SLIB) $(PREFIX)/lib
install -m 0644 $(HEADERS) $(PREFIX)/include/sparse
$(LIB_NAME): $(LIB_OBJS)
$(AR) rc $(SLIB) $(LIB_OBJS)
$(RANLIB) $(SLIB)
simg2img: $(SIMG2IMG_SRCS) $(LIB_NAME)
$(CC) $(CFLAGS) $(LIB_INCS) -o simg2img $< $(LDFLAGS)
simg2simg: $(SIMG2SIMG_SRCS) $(LIB_NAME)
$(CC) $(CFLAGS) $(LIB_INCS) -o simg2simg $< $(LDFLAGS)
img2simg: $(IMG2SIMG_SRCS) $(LIB_NAME)
$(CC) $(CFLAGS) $(LIB_INCS) -o img2simg $< $(LDFLAGS)
append2simg: $(APPEND2SIMG_SRCS) $(LIB_NAME)
$(CC) $(CFLAGS) $(LIB_INCS) -o append2simg $< $(LDFLAGS)
%.o: %.c .depend
$(CC) -c $(CFLAGS) $(LIB_INCS) $< -o $@
clean:
$(RM) -f *.o *.a simg2img simg2simg img2simg append2simg .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;)
indent:
indent -linux -l100 -lc100 -nut -i4 *.c *.h; rm -f *~