summaryrefslogtreecommitdiff
path: root/ubi-utils/Makefile
blob: 2776c07001a0b4b6f6959016e4d4786a26870f08 (plain)
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
#
# Makefile for ubi-utils
#

HOST_OS_NAME := $(shell uname -s)
HOST_VERSION_NAME := $(shell uname -r)
BUILD_CPU := $(shell uname -m)
BUILD_OS := $(shell uname -o)

KERNELHDR := ../include
DESTDIR := /usr/local
SBINDIR := bin

CC := $(CROSS)gcc
CFLAGS := -I./inc -I./src -I$(KERNELHDR) -O2 -g -Wall -Werror \
	-Wwrite-strings -W -std=gnu99 \
        -DHOST_OS_NAME=\"$(HOST_OS_NAME)\" \
        -DHOST_VERSION_NAME=\"$(HOST_VERSION_NAME)\" \
	-DBUILD_CPU=\"$(BUILD_CPU)\" -DBUILD_OS=\"$(BUILD_OS)\"

PERLPROGS = mkpfi ubicrc32.pl
TARGETS = ubiupdatevol ubimkvol ubirmvol pfiflash pddcustomize ubimirror \
	bin2nand nand2bin ubigen mkbootenv unubi pfi2bin

vpath   %.c ./src

%: %.o
	$(CC) $(LDFLAGS) -g -o $@ $^

%.o: %.c
	$(CC) $(CFLAGS) -g -c -o $@ $< -g -Wp,-MD,.$(shell basename $<).dep

all: $(TARGETS)

IGNORE=${wildcard .*.c.dep}
-include ${IGNORE}

clean:
	rm -rf *.o $(TARGETS) .*.c.dep

ubiupdatevol: ubiupdatevol.o error.o libubi.o libubi_sysfs.o
	$(CC) $(LDFLAGS) -o $@ $^

ubimkvol: ubimkvol.o error.o libubi.o libubi_sysfs.o
	$(CC) $(LDFLAGS) -o $@ $^

ubirmvol: ubirmvol.o error.o libubi.o libubi_sysfs.o
	$(CC) $(LDFLAGS) -o $@ $^

pddcustomize: pddcustomize.o error.o libubimirror.o bootenv.o hashmap.o \
		libubi.o libubi_sysfs.o crc32.o
	$(CC) $(LDFLAGS) -o $@ $^

pfiflash: pfiflash.o libpfiflash.o list.o reader.o error.o libubimirror.o \
		bootenv.o hashmap.o pfi.o libubi.o libubi_sysfs.o crc32.o
	$(CC) $(LDFLAGS) -o $@ $^

ubimirror: ubimirror.o error.o libubimirror.o bootenv.o hashmap.o \
		libubi.o libubi_sysfs.o crc32.o
	$(CC) $(LDFLAGS) -o $@ $^

nand2bin: nand2bin.o nandecc.o nandcorr.o
	$(CC) $(LDFLAGS) -o $@ $^

bin2nand: bin2nand.o error.o nandecc.o
	$(CC) $(LDFLAGS) -o $@ $^

ubigen: ubigen.o libubigen.o crc32.o
	$(CC) $(LDFLAGS) -o $@ $^

mkbootenv: mkbootenv.o bootenv.o hashmap.o error.o crc32.o
	$(CC) $(LDFLAGS) -o $@ $^

unubi: unubi.o crc32.o
	$(CC) $(LDFLAGS) -o $@ $^

pfi2bin: pfi2bin.o peb.o error.o list.o crc32.o libubigen.o bootenv.o \
		hashmap.o reader.o pfi.o
	$(CC) $(LDFLAGS) -o $@ $^

install: ${TARGETS}
	mkdir -p ${DESTDIR}/${SBINDIR}
	install -m0755 ${TARGETS} ${DESTDIR}/${SBINDIR}/
	(cd perl && install ${PERLPROGS} ${DESTDIR}/${SBINDIR}/)

uninstall:
	for file in ${TARGETS} ${PERLPROGS}; do \
		$(RM) ${DESTDIR}/${SBINDIR}/$$file; \
	done