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.
20 PROJ_DIR
:= $(dir $(lastword
$(MAKEFILE_LIST
)))
21 METASTORE_VER
:= $(shell "$(PROJ_DIR)"/version.sh
)
22 UNAME_S
:= $(shell uname
-s
)
25 CFLAGS
+= -g
-Wall
-pedantic
-std
=c99
-D_FILE_OFFSET_BITS
=64 -O2
26 CFLAGS
+= -DMETASTORE_VER
="\"$(METASTORE_VER)\""
29 ifeq ($(findstring BSD
,$(UNAME_S
)),)
30 ifneq (DragonFly
,$(UNAME_S
))
31 ifneq (Darwin
,$(UNAME_S
))
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 DOCFILES
= AUTHORS FILEFORMAT LICENSE.GPLv2 NEWS README metastore.txt
46 MANPAGES
= man1
/metastore
.1
48 SRCS_DIR
:= $(PROJ_DIR
)src
/
49 MANS_DIR
:= $(PROJ_DIR
)
50 DOCS_DIR
:= $(PROJ_DIR
)
54 EXECPREFIX
= $(PREFIX
)
55 DATAROOTDIR
= ${PREFIX}/share
56 BINDIR
= ${EXECPREFIX}/bin
57 DOCDIR
= ${DATAROOTDIR}/doc
/metastore
58 MANDIR
= ${DATAROOTDIR}/man
63 $(foreach file
,$(DOCFILES
),$(eval vpath
$(file
) $(DOCS_DIR
)))
74 $(COMPILE
) -o
$@
-c
$<
78 $(LINK
) -o
$@
$^
$(LIBS
)
81 metastore.txt
: $(MANPAGES
)
82 groff
-mandoc
-Kutf8
-Tutf8
$^ | col
-bx
>$@
85 install: all $(DOCFILES
) $(MANPAGES
)
86 $(INSTALL
) -d
$(DESTDIR
)$(DOCDIR
)/
87 $(INSTALL_DATA
) $(filter-out all %.1,$^
) $(DESTDIR
)$(DOCDIR
)
88 cp
-rf
$(DOCS_DIR
)examples
$(DESTDIR
)$(DOCDIR
)
89 $(INSTALL
) -d
$(DESTDIR
)$(MANDIR
)/man1
/
90 $(INSTALL_DATA
) $(filter %.1,$^
) $(DESTDIR
)$(MANDIR
)/man1
/
91 $(INSTALL
) -d
$(DESTDIR
)$(BINDIR
)/
92 $(INSTALL_PROGRAM
) metastore
$(DESTDIR
)$(BINDIR
)/
96 - rm -f
$(addprefix $(DESTDIR
)$(DOCDIR
)/,$(DOCFILES
))
97 - rm -rf
$(DESTDIR
)$(DOCDIR
)/examples
98 - rmdir
$(DESTDIR
)$(DOCDIR
)
99 - rm -f
$(addprefix $(DESTDIR
)$(MANDIR
)/,$(MANPAGES
))
100 - rm -f
$(DESTDIR
)$(BINDIR
)/metastore
104 - rm -f
*.o metastore
107 .PHONY
: install uninstall clean all