Merge pull request #32 from Alphix/master
[metastore.git] / Makefile
blob744293587fa3687c73a4a4ec17fe087ce491fdd2
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 CC = gcc
21 CFLAGS += -g -Wall -pedantic -std=c99 -D_FILE_OFFSET_BITS=64 -O2
22 LDFLAGS +=
23 LIBS += -lbsd
24 INCLUDES =
25 INSTALL = install
26 INSTALL_PROGRAM = ${INSTALL} -c
27 INSTALL_DATA = ${INSTALL} -c -m 644
28 COMPILE = $(CC) $(INCLUDES) $(CFLAGS) $(CPPFLAGS)
29 LINK = $(CC) $(CFLAGS) $(LDFLAGS)
30 OBJECTS = utils.o metastore.o metaentry.o
31 HEADERS = utils.h metastore.h metaentry.h
32 MANPAGES = man1/metastore.1
34 PROJ_DIR := $(dir $(lastword $(MAKEFILE_LIST)))
35 SRCS_DIR := $(PROJ_DIR)src/
36 MANS_DIR := $(PROJ_DIR)
38 DESTDIR ?=
39 prefix = /usr
40 usrbindir = ${prefix}/bin
41 mandir = ${prefix}/share/man
43 vpath %.c $(SRCS_DIR)
44 vpath %.h $(SRCS_DIR)
45 vpath %.1 $(MANS_DIR)
48 # Targets
51 all: metastore
52 .DEFAULT: all
55 %.o: %.c $(HEADERS)
56 $(COMPILE) -o $@ -c $<
59 metastore: $(OBJECTS)
60 $(LINK) -o $@ $^ $(LIBS)
63 install: all $(MANPAGES)
64 $(INSTALL) -d $(DESTDIR)$(mandir)/man1/
65 $(INSTALL_DATA) $(filter %.1,$^) $(DESTDIR)$(mandir)/man1/
66 $(INSTALL) -d $(DESTDIR)$(usrbindir)/
67 $(INSTALL_PROGRAM) metastore $(DESTDIR)$(usrbindir)/
70 uninstall:
71 - rm -f $(addprefix $(DESTDIR)$(mandir)/,$(MANPAGES))
72 - rm -f $(DESTDIR)$(usrbindir)/metastore
75 clean:
76 - rm -f *.o metastore
79 .PHONY: install uninstall clean all