--- src/Makefile 2005/06/12 05:54:57 581 +++ src/Makefile 2005/10/10 14:45:33 640 @@ -30,7 +30,7 @@ # # This makefile contains (supposedly) generic build rules to build the # library and applications. It includes all system specific settings -# from config.mk. The idea is that configuring and porting the +# from config.mk. The idea is that configuring and porting the # software to a new platform should only require changes in config.mk. # # Restrictions: @@ -48,25 +48,25 @@ # Source files # Add standalone C++ header files to this list -CCHDR = exv_conf.h exv_msvc.h mn.hpp rcsid.hpp +CCHDR = exv_conf.h exv_msvc.h mn.hpp rcsid.hpp # Add library C++ source files to this list -CCSRC = basicio.cpp canonmn.cpp datasets.cpp error.cpp exif.cpp futils.cpp \ - fujimn.cpp ifd.cpp image.cpp iptc.cpp jpgimage.cpp makernote.cpp \ - metadatum.cpp nikonmn.cpp olympusmn.cpp panasonicmn.cpp sigmamn.cpp \ - sonymn.cpp tags.cpp types.cpp value.cpp +CCSRC = basicio.cpp canonmn.cpp datasets.cpp error.cpp exif.cpp \ + futils.cpp fujimn.cpp ifd.cpp image.cpp iptc.cpp jpgimage.cpp \ + makernote.cpp metadatum.cpp nikonmn.cpp olympusmn.cpp panasonicmn.cpp \ + sigmamn.cpp sonymn.cpp tags.cpp types.cpp value.cpp # Add source files of simple applications to this list BINSRC = addmoddel.cpp dataarea-test.cpp exifcomment.cpp exifdata-test.cpp \ exifprint.cpp ifd-test.cpp iotest.cpp iptceasy.cpp iptcprint.cpp \ iptctest.cpp key-test.cpp makernote-test.cpp taglist.cpp write-test.cpp \ - write2-test.cpp + write2-test.cpp # Main source file of the Exiv2 application EXIV2MAIN = exiv2.cpp # Add additional source files of the Exiv2 application to this list -EXIV2SRC = actions.cpp utils.cpp +EXIV2SRC = actions.cpp utils.cpp # C source files of the Exiv2 application ifndef HAVE_TIMEGM EXIVCSRC = localtime.c @@ -110,15 +110,18 @@ HDR = $(CCHDR) OBJ = $(CCOBJ) LOBJ = $(CCLOBJ) -DEP = $(CCSRC:%.cpp=.%.d) $(BINSRC:%.cpp=.%.d) \ - $(EXIV2MAIN:%.cpp=.%.d) $(EXIV2SRC:%.cpp=.%.d) $(EXIVCSRC:%.c=.%.d) \ - $(MCMAIN:%.cpp=.%.d) $(MCSRC:%.cpp=.%.d) + +DEPDIR = .deps +DEP = $(CCSRC:%.cpp=$(DEPDIR)/%.d) $(BINSRC:%.cpp=$(DEPDIR)/%.d) \ + $(EXIV2MAIN:%.cpp=$(DEPDIR)/%.d) $(EXIV2SRC:%.cpp=$(DEPDIR)/%.d) \ + $(EXIVCSRC:%.c=$(DEPDIR)/%.d) $(MCMAIN:%.cpp=$(DEPDIR)/%.d) \ + $(MCSRC:%.cpp=$(DEPDIR)/%.d) $(DEPDIR)/path-test.d BINOBJ = $(BINSRC:.cpp=.o) BINARY = $(BINSRC:.cpp=) EXECUTABLE = $(BINSRC:.cpp=$(EXEEXT)) -EXIV2OBJ = $(EXIV2MAIN:.cpp=.o) $(EXIV2SRC:.cpp=.o) +EXIV2OBJ = $(EXIV2MAIN:.cpp=.o) $(EXIV2SRC:.cpp=.o) EXIV2COBJ = $(EXIVCSRC:.c=.o) EXIV2BIN = $(EXIV2MAIN:.cpp=) EXIV2EXE = $(EXIV2MAIN:.cpp=$(EXEEXT)) @@ -127,44 +130,38 @@ MCBIN = $(MCMAIN:.cpp=) MCEXE = $(MCMAIN:.cpp=$(EXEEXT)) -# ****************************************************************************** -# Include `.*.d' files, but only if we need them, -# i.e., if no target was given... -ifeq ($(strip $(MAKECMDGOALS)),) --include $(DEP) -else -# ...or the target is _not_ one in the list of targets below. -NOINCLUDE = uninstall uninstall-lib check doc ctags mostlyclean clean \ - install-header uninstall-header distclean maintainer-clean exv_conf.h -ifneq ($(MAKECMDGOALS), $(filter $(MAKECMDGOALS), $(NOINCLUDE))) --include $(DEP) -endif -endif +# Dependency files post-process commands +POSTDEPEND = if test ! -d $(DEPDIR); then mkdir $(DEPDIR); fi; \ + if test -e $*.d; then cp $*.d $(DEPDIR)/$*.d; \ + sed -e 's/^\#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \ + -e '/^$$/ d' -e 's/$$/ :/' < $*.d >> $(DEPDIR)/$*.d; \ + $(RM) $*.d; fi + +# Compilation shortcuts +COMPILE.cc = $(CXX) $(CXXFLAGS) $(CXXDEFS) $(CXXINCS) -c +COMPILE.c = $(CC) $(CFLAGS) $(DEFS) $(INCS) -c +LINK.cc = $(CXX) $(CXXFLAGS) $(LDLIBS) $(LDFLAGS) -rpath $(libdir) # ****************************************************************************** # Rules $(OBJ): %.o: %.cpp - @$(LIBTOOL) --mode=compile $(CXX) $(CXXFLAGS) $(CXXDEFS) $(CXXINCS) -c $< - -$(sort $(BINOBJ) $(EXIV2OBJ) $(MCOBJ)): %.o: %.cpp - $(CXX) $(CXXFLAGS) $(CXXDEFS) $(CXXINCS) -c $< + @$(LIBTOOL) --mode=compile $(COMPILE.cc) -o $@ $< + @$(MAKEDEPEND) + @$(POSTDEPEND) + +$(sort $(BINOBJ) $(EXIV2OBJ) $(MCOBJ) path-test.o): %.o: %.cpp + $(COMPILE.cc) -o $@ $< + @$(MAKEDEPEND) + @$(POSTDEPEND) %.o: %.c - $(CC) $(CFLAGS) $(DEFS) $(INCS) -c $< + $(COMPILE.c) -o $@ $< + @$(MAKEDEPEND) + @$(POSTDEPEND) %.ii: %.cpp set -e; \ - $(CXXCPP) $(CPPFLAGS) $(CXXDEFS) $(CXXINCS) $< \ - | sed '/^[ ]*$$/d' > $@ - -# generate a makefile with the prerequisites for each source file -# (see `info make' for details) -.%.d: %.cpp - @echo generating $@ - @set -e; \ - $(CXXDEP) $(CPPFLAGS) $(CXXDEFS) $(CXXINCS) $< \ - | sed 's/\($*\)\.o[ :]*/\1.o $@ : /' > $@; \ - [ -s $@ ] || $(RM) $@ + $(CXXCPP) $(CPPFLAGS) $(CXXDEFS) $(CXXINCS) $< | sed '/^[ ]*$$/d' > $@ # ****************************************************************************** # Targets @@ -173,8 +170,10 @@ install install-header install-lib \ uninstall uninstall-header uninstall-lib -types.hpp: exv_conf.h -actions.cpp exiv2.cpp image.cpp utils.cpp: exv_conf.h +# Include targets from dependency files +-include $(DEP) + +actions.cpp basicio.cpp exif.cpp exiv2.cpp futils.cpp image.cpp jpgimage.cpp utils.cpp: exv_conf.h exv_conf.h: $(top_srcdir)/config/config.h sed 's/#define \([A-Z]\)/#define EXV_\1/; s/#undef \([A-Z]\)/#undef EXV_\1/' < $< > $@ @@ -185,52 +184,52 @@ bin: lib $(BINARY) $(EXIV2BIN) $(MCBIN) path-test lib: $(OBJ) - $(LIBTOOL) --mode=link $(CXX) $(LDFLAGS) $(LOBJ) -o $(LIBRARY) -rpath $(libdir) -release $(EXIV2_VERSION) + $(LIBTOOL) --mode=link $(CXX) $(LDFLAGS) $(LOBJ) -o $(LIBRARY) -rpath $(libdir) -release $(EXIV2_VERSION) @touch lib path-test: path-test.o utils.o $(CXX) $(CXXFLAGS) path-test.o utils.o -o $@ $(BINARY): %: %.o lib - @$(LIBTOOL) --mode=link $(CXX) $(CXXFLAGS) $(LDLIBS) $@.o $(LDFLAGS) -o $@ -rpath $(libdir) + @$(LIBTOOL) --mode=link $(LINK.cc) -o $@ $@.o $(EXIV2BIN): lib $(EXIV2OBJ) $(EXIV2COBJ) - @$(LIBTOOL) --mode=link $(CXX) $(CXXFLAGS) $(EXIV2OBJ) $(EXIV2COBJ) $(LDLIBS) $(LDFLAGS) -o $@ -rpath $(libdir) + @$(LIBTOOL) --mode=link $(LINK.cc) -o $@ $(EXIV2OBJ) $(EXIV2COBJ) $(MCBIN): lib $(MCOBJ) - @$(LIBTOOL) --mode=link $(CXX) $(CXXFLAGS) $(MCOBJ) $(LDLIBS) $(LDFLAGS) -o $@ -rpath $(libdir) + @$(LIBTOOL) --mode=link $(LINK.cc) -o $@ $(MCOBJ) install-header: - $(INSTALL_DIRS) $(incdir) + $(INSTALL_DIRS) $(DESTDIR)$(incdir) @list='$(HDR)'; for p in $$list; do \ if test -f $$p; then \ - echo "$(INSTALL_DATA) $$p $(incdir)/$$p"; \ - $(INSTALL_DATA) $$p $(incdir)/$$p; \ + echo "$(INSTALL_DATA) $$p $(DESTDIR)$(incdir)/$$p"; \ + $(INSTALL_DATA) $$p $(DESTDIR)$(incdir)/$$p; \ else :; fi; \ done install-lib: lib install-header - $(INSTALL_DIRS) $(libdir) - @$(LIBTOOL) --mode=install $(INSTALL_DATA) $(LIBRARY) $(libdir)/$(LIBRARY) + $(INSTALL_DIRS) $(DESTDIR)$(libdir) + @$(LIBTOOL) --mode=install $(INSTALL_DATA) $(LIBRARY) $(DESTDIR)$(libdir)/$(LIBRARY) install: $(EXIV2BIN) install-lib - $(INSTALL_DIRS) $(bindir) - @$(LIBTOOL) --mode=install $(INSTALL_PROGRAM) $(EXIV2EXE) $(bindir)/$(EXIV2EXE) + $(INSTALL_DIRS) $(DESTDIR)$(bindir) + @$(LIBTOOL) --mode=install $(INSTALL_PROGRAM) $(EXIV2EXE) $(DESTDIR)$(bindir)/$(EXIV2EXE) uninstall-header: @list='$(HDR)'; for p in $$list; do \ - echo "$(RM) $(incdir)/$$p"; \ - $(RM) $(incdir)/$$p; \ + echo "$(RM) $(DESTDIR)$(incdir)/$$p"; \ + $(RM) $(DESTDIR)$(incdir)/$$p; \ done - -rmdir $(incdir) + -rmdir $(DESTDIR)$(incdir) uninstall-lib: uninstall-header - @$(LIBTOOL) --mode=uninstall $(RM) $(libdir)/$(LIBRARY) - -rmdir $(libdir) + @$(LIBTOOL) --mode=uninstall $(RM) $(DESTDIR)$(libdir)/$(LIBRARY) + -rmdir $(DESTDIR)$(libdir) uninstall: uninstall-lib - @$(LIBTOOL) --mode=uninstall $(RM) $(bindir)/$(EXIV2EXE) - -rmdir $(bindir) + @$(LIBTOOL) --mode=uninstall $(RM) $(DESTDIR)$(bindir)/$(EXIV2EXE) + -rmdir $(DESTDIR)$(bindir) ctags: ebrowse $(CCHDR) $(CCSRC) @@ -245,6 +244,7 @@ $(RM) $(CCSRC:.cpp=.ii) $(RM) lib $(RM) path-test.o + $(RM) $(CCSRC:%.cpp=.libs/%.d) @$(LIBTOOL) --mode=clean $(RM) $(LOBJ) $(sort $(BINOBJ) $(EXIV2OBJ) $(EXIV2COBJ) $(MCOBJ)) clean: mostlyclean @@ -256,10 +256,11 @@ # files created by configuring the program. distclean: clean $(RM) exv_conf.h + $(RM) $(DEP) + -rmdir $(DEPDIR) $(RM) tags TAGS $(RM) *~ *.bak *# # This command is intended for maintainers to use; it deletes files # that may need special tools to rebuild. maintainer-clean: uninstall distclean - $(RM) $(DEP)