From 705e60496b1ac336e4d932cfc3b6652a6804ae9e Mon Sep 17 00:00:00 2001 From: Thomas Friebel Date: Fri, 8 Mar 2013 22:14:08 +0100 Subject: [PATCH 1/4] Allow overriding Makefile variables from the command line --- src/Makefile | 6 +++--- tools/Makefile | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Makefile b/src/Makefile index 16c3e97..7996688 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,7 +1,7 @@ -CXX = g++ -CXXFLAGS = -O3 -AR = ar +CXX ?= g++ +CXXFLAGS ?= -O3 +AR ?= ar all: libosmpbf.a ../include/osmpbf/fileformat.pb.h ../include/osmpbf/osmformat.pb.h diff --git a/tools/Makefile b/tools/Makefile index b9fc26b..db134fc 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -1,7 +1,7 @@ -CXX = g++ -CXXFLAGS = -g -I../include -LDFLAGS = -L../src -lpthread -lz -lprotobuf-lite -losmpbf +CXX ?= g++ +CXXFLAGS ?= -g -I../include +LDFLAGS ?= -L../src -lpthread -lz -lprotobuf-lite -losmpbf all: osmpbf-outline From 2b7a3329573aabc5630a37294827a4eedd23f71f Mon Sep 17 00:00:00 2001 From: Thomas Friebel Date: Fri, 8 Mar 2013 22:14:59 +0100 Subject: [PATCH 2/4] Allow overriding protoc path from the command line --- src/Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Makefile b/src/Makefile index 7996688..bb8d035 100644 --- a/src/Makefile +++ b/src/Makefile @@ -2,6 +2,7 @@ CXX ?= g++ CXXFLAGS ?= -O3 AR ?= ar +PROTOC ?= protoc all: libosmpbf.a ../include/osmpbf/fileformat.pb.h ../include/osmpbf/osmformat.pb.h @@ -12,7 +13,7 @@ libosmpbf.a: fileformat.pb.o osmformat.pb.o $(CXX) $(CXXFLAGS) -c -o $@ $< %.pb.cc ../include/osmpbf/%.pb.h: %.proto - protoc --proto_path=. --cpp_out=. $< + $(PROTOC) --proto_path=. --cpp_out=. $< cp *.pb.h ../include/osmpbf/ install: From 1cbcd0078eccac78732b409712a215d87f56e903 Mon Sep 17 00:00:00 2001 From: Thomas Friebel Date: Fri, 8 Mar 2013 22:27:09 +0100 Subject: [PATCH 3/4] Install to /usr/local per default --- src/Makefile | 13 +++++++------ tools/Makefile | 5 +++-- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/Makefile b/src/Makefile index bb8d035..aea692f 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,4 +1,5 @@ +DESTDIR ?= /usr/local CXX ?= g++ CXXFLAGS ?= -O3 AR ?= ar @@ -17,12 +18,12 @@ libosmpbf.a: fileformat.pb.o osmformat.pb.o cp *.pb.h ../include/osmpbf/ install: - install -m 755 -g root -o root -d $(DESTDIR)/usr/lib - install -m 644 -g root -o root libosmpbf.a $(DESTDIR)/usr/lib - install -m 755 -g root -o root -d $(DESTDIR)/usr/include/osmpbf - install -m 644 -g root -o root ../include/osmpbf/osmpbf.h $(DESTDIR)/usr/include/osmpbf - install -m 644 -g root -o root ../include/osmpbf/fileformat.pb.h $(DESTDIR)/usr/include/osmpbf - install -m 644 -g root -o root ../include/osmpbf/osmformat.pb.h $(DESTDIR)/usr/include/osmpbf + install -m 755 -g root -o root -d $(DESTDIR)/lib + install -m 644 -g root -o root libosmpbf.a $(DESTDIR)/lib + install -m 755 -g root -o root -d $(DESTDIR)/include/osmpbf + install -m 644 -g root -o root ../include/osmpbf/osmpbf.h $(DESTDIR)/include/osmpbf + install -m 644 -g root -o root ../include/osmpbf/fileformat.pb.h $(DESTDIR)/include/osmpbf + install -m 644 -g root -o root ../include/osmpbf/osmformat.pb.h $(DESTDIR)/include/osmpbf clean: rm -f *.pb.h *.pb.cc *.pb.o libosmpbf.a diff --git a/tools/Makefile b/tools/Makefile index db134fc..9112867 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -1,4 +1,5 @@ +DESTDIR ?= /usr/local CXX ?= g++ CXXFLAGS ?= -g -I../include LDFLAGS ?= -L../src -lpthread -lz -lprotobuf-lite -losmpbf @@ -9,8 +10,8 @@ osmpbf-outline: osmpbf-outline.cpp $(CXX) $(CXXFLAGS) -o $@ $< $(LDFLAGS) install: - install -m 755 -g root -o root -d $(DESTDIR)/usr/bin - install -m 644 -g root -o root -s osmpbf-outline $(DESTDIR)/usr/bin + install -m 755 -g root -o root -d $(DESTDIR)/bin + install -m 644 -g root -o root -s osmpbf-outline $(DESTDIR)/bin clean: rm -f osmpbf-outline From b8266ac09f73169202a66db086c9a03bbbb77c0a Mon Sep 17 00:00:00 2001 From: Thomas Friebel Date: Fri, 8 Mar 2013 22:24:11 +0100 Subject: [PATCH 4/4] Do not set file user:group to 'root:root' during installation When run as root, files will be 'root:root' anyway. When run as user changing user:group will fail. Furthermore, the group 'root' is not available on all systems. --- src/Makefile | 12 ++++++------ tools/Makefile | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Makefile b/src/Makefile index aea692f..e850edd 100644 --- a/src/Makefile +++ b/src/Makefile @@ -18,12 +18,12 @@ libosmpbf.a: fileformat.pb.o osmformat.pb.o cp *.pb.h ../include/osmpbf/ install: - install -m 755 -g root -o root -d $(DESTDIR)/lib - install -m 644 -g root -o root libosmpbf.a $(DESTDIR)/lib - install -m 755 -g root -o root -d $(DESTDIR)/include/osmpbf - install -m 644 -g root -o root ../include/osmpbf/osmpbf.h $(DESTDIR)/include/osmpbf - install -m 644 -g root -o root ../include/osmpbf/fileformat.pb.h $(DESTDIR)/include/osmpbf - install -m 644 -g root -o root ../include/osmpbf/osmformat.pb.h $(DESTDIR)/include/osmpbf + install -m 755 -d $(DESTDIR)/lib + install -m 644 libosmpbf.a $(DESTDIR)/lib + install -m 755 -d $(DESTDIR)/include/osmpbf + install -m 644 ../include/osmpbf/osmpbf.h $(DESTDIR)/include/osmpbf + install -m 644 ../include/osmpbf/fileformat.pb.h $(DESTDIR)/include/osmpbf + install -m 644 ../include/osmpbf/osmformat.pb.h $(DESTDIR)/include/osmpbf clean: rm -f *.pb.h *.pb.cc *.pb.o libosmpbf.a diff --git a/tools/Makefile b/tools/Makefile index 9112867..a4e3ab4 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -10,8 +10,8 @@ osmpbf-outline: osmpbf-outline.cpp $(CXX) $(CXXFLAGS) -o $@ $< $(LDFLAGS) install: - install -m 755 -g root -o root -d $(DESTDIR)/bin - install -m 644 -g root -o root -s osmpbf-outline $(DESTDIR)/bin + install -m 755 -d $(DESTDIR)/bin + install -m 644 -s osmpbf-outline $(DESTDIR)/bin clean: rm -f osmpbf-outline