-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
117 lines (89 loc) · 4.47 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
110
111
112
113
114
115
116
117
LTO=-flto
CFLAGS=-Wall -O3 -g $(LTO) -std=gnu11 -fPIC
LDFLAGS=-Wall -O3 -g $(LTO) -std=gnu11 -fPIC
LIB_CFLAGS=-Wall -O3 -g -std=gnu11 -shared -fPIC
VERSION=0.9.1
prefix = /usr
exec_prefix = ${prefix}
bindir = ${exec_prefix}/bin
libdir = ${exec_prefix}/lib
fmlibdir = ${libdir}/filemapper
mandir = ${exec_prefix}/man
man1dir = ${mandir}/man1
appdir = ${exec_prefix}/share/applications
XFSPROGS ?= Please_set_XFSPROGS_to_the_XFS_source_directory
DOSFSTOOLS ?= Please_set_DOSFSTOOLS_to_the_DOS_source_directory
DOSFS_HEADERS=$(DOSFSTOOLS)/src/fsck.fat.h $(DOSFSTOOLS)/src/file.h $(DOSFSTOOLS)/src/fat.h $(DOSFSTOOLS)/src/lfn.h $(DOSFSTOOLS)/src/charconv.h $(DOSFSTOOLS)/src/boot.h $(DOSFSTOOLS)/src/common.h $(DOSFSTOOLS)/src/io.h
PYINCLUDE ?= -I/usr/include/python3.5m/
COMPDB_LIBS=-lz -llz4 -llzma -lbz2
pyfiles=fiemap.py filemapper.py fmcli.py fmdb.py fmgui.py getfsmap.py ioctl.py vfs.py
ifeq ("$(notdir $(wildcard $(XFSPROGS)/libxfs/.libs/libxfs.a))", "libxfs.a")
xfsmapper=xfsmapper
endif
ifeq ("$(notdir $(wildcard $(DOSFSTOOLS)/fat.o))", "fat.o")
fatmapper=fatmapper
endif
progs=filemapper e2mapper ntfsmapper shrinkmapper $(xfsmapper) $(fatmapper)
libs=compdb.so
manpages=$(patsubst %,%.1.gz,$(progs))
all: $(progs) $(libs) $(manpages) $(pyfiles) filemapper.desktop
%.1.gz: %.1
gzip -9n < $< > $@
compdb.so: compdb.o compress.o pymod.o
$(CC) $(LIB_CFLAGS) -o $@ $^ -lsqlite3 $(COMPDB_LIBS)
pymod.o: pymod.c compdb.h compress.h filemapper.h
$(CC) $(CFLAGS) -DPYMOD $(PYINCLUDE) -o $@ -c $<
compdb.o: compdb.c compdb.h compress.h filemapper.h
compress.o: compress.h
filemapper.o: filemapper.h
shrinkmapper: shrinkmapper.o compress.o compdb.o
$(CC) $(CFLAGS) -o $@ $^ -lsqlite3 $(COMPDB_LIBS)
shrinkmapper.o: compdb.h filemapper.h
xfsmapper: filemapper.o xfsmapper.o compress.o compdb.o $(XFSPROGS)/libxfs/.libs/libxfs.a
$(CC) $(CFLAGS) -o $@ $^ $(XFSPROGS)/repair/btree.o -lsqlite3 -lpthread -luuid -lm $(COMPDB_LIBS)
xfsmapper.o: xfsmapper.c filemapper.h $(XFSPROGS)/include/libxfs.h $(XFSPROGS)/repair/btree.h $(XFSPROGS)/libxfs/libxfs_api_defs.h compdb.h
$(CC) $(CFLAGS) -D_GNU_SOURCE -o $@ -c $< -I$(XFSPROGS)/include/ -I$(XFSPROGS)/libxfs/ -I$(XFSPROGS)/
e2mapper: filemapper.o e2mapper.o compress.o compdb.o
$(CC) $(CFLAGS) -o $@ $^ -lsqlite3 -lcom_err -lext2fs -lm $(COMPDB_LIBS)
e2mapper.o: e2mapper.c filemapper.h compdb.h
ntfsmapper: filemapper.o ntfsmapper.o compress.o compdb.o
$(CC) $(CFLAGS) -o $@ $^ -lsqlite3 -lntfs-3g -lm $(COMPDB_LIBS)
ntfsmapper.o: ntfsmapper.c filemapper.h compdb.h
libfat.a: $(DOSFSTOOLS)/boot.o $(DOSFSTOOLS)/charconv.o $(DOSFSTOOLS)/common.o $(DOSFSTOOLS)/fat.o $(DOSFSTOOLS)/file.o $(DOSFSTOOLS)/io.o $(DOSFSTOOLS)/lfn.o
$(AR) cr libfat.a $^
fatmapper: filemapper.o fatmapper.o fatcheck.o libfat.a compress.o compdb.o
$(CC) $(CFLAGS) -o $@ $^ -lsqlite3 -lm $(COMPDB_LIBS)
fatcheck.c: $(DOSFSTOOLS)/src/check.c $(DOSFS_HEADERS)
sed -e 's/static void add_file/void add_file/g' < $< > $@
fatcheck.o: fatcheck.c
$(CC) $(CFLAGS) -o $@ -c $< -I$(DOSFSTOOLS)/src/
fatmapper.o: fatmapper.c filemapper.h $(DOSFS_HEADERS) compdb.h
$(CC) $(CFLAGS) -o $@ -c $< -I$(DOSFSTOOLS)/src/
clean:;
rm -rf $(progs) $(manpages) $(libs) xfsmapper xfsmapper.1.gz fatmapper fatmapper.1.gz libfat.a fatcheck.c *.pyc __pycache__ filemapper.desktop *.o
filemapper: filemapper.in
sed -e "s|%libdir%|${fmlibdir}|g" < $< > $@
filemapper.desktop: filemapper.desktop.in
sed -e "s|%libdir%|${fmlibdir}|g" < $< > $@
install: all
install -d $(DESTDIR)$(bindir)
install -s e2mapper ntfsmapper shrinkmapper $(DESTDIR)$(bindir)
install filemapper $(DESTDIR)$(bindir)
install -d $(DESTDIR)$(fmlibdir)
install -m 0644 $(pyfiles) $(DESTDIR)$(fmlibdir)
install -s compdb.so $(DESTDIR)$(fmlibdir)
install -m 0644 filemapper.png filemapper.ui $(DESTDIR)$(fmlibdir)
install -d $(DESTDIR)$(man1dir)
install -m 0644 e2mapper.1.gz filemapper.1.gz ntfsmapper.1.gz shrinkmapper.1.gz $(DESTDIR)$(man1dir)
install -d $(DESTDIR)$(appdir)
install -m 0644 filemapper.desktop $(DESTDIR)$(appdir)
-test -e fatmapper && install -s fatmapper $(DESTDIR)$(bindir)
-test -e fatmapper && install -m 0644 fatmapper.1.gz $(DESTDIR)$(man1dir)
-test -e xfsmapper && install -s xfsmapper $(DESTDIR)$(bindir)
-test -e xfsmapper && install -m 0644 xfsmapper.1.gz $(DESTDIR)$(man1dir)
dist:
@if test "`git describe`" != "$(VERSION)" ; then \
echo 'Update VERSION in the Makefile before running "make dist".' ; \
exit 1 ; \
fi
git archive --format=tar --prefix=filemapper-$(VERSION)/ HEAD^{tree} | xz -9 > ../filemapper_$(VERSION).orig.tar.xz