1# ************************************************************* -*- Makefile -*-
2#
3# Copyright (C) 2004-2015 Andreas Huggel <ahuggel@gmx.net>
4#
5# This Makefile is part of the Exiv2 distribution.
6#
7# Redistribution and use in source and binary forms, with or without
8# modification, are permitted provided that the following conditions
9# are met:
10#
11#    1. Redistributions of source code must retain the above copyright
12#       notice, this list of conditions and the following disclaimer.
13#    2. Redistributions in binary form must reproduce the above
14#       copyright notice, this list of conditions and the following
15#       disclaimer in the documentation and/or other materials provided
16#       with the distribution.
17#    3. The name of the author may not be used to endorse or promote
18#       products derived from this software without specific prior
19#       written permission.
20#
21# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
23# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
25# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
27# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
29# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
30# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
31# IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32#
33# File:      Makefile
34# Author(s): Andreas Huggel (ahu) <ahuggel@gmx.net>
35# History:   31-Jan-09, ahu: created
36#
37# Description:
38#  Simple Makefile to build the organize application. Requires installed
39#  exiv2 library and headers. Adapted from samples/Makefile.
40#
41# Restrictions:
42#  Requires GNU make.
43#
44
45# ******************************************************************************
46# Default make target
47all: ozbin
48
49# Include system configuration
50top_srcdir = ../..
51include $(top_srcdir)/config/config.mk
52include boost.mk
53
54# ******************************************************************************
55# Source files
56
57# Source files for the organize application
58OZMAIN = organize.cpp
59OZSRC  = helpers.cpp MD5.cpp
60
61# ******************************************************************************
62# Initialisations
63SHELL = /bin/sh
64
65.SUFFIXES:
66.SUFFIXES: .c .cpp .o .so
67
68.PRECIOUS: %.cpp
69
70CPPFLAGS := -I$(BOOST_INC_DIR) `pkg-config exiv2 --cflags`
71ifdef HAVE_STDINT
72	CPPFLAGS += -DEXV_HAVE_STDINT_H=1
73endif
74
75LDFLAGS := $(BOOST_LIBS) `pkg-config exiv2 --libs`
76
77OZOBJ = $(OZSRC:.cpp=.o) $(OZMAIN:.cpp=.o)
78OZBIN = $(OZMAIN:.cpp=)
79OZEXE = $(OZMAIN:.cpp=$(EXEEXT))
80
81ifdef DEP_TRACKING
82DEP = $(OZMAIN:%.cpp=$(DEPDIR)/%.d) $(OZSRC:%.cpp=$(DEPDIR)/%.d)
83endif
84
85# ******************************************************************************
86# Rules
87ozbin: $(OZBIN)
88
89$(OZOBJ): %.o: %.cpp
90	$(COMPILE.cc) -o $@ $<
91	@$(MAKEDEPEND)
92	@$(POSTDEPEND)
93
94%.ii: %.cpp
95	set -e; \
96	$(CXXCPP) -E $(CPPFLAGS) $< | sed '/^[ 	]*$$/d' > $@
97
98# ******************************************************************************
99# Targets
100.PHONY: all ozbin relink binclean install uninstall mostlyclean clean distclean maintainer-clean
101
102ifdef DEP_TRACKING
103# Include targets from dependency files
104-include $(DEP)
105endif
106
107$(OZBIN): $(OZOBJ)
108	$(LIBTOOL) --mode=link $(LINK.cc) -o $@ $(OZOBJ)
109
110relink: binclean organize
111
112install:
113	$(INSTALL_DIRS) $(DESTDIR)$(bindir)
114	@$(LIBTOOL) --mode=install $(INSTALL_PROGRAM) $(OZEXE) $(DESTDIR)$(bindir)/$(OZEXE)
115
116uninstall:
117	@$(LIBTOOL) --mode=uninstall $(RM) $(DESTDIR)$(bindir)/$(OZEXE)
118	-rmdir $(DESTDIR)$(bindir)
119
120# Remove binaries, e.g., to relink them
121binclean:
122	$(RM) $(OZEXE)
123
124mostlyclean:
125	$(RM) core
126	$(RM) $(OZMAIN:.cpp=.ii) $(OZSRC:.cpp=.ii)
127	$(RM) $(OZMAIN:%.cpp=.libs/%.d) $(OZSRC:%.cpp=.libs/%.d)
128	-rmdir .libs
129	$(RM) $(OZOBJ)
130
131clean: binclean mostlyclean
132
133# Run `make distclean' from the top source directory to also remove
134# files created by configuring the program.
135distclean: clean
136ifdef DEP_TRACKING
137	$(RM) $(DEP)
138	-rmdir $(DEPDIR)
139endif
140	$(RM) *~ *.bak *#
141
142# This command is intended for maintainers to use; it deletes files
143# that may need special tools to rebuild.
144maintainer-clean: uninstall distclean
145