Imported Upstream version 3.0.16
[platform/upstream/dosfstools.git] / Makefile
1 # Makefile
2 #
3 # Copyright (C) 2008-2013 Daniel Baumann <mail@daniel-baumann.ch>
4 #
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
17 #
18 # On Debian systems, the complete text of the GNU General Public License
19 # can be found in /usr/share/common-licenses/GPL-3 file.
20
21
22 DESTDIR =
23 PREFIX = /usr/local
24 SBINDIR = $(PREFIX)/sbin
25 DOCDIR = $(PREFIX)/share/doc
26 MANDIR = $(PREFIX)/share/man
27
28 #OPTFLAGS = -O2 -fomit-frame-pointer -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
29 OPTFLAGS = -O2 -fomit-frame-pointer $(shell getconf LFS_CFLAGS)
30 #WARNFLAGS = -Wall -pedantic -std=c99
31 WARNFLAGS = -Wall
32 DEBUGFLAGS = -g
33 CFLAGS += $(OPTFLAGS) $(WARNFLAGS) $(DEBUGFLAGS)
34
35 VPATH = src
36
37 all: build
38
39 build: dosfsck dosfslabel mkdosfs
40
41 dosfsck: boot.o check.o common.o fat.o file.o io.o lfn.o charconv.o dosfsck.o
42
43 dosfslabel: boot.o check.o common.o fat.o file.o io.o lfn.o charconv.o dosfslabel.o
44
45 mkdosfs: mkdosfs.o
46
47 rebuild: distclean build
48
49 install: install-bin install-doc install-man
50
51 install-bin: build
52         install -d -m 0755 $(DESTDIR)/$(SBINDIR)
53         install -m 0755 dosfsck dosfslabel mkdosfs $(DESTDIR)/$(SBINDIR)
54
55         ln -sf dosfsck $(DESTDIR)/$(SBINDIR)/fsck.msdos
56         ln -sf dosfsck $(DESTDIR)/$(SBINDIR)/fsck.vfat
57         ln -sf mkdosfs $(DESTDIR)/$(SBINDIR)/mkfs.msdos
58         ln -sf mkdosfs $(DESTDIR)/$(SBINDIR)/mkfs.vfat
59
60 install-doc:
61         install -d -m 0755 $(DESTDIR)/$(DOCDIR)/dosfstools
62         install -p -m 0644 ChangeLog doc/* $(DESTDIR)/$(DOCDIR)/dosfstools
63
64 install-man:
65         install -d -m 0755 $(DESTDIR)/$(MANDIR)/man8
66         install -p -m 0644 man/*.8 $(DESTDIR)/$(MANDIR)/man8
67
68         ln -sf dosfsck.8 $(DESTDIR)/$(MANDIR)/man8/fsck.msdos.8
69         ln -sf dosfsck.8 $(DESTDIR)/$(MANDIR)/man8/fsck.vfat.8
70         ln -sf mkdosfs.8 $(DESTDIR)/$(MANDIR)/man8/mkfs.msdos.8
71         ln -sf mkdosfs.8 $(DESTDIR)/$(MANDIR)/man8/mkfs.vfat.8
72
73 uninstall: uninstall-bin uninstall-doc uninstall-man
74
75 uninstall-bin:
76         rm -f $(DESTDIR)/$(SBINDIR)/dosfsck
77         rm -f $(DESTDIR)/$(SBINDIR)/dosfslabel
78         rm -f $(DESTDIR)/$(SBINDIR)/mkdosfs
79
80         rm -f $(DESTDIR)/$(SBINDIR)/fsck.msdos
81         rm -f $(DESTDIR)/$(SBINDIR)/fsck.vfat
82         rm -f $(DESTDIR)/$(SBINDIR)/mkfs.msdos
83         rm -f $(DESTDIR)/$(SBINDIR)/mkfs.vfat
84
85         rmdir --ignore-fail-on-non-empty $(DESTDIR)/$(SBINDIR)
86
87 uninstall-doc:
88         rm -rf $(DESTDIR)/$(DOCDIR)/dosfstools
89
90         rmdir --ignore-fail-on-non-empty $(DESTDIR)/$(DOCDIR)
91
92 uninstall-man:
93         rm -f $(DESTDIR)/$(MANDIR)/man8/dosfsck.8
94         rm -f $(DESTDIR)/$(MANDIR)/man8/dosfslabel.8
95         rm -f $(DESTDIR)/$(MANDIR)/man8/mkdosfs.8
96
97         rm -f $(DESTDIR)/$(MANDIR)/man8/fsck.msdos.8
98         rm -f $(DESTDIR)/$(MANDIR)/man8/fsck.vfat.8
99         rm -f $(DESTDIR)/$(MANDIR)/man8/mkfs.msdos.8
100         rm -f $(DESTDIR)/$(MANDIR)/man8/mkfs.vfat.8
101
102         rmdir --ignore-fail-on-non-empty $(DESTDIR)/$(MANDIR)/man8
103         rmdir --ignore-fail-on-non-empty $(DESTDIR)/$(MANDIR)
104
105 reinstall: distclean install
106
107 clean:
108         rm -f *.o
109
110 distclean: clean
111         rm -f dosfsck dosfslabel mkdosfs
112
113 .PHONY: build rebuild install install-bin install-doc install-man uninstall uninstall-bin uninstall-doc uninstall-man reinstall clean distclean