metastore.txt: Create plain-text version of the manual page.
[metastore.git] / Makefile
blob8e6a48c959a3ab3bc0e90f10e7314bf914ea756b
2 # Copyright (C) 2007 David Härdeman <david@hardeman.nu>
4 # This program is free software; you can redistribute it and/or modify it
5 # under the terms of the GNU General Public License as published by the
6 # Free Software Foundation; only version 2 of the License is applicable.
8 # This program is distributed in the hope that it will be useful, but
9 # WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 # General Public License for more details.
13 # You should have received a copy of the GNU General Public License along
14 # with this program; if not, write to the Free Software Foundation, Inc.,
15 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 # Generic settings
20 PROJ_DIR := $(dir $(lastword $(MAKEFILE_LIST)))
21 METASTORE_VER := $(shell "$(PROJ_DIR)"/version.sh)
22 UNAME_S := $(shell uname -s)
24 CC = gcc
25 CFLAGS += -g -Wall -pedantic -std=c99 -D_FILE_OFFSET_BITS=64 -O2
26 CFLAGS += -DMETASTORE_VER="\"$(METASTORE_VER)\""
27 LDFLAGS +=
29 ifeq ($(findstring BSD,$(UNAME_S)),)
30 ifneq (DragonFly,$(UNAME_S))
31 ifneq (Darwin,$(UNAME_S))
32 LIBS += -lbsd
33 endif
34 endif
35 endif
37 INCLUDES =
38 INSTALL = install
39 INSTALL_PROGRAM = ${INSTALL} -c
40 INSTALL_DATA = ${INSTALL} -c -m 644
41 COMPILE = $(CC) $(INCLUDES) $(CFLAGS) $(CPPFLAGS)
42 LINK = $(CC) $(CFLAGS) $(LDFLAGS)
43 OBJECTS = utils.o metastore.o metaentry.o
44 HEADERS = utils.h metastore.h metaentry.h
45 MANPAGES = man1/metastore.1
47 SRCS_DIR := $(PROJ_DIR)src/
48 MANS_DIR := $(PROJ_DIR)
50 DESTDIR ?=
51 PREFIX = /usr/local
52 EXECPREFIX = $(PREFIX)
53 DATAROOTDIR = ${PREFIX}/share
54 BINDIR = ${EXECPREFIX}/bin
55 MANDIR = ${DATAROOTDIR}/man
57 vpath %.c $(SRCS_DIR)
58 vpath %.h $(SRCS_DIR)
59 vpath %.1 $(MANS_DIR)
62 # Targets
65 all: metastore
66 .DEFAULT: all
69 %.o: %.c $(HEADERS)
70 $(COMPILE) -o $@ -c $<
73 metastore: $(OBJECTS)
74 $(LINK) -o $@ $^ $(LIBS)
77 metastore.txt: $(MANPAGES)
78 groff -mandoc -Kutf8 -Tutf8 $^ | col -bx >$@
81 install: all $(MANPAGES)
82 $(INSTALL) -d $(DESTDIR)$(MANDIR)/man1/
83 $(INSTALL_DATA) $(filter %.1,$^) $(DESTDIR)$(MANDIR)/man1/
84 $(INSTALL) -d $(DESTDIR)$(BINDIR)/
85 $(INSTALL_PROGRAM) metastore $(DESTDIR)$(BINDIR)/
88 uninstall:
89 - rm -f $(addprefix $(DESTDIR)$(MANDIR)/,$(MANPAGES))
90 - rm -f $(DESTDIR)$(BINDIR)/metastore
93 clean:
94 - rm -f *.o metastore
97 .PHONY: install uninstall clean all