bigbiff bigbiff | 9c75405 | 2013-01-09 09:09:08 -0500 | [diff] [blame] | 1 | # Makefile |
| 2 | # |
Matt Mower | 18794c8 | 2015-11-11 16:22:45 -0600 | [diff] [blame^] | 3 | # Copyright (C) 2008-2014 Daniel Baumann <mail@daniel-baumann.ch> |
bigbiff bigbiff | 9c75405 | 2013-01-09 09:09:08 -0500 | [diff] [blame] | 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 | # |
Matt Mower | 18794c8 | 2015-11-11 16:22:45 -0600 | [diff] [blame^] | 18 | # The complete text of the GNU General Public License |
bigbiff bigbiff | 9c75405 | 2013-01-09 09:09:08 -0500 | [diff] [blame] | 19 | # can be found in /usr/share/common-licenses/GPL-3 file. |
| 20 | |
Matt Mower | 18794c8 | 2015-11-11 16:22:45 -0600 | [diff] [blame^] | 21 | SHELL := sh -e |
| 22 | LANGUAGES = $(shell cd manpages/po && ls) |
| 23 | |
bigbiff bigbiff | 9c75405 | 2013-01-09 09:09:08 -0500 | [diff] [blame] | 24 | DESTDIR = |
| 25 | PREFIX = /usr/local |
| 26 | SBINDIR = $(PREFIX)/sbin |
| 27 | DOCDIR = $(PREFIX)/share/doc |
| 28 | MANDIR = $(PREFIX)/share/man |
| 29 | |
| 30 | #OPTFLAGS = -O2 -fomit-frame-pointer -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 |
Matt Mower | 18794c8 | 2015-11-11 16:22:45 -0600 | [diff] [blame^] | 31 | OPTFLAGS = -O2 -fomit-frame-pointer -D_GNU_SOURCE $(shell getconf LFS_CFLAGS) |
bigbiff bigbiff | 9c75405 | 2013-01-09 09:09:08 -0500 | [diff] [blame] | 32 | #WARNFLAGS = -Wall -pedantic -std=c99 |
Matt Mower | 18794c8 | 2015-11-11 16:22:45 -0600 | [diff] [blame^] | 33 | WARNFLAGS = -Wall -Wextra -Wno-sign-compare -Wno-missing-field-initializers -Wmissing-prototypes -Wstrict-prototypes -Wwrite-strings |
bigbiff bigbiff | 9c75405 | 2013-01-09 09:09:08 -0500 | [diff] [blame] | 34 | DEBUGFLAGS = -g |
| 35 | CFLAGS += $(OPTFLAGS) $(WARNFLAGS) $(DEBUGFLAGS) |
| 36 | |
| 37 | VPATH = src |
| 38 | |
| 39 | all: build |
| 40 | |
Matt Mower | 18794c8 | 2015-11-11 16:22:45 -0600 | [diff] [blame^] | 41 | build: fatlabel fsck.fat mkfs.fat |
bigbiff bigbiff | 9c75405 | 2013-01-09 09:09:08 -0500 | [diff] [blame] | 42 | |
Matt Mower | 18794c8 | 2015-11-11 16:22:45 -0600 | [diff] [blame^] | 43 | fatlabel: boot.o check.o common.o fat.o file.o io.o lfn.o fatlabel.o |
bigbiff bigbiff | 9c75405 | 2013-01-09 09:09:08 -0500 | [diff] [blame] | 44 | |
Matt Mower | 18794c8 | 2015-11-11 16:22:45 -0600 | [diff] [blame^] | 45 | fsck.fat: boot.o check.o common.o fat.o file.o io.o lfn.o fsck.fat.o |
bigbiff bigbiff | 9c75405 | 2013-01-09 09:09:08 -0500 | [diff] [blame] | 46 | |
Matt Mower | 18794c8 | 2015-11-11 16:22:45 -0600 | [diff] [blame^] | 47 | mkfs.fat: mkfs.fat.o |
bigbiff bigbiff | 9c75405 | 2013-01-09 09:09:08 -0500 | [diff] [blame] | 48 | |
| 49 | rebuild: distclean build |
| 50 | |
Matt Mower | 18794c8 | 2015-11-11 16:22:45 -0600 | [diff] [blame^] | 51 | install: install-bin install-doc install-man install-symlinks |
bigbiff bigbiff | 9c75405 | 2013-01-09 09:09:08 -0500 | [diff] [blame] | 52 | |
| 53 | install-bin: build |
| 54 | install -d -m 0755 $(DESTDIR)/$(SBINDIR) |
Matt Mower | 18794c8 | 2015-11-11 16:22:45 -0600 | [diff] [blame^] | 55 | install -m 0755 fatlabel fsck.fat mkfs.fat $(DESTDIR)/$(SBINDIR) |
bigbiff bigbiff | 9c75405 | 2013-01-09 09:09:08 -0500 | [diff] [blame] | 56 | |
| 57 | install-doc: |
| 58 | install -d -m 0755 $(DESTDIR)/$(DOCDIR)/dosfstools |
| 59 | install -p -m 0644 ChangeLog doc/* $(DESTDIR)/$(DOCDIR)/dosfstools |
| 60 | |
| 61 | install-man: |
Matt Mower | 18794c8 | 2015-11-11 16:22:45 -0600 | [diff] [blame^] | 62 | for MANPAGE in manpages/en/*; \ |
| 63 | do \ |
| 64 | SECTION="8"; \ |
| 65 | mkdir -p $(DESTDIR)/$(MANDIR)/man$${SECTION}/; \ |
| 66 | install -m 0644 $${MANPAGE} $(DESTDIR)/$(MANDIR)/man$${SECTION}/$$(basename $${MANPAGE}); \ |
| 67 | done |
bigbiff bigbiff | 9c75405 | 2013-01-09 09:09:08 -0500 | [diff] [blame] | 68 | |
Matt Mower | 18794c8 | 2015-11-11 16:22:45 -0600 | [diff] [blame^] | 69 | for LANGUAGE in $(LANGUAGES); \ |
| 70 | do \ |
| 71 | for MANPAGE in manpages/$${LANGUAGE}/*; \ |
| 72 | do \ |
| 73 | SECTION="8"; \ |
| 74 | mkdir -p $(DESTDIR)/$(MANDIR)/$${LANGUAGE}/man$${SECTION}/; \ |
| 75 | install -m 0644 $${MANPAGE} $(DESTDIR)/$(MANDIR)/$${LANGUAGE}/man$${SECTION}/$$(basename $${MANPAGE} .$${LANGUAGE}.$${SECTION}).$${SECTION}; \ |
| 76 | done; \ |
| 77 | done |
| 78 | install-symlinks: install-bin install-man |
| 79 | if [ -e $(DESTDIR)/$(SBINDIR)/fatlabel ]; \ |
| 80 | then \ |
| 81 | ln -sf fatlabel $(DESTDIR)/$(SBINDIR)/dosfslabel; \ |
| 82 | if [ -e $(DESTDIR)/$(MANDIR)/man8/fatlabel.8 ]; \ |
| 83 | then \ |
| 84 | ln -sf fatlabel.8 $(DESTDIR)/$(MANDIR)/man8/dosfslabel.8; \ |
| 85 | fi; \ |
| 86 | fi |
bigbiff bigbiff | 9c75405 | 2013-01-09 09:09:08 -0500 | [diff] [blame] | 87 | |
Matt Mower | 18794c8 | 2015-11-11 16:22:45 -0600 | [diff] [blame^] | 88 | if [ -e $(DESTDIR)/$(SBINDIR)/fsck.fat ]; \ |
| 89 | then \ |
| 90 | ln -sf fsck.fat $(DESTDIR)/$(SBINDIR)/dosfsck; \ |
| 91 | ln -sf fsck.fat $(DESTDIR)/$(SBINDIR)/fsck.msdos; \ |
| 92 | ln -sf fsck.fat $(DESTDIR)/$(SBINDIR)/fsck.vfat; \ |
| 93 | if [ -e $(DESTDIR)/$(MANDIR)/man8/fsck.fat.8 ]; \ |
| 94 | then \ |
| 95 | ln -sf fsck.fat.8 $(DESTDIR)/$(MANDIR)/man8/dosfsck.8; \ |
| 96 | ln -sf fsck.fat.8 $(DESTDIR)/$(MANDIR)/man8/fsck.msdos.8; \ |
| 97 | ln -sf fsck.fat.8 $(DESTDIR)/$(MANDIR)/man8/fsck.vfat.8; \ |
| 98 | fi; \ |
| 99 | fi |
| 100 | |
| 101 | if [ -e $(DESTDIR)/$(SBINDIR)/mkfs.fat ]; \ |
| 102 | then \ |
| 103 | ln -sf mkfs.fat $(DESTDIR)/$(SBINDIR)/mkdosfs; \ |
| 104 | ln -sf mkfs.fat $(DESTDIR)/$(SBINDIR)/mkfs.msdos; \ |
| 105 | ln -sf mkfs.fat $(DESTDIR)/$(SBINDIR)/mkfs.vfat; \ |
| 106 | if [ -e $(DESTDIR)/$(MANDIR)/man8/mkfs.fat.8 ]; \ |
| 107 | then \ |
| 108 | ln -sf mkfs.fat.8 $(DESTDIR)/$(MANDIR)/man8/mkdosfs.8; \ |
| 109 | ln -sf mkfs.fat.8 $(DESTDIR)/$(MANDIR)/man8/mkfs.msdos.8; \ |
| 110 | ln -sf mkfs.fat.8 $(DESTDIR)/$(MANDIR)/man8/mkfs.vfat.8; \ |
| 111 | fi; \ |
| 112 | fi |
| 113 | |
| 114 | uninstall: uninstall-symlinks uninstall-man uninstall-doc uninstall-bin |
bigbiff bigbiff | 9c75405 | 2013-01-09 09:09:08 -0500 | [diff] [blame] | 115 | |
| 116 | uninstall-bin: |
Matt Mower | 18794c8 | 2015-11-11 16:22:45 -0600 | [diff] [blame^] | 117 | rm -f $(DESTDIR)/$(SBINDIR)/fatlabel |
| 118 | rm -f $(DESTDIR)/$(SBINDIR)/fsck.fat |
| 119 | rm -f $(DESTDIR)/$(SBINDIR)/mkfs.fat |
bigbiff bigbiff | 9c75405 | 2013-01-09 09:09:08 -0500 | [diff] [blame] | 120 | |
| 121 | rmdir --ignore-fail-on-non-empty $(DESTDIR)/$(SBINDIR) |
| 122 | |
| 123 | uninstall-doc: |
| 124 | rm -rf $(DESTDIR)/$(DOCDIR)/dosfstools |
| 125 | |
| 126 | rmdir --ignore-fail-on-non-empty $(DESTDIR)/$(DOCDIR) |
| 127 | |
| 128 | uninstall-man: |
Matt Mower | 18794c8 | 2015-11-11 16:22:45 -0600 | [diff] [blame^] | 129 | for MANPAGE in manpages/en/*; \ |
| 130 | do \ |
| 131 | SECTION="8"; \ |
| 132 | rm -f $(DESTDIR)/$(MANDIR)/man$${SECTION}/$$(basename $${MANPAGE} .en.$${SECTION}).$${SECTION}; \ |
| 133 | done |
| 134 | |
| 135 | for LANGUAGE in $(LANGUAGES); \ |
| 136 | do \ |
| 137 | for MANPAGE in manpages/$${LANGUAGE}/*; \ |
| 138 | do \ |
| 139 | SECTION="8"; \ |
| 140 | rm -f $(DESTDIR)/$(MANDIR)/$${LANGUAGE}/man$${SECTION}/$$(basename $${MANPAGE} .$${LANGUAGE}.$${SECTION}).$${SECTION}; \ |
| 141 | done; \ |
| 142 | done |
| 143 | |
| 144 | uninstall-symlinks: |
| 145 | rm -f $(DESTDIR)/$(SBINDIR)/dosfslabel |
bigbiff bigbiff | 9c75405 | 2013-01-09 09:09:08 -0500 | [diff] [blame] | 146 | rm -f $(DESTDIR)/$(MANDIR)/man8/dosfslabel.8 |
bigbiff bigbiff | 9c75405 | 2013-01-09 09:09:08 -0500 | [diff] [blame] | 147 | |
Matt Mower | 18794c8 | 2015-11-11 16:22:45 -0600 | [diff] [blame^] | 148 | rm -f $(DESTDIR)/$(SBINDIR)/dosfsck |
| 149 | rm -f $(DESTDIR)/$(MANDIR)/man8/dosfsck.8 |
| 150 | rm -f $(DESTDIR)/$(SBINDIR)/fsck.msdos |
bigbiff bigbiff | 9c75405 | 2013-01-09 09:09:08 -0500 | [diff] [blame] | 151 | rm -f $(DESTDIR)/$(MANDIR)/man8/fsck.msdos.8 |
Matt Mower | 18794c8 | 2015-11-11 16:22:45 -0600 | [diff] [blame^] | 152 | rm -f $(DESTDIR)/$(SBINDIR)/fsck.vfat |
bigbiff bigbiff | 9c75405 | 2013-01-09 09:09:08 -0500 | [diff] [blame] | 153 | rm -f $(DESTDIR)/$(MANDIR)/man8/fsck.vfat.8 |
bigbiff bigbiff | 9c75405 | 2013-01-09 09:09:08 -0500 | [diff] [blame] | 154 | |
Matt Mower | 18794c8 | 2015-11-11 16:22:45 -0600 | [diff] [blame^] | 155 | rm -f $(DESTDIR)/$(SBINDIR)/mkdosfs |
| 156 | rm -f $(DESTDIR)/$(MANDIR)/man8/mkdosfs.8 |
| 157 | rm -f $(DESTDIR)/$(SBINDIR)/mkfs.msdos |
| 158 | rm -f $(DESTDIR)/$(MANDIR)/man8/mkfs.msdos.8 |
| 159 | rm -f $(DESTDIR)/$(SBINDIR)/mkfs.vfat |
| 160 | rm -f $(DESTDIR)/$(MANDIR)/man8/mkfs.vfat.8 |
bigbiff bigbiff | 9c75405 | 2013-01-09 09:09:08 -0500 | [diff] [blame] | 161 | |
| 162 | reinstall: distclean install |
| 163 | |
| 164 | clean: |
| 165 | rm -f *.o |
| 166 | |
| 167 | distclean: clean |
Matt Mower | 18794c8 | 2015-11-11 16:22:45 -0600 | [diff] [blame^] | 168 | rm -f fatlabel fsck.fat mkfs.fat |
bigbiff bigbiff | 9c75405 | 2013-01-09 09:09:08 -0500 | [diff] [blame] | 169 | |
Matt Mower | 18794c8 | 2015-11-11 16:22:45 -0600 | [diff] [blame^] | 170 | .PHONY: build rebuild install install-bin install-doc install-man install-symlinks uninstall uninstall-bin uninstall-doc uninstall-man uninstall-symlinks reinstall clean distclean |