blob: fa993559c146df106852f14ab8d3ce549b589638 [file] [log] [blame]
bigbiff bigbiff9c754052013-01-09 09:09:08 -05001# Makefile
2#
Matt Mower18794c82015-11-11 16:22:45 -06003# Copyright (C) 2008-2014 Daniel Baumann <mail@daniel-baumann.ch>
bigbiff bigbiff9c754052013-01-09 09:09:08 -05004#
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 Mower18794c82015-11-11 16:22:45 -060018# The complete text of the GNU General Public License
bigbiff bigbiff9c754052013-01-09 09:09:08 -050019# can be found in /usr/share/common-licenses/GPL-3 file.
20
Matt Mower18794c82015-11-11 16:22:45 -060021SHELL := sh -e
22LANGUAGES = $(shell cd manpages/po && ls)
23
bigbiff bigbiff9c754052013-01-09 09:09:08 -050024DESTDIR =
25PREFIX = /usr/local
26SBINDIR = $(PREFIX)/sbin
27DOCDIR = $(PREFIX)/share/doc
28MANDIR = $(PREFIX)/share/man
29
30#OPTFLAGS = -O2 -fomit-frame-pointer -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
Matt Mower18794c82015-11-11 16:22:45 -060031OPTFLAGS = -O2 -fomit-frame-pointer -D_GNU_SOURCE $(shell getconf LFS_CFLAGS)
bigbiff bigbiff9c754052013-01-09 09:09:08 -050032#WARNFLAGS = -Wall -pedantic -std=c99
Matt Mower18794c82015-11-11 16:22:45 -060033WARNFLAGS = -Wall -Wextra -Wno-sign-compare -Wno-missing-field-initializers -Wmissing-prototypes -Wstrict-prototypes -Wwrite-strings
bigbiff bigbiff9c754052013-01-09 09:09:08 -050034DEBUGFLAGS = -g
35CFLAGS += $(OPTFLAGS) $(WARNFLAGS) $(DEBUGFLAGS)
36
37VPATH = src
38
39all: build
40
Matt Mower18794c82015-11-11 16:22:45 -060041build: fatlabel fsck.fat mkfs.fat
bigbiff bigbiff9c754052013-01-09 09:09:08 -050042
Matt Mower18794c82015-11-11 16:22:45 -060043fatlabel: boot.o check.o common.o fat.o file.o io.o lfn.o fatlabel.o
bigbiff bigbiff9c754052013-01-09 09:09:08 -050044
Matt Mower18794c82015-11-11 16:22:45 -060045fsck.fat: boot.o check.o common.o fat.o file.o io.o lfn.o fsck.fat.o
bigbiff bigbiff9c754052013-01-09 09:09:08 -050046
Matt Mower18794c82015-11-11 16:22:45 -060047mkfs.fat: mkfs.fat.o
bigbiff bigbiff9c754052013-01-09 09:09:08 -050048
49rebuild: distclean build
50
Matt Mower18794c82015-11-11 16:22:45 -060051install: install-bin install-doc install-man install-symlinks
bigbiff bigbiff9c754052013-01-09 09:09:08 -050052
53install-bin: build
54 install -d -m 0755 $(DESTDIR)/$(SBINDIR)
Matt Mower18794c82015-11-11 16:22:45 -060055 install -m 0755 fatlabel fsck.fat mkfs.fat $(DESTDIR)/$(SBINDIR)
bigbiff bigbiff9c754052013-01-09 09:09:08 -050056
57install-doc:
58 install -d -m 0755 $(DESTDIR)/$(DOCDIR)/dosfstools
59 install -p -m 0644 ChangeLog doc/* $(DESTDIR)/$(DOCDIR)/dosfstools
60
61install-man:
Matt Mower18794c82015-11-11 16:22:45 -060062 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 bigbiff9c754052013-01-09 09:09:08 -050068
Matt Mower18794c82015-11-11 16:22:45 -060069 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
78install-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 bigbiff9c754052013-01-09 09:09:08 -050087
Matt Mower18794c82015-11-11 16:22:45 -060088 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
114uninstall: uninstall-symlinks uninstall-man uninstall-doc uninstall-bin
bigbiff bigbiff9c754052013-01-09 09:09:08 -0500115
116uninstall-bin:
Matt Mower18794c82015-11-11 16:22:45 -0600117 rm -f $(DESTDIR)/$(SBINDIR)/fatlabel
118 rm -f $(DESTDIR)/$(SBINDIR)/fsck.fat
119 rm -f $(DESTDIR)/$(SBINDIR)/mkfs.fat
bigbiff bigbiff9c754052013-01-09 09:09:08 -0500120
121 rmdir --ignore-fail-on-non-empty $(DESTDIR)/$(SBINDIR)
122
123uninstall-doc:
124 rm -rf $(DESTDIR)/$(DOCDIR)/dosfstools
125
126 rmdir --ignore-fail-on-non-empty $(DESTDIR)/$(DOCDIR)
127
128uninstall-man:
Matt Mower18794c82015-11-11 16:22:45 -0600129 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
144uninstall-symlinks:
145 rm -f $(DESTDIR)/$(SBINDIR)/dosfslabel
bigbiff bigbiff9c754052013-01-09 09:09:08 -0500146 rm -f $(DESTDIR)/$(MANDIR)/man8/dosfslabel.8
bigbiff bigbiff9c754052013-01-09 09:09:08 -0500147
Matt Mower18794c82015-11-11 16:22:45 -0600148 rm -f $(DESTDIR)/$(SBINDIR)/dosfsck
149 rm -f $(DESTDIR)/$(MANDIR)/man8/dosfsck.8
150 rm -f $(DESTDIR)/$(SBINDIR)/fsck.msdos
bigbiff bigbiff9c754052013-01-09 09:09:08 -0500151 rm -f $(DESTDIR)/$(MANDIR)/man8/fsck.msdos.8
Matt Mower18794c82015-11-11 16:22:45 -0600152 rm -f $(DESTDIR)/$(SBINDIR)/fsck.vfat
bigbiff bigbiff9c754052013-01-09 09:09:08 -0500153 rm -f $(DESTDIR)/$(MANDIR)/man8/fsck.vfat.8
bigbiff bigbiff9c754052013-01-09 09:09:08 -0500154
Matt Mower18794c82015-11-11 16:22:45 -0600155 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 bigbiff9c754052013-01-09 09:09:08 -0500161
162reinstall: distclean install
163
164clean:
165 rm -f *.o
166
167distclean: clean
Matt Mower18794c82015-11-11 16:22:45 -0600168 rm -f fatlabel fsck.fat mkfs.fat
bigbiff bigbiff9c754052013-01-09 09:09:08 -0500169
Matt Mower18794c82015-11-11 16:22:45 -0600170.PHONY: build rebuild install install-bin install-doc install-man install-symlinks uninstall uninstall-bin uninstall-doc uninstall-man uninstall-symlinks reinstall clean distclean