Skip to content

Commit

Permalink
Changes to Makefile library dependencies
Browse files Browse the repository at this point in the history
It now uses pkg-config to get the exiv2 compiler flags and only
runs pkg-config one time instead of for every compiled file.
Also, the command-line tool no longer links against the GUI
libraries.
  • Loading branch information
dfandrich committed Sep 1, 2012
1 parent a52c046 commit bf5bc40
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 14 deletions.
23 changes: 15 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,13 @@ CXX = g++
COBJS = main-command.o unixtime.o gpx-read.o correlate.o exif-gps.o
GOBJS = main-gui.o gui.o unixtime.o gpx-read.o correlate.o exif-gps.o
CFLAGS = -Wall -O2
override CFLAGS += $(shell pkg-config --cflags libxml-2.0 gtk+-2.0) -I/usr/include/exiv2
OFLAGS = -Wall -O2
override OFLAGS += $(shell pkg-config --libs libxml-2.0 gtk+-2.0) -lm -lexiv2
CFLAGSINC := $(shell pkg-config --cflags libxml-2.0 exiv2)
# Add the gtk+ flags only when building the GUI
gpscorrelate-gui: CFLAGSINC += $(shell pkg-config --cflags gtk+-2.0)
LDFLAGS = -Wall -O2
LDFLAGSALL := $(shell pkg-config --libs libxml-2.0 exiv2) -lm
LDFLAGSGUI := $(shell pkg-config --libs gtk+-2.0)

prefix = /usr/local
bindir = $(prefix)/bin
datadir = $(prefix)/share
Expand All @@ -21,21 +25,24 @@ applicationsdir = $(datadir)/applications

DEFS = -DPACKAGE_VERSION=\"$(PACKAGE_VERSION)\"

TARGETS = gpscorrelate gpscorrelate-gui gpscorrelate.1
TARGETS = gpscorrelate-gui gpscorrelate gpscorrelate.1

all: $(TARGETS)

gpscorrelate: $(COBJS)
$(CXX) $(OFLAGS) -o $@ $(COBJS)
$(CXX) -o $@ $(COBJS) $(LDFLAGS) $(LDFLAGSALL)

gpscorrelate-gui: $(GOBJS)
$(CXX) $(OFLAGS) -o $@ $(GOBJS)
$(CXX) -o $@ $(GOBJS) $(LDFLAGS) $(LDFLAGSGUI) $(LDFLAGSALL)

.c.o:
$(CC) $(CFLAGS) $(DEFS) -c -o $*.o $<
$(CC) $(CFLAGS) $(CFLAGSINC) $(DEFS) -c -o $@ $<

.cpp.o:
$(CXX) $(CFLAGS) $(DEFS) -c -o $*.o $<
$(CXX) $(CFLAGS) $(CFLAGSINC) $(DEFS) -c -o $@ $<

# Hack to recompile everything if a header changes
*.o: *.h

clean:
rm -f *.o gpscorrelate{,.exe} gpscorrelate-gui{,.exe} doc/gpscorrelate-manpage.xml $(TARGETS)
Expand Down
6 changes: 3 additions & 3 deletions Makefile.mingw32
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Makefile for gpscorrelate
# Makefile for gpscorrelate for cross-compiling with MinGW32
# Written by Daniel Foote.

CC = i486-mingw32-gcc
Expand All @@ -18,10 +18,10 @@ gpscorrelate-gui.exe: $(GOBJS)
$(CXX) -o $@ $(GOBJS) $(OFLAGS)

.c.o:
$(CC) $(CFLAGS) -c -o $*.o $<
$(CC) $(CFLAGS) -c -o $@ $<

.cpp.o:
$(CXX) $(CFLAGS) -c -o $*.o $<
$(CXX) $(CFLAGS) -c -o $@ $<

clean:
rm -f *.o gpscorrelate{,.exe} gpscorrelate-gui{,.exe}
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ So I wrote my own. A little bit of C, a little bit of C++, a shade of GTK+, and
To build, you will need:

* The Exiv2 library (C++ EXIF tag handling): http://www.exiv2.org/
* libxml
* GTK+ (if compiling the GUI).
* libxml2 (XML parsing): http://www.xmlsoft.org/
* GTK+ (if compiling the GUI): http://www.gtk.org

You can build the command line version and the GUI together simply with
"make". There is presently no "make install".
"make" and install it with "sudo make install"

## Release History

Expand Down
2 changes: 2 additions & 0 deletions RELEASES
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,5 @@ v1.X: TBD
been touched)
- Store GPS coordinates in such a way as to preserve the number of
significant figures of the original data
- Use pkg-config to get the exiv2 compiler flags when building
- Renamed OFLAGS to LDFLAGS which is a more common name

0 comments on commit bf5bc40

Please sign in to comment.