Skip to content

Commit

Permalink
rationalize Makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
abeylot committed Feb 22, 2024
1 parent 7db3379 commit ae8b320
Showing 1 changed file with 53 additions and 126 deletions.
179 changes: 53 additions & 126 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,155 +4,82 @@ GIT_VERSION = "$(shell git describe --tags)"

CC= g++
cc=$(CC) -O2 -g -Wall -Wextra -pedantic-errors -std=c++17 -D_FILE_OFFSET_BITS=64 -DVERSION=\"$(GIT_VERSION)\"
BUILD=build

#cc=$(CC) -g -Wall -std=c++17 -D_FILE_OFFSET_BITS=64 -DVERSION=\"$(GIT_VERSION)\"


#headers with no matching .cpp
headersCommon=CompiledDataManager.hpp \
common/constants.hpp \
common/GeoTypes.hpp \
Coordinates.hpp \
helpers/Sequence.hpp \
helpers/Rectangle.hpp \
helpers/config.hpp \
helpers/FileIndex.hpp \
helpers/ExtThread.hpp \
helpers/NonGrowableQueue.hpp \
helpers/hash.hpp \
GeoBox.hpp

headersServer = services/Ping.hpp \
services/Geolocation.hpp \
services/RelationList.hpp \
services/RelationDetail.hpp \
services/WayDetail.hpp \
services/IdxList.hpp \
services/IdxDetail.hpp \
services/ServicesFactory.hpp \
messaging/HttpProtocol.hpp \
messaging/HttpEncoder.hpp \
services/renderers/SvgRenderer.hpp \
services/Tile.hpp \
services/Svg.hpp \
services/MapDisplay.hpp \
helpers/TcpConnection.hpp \
helpers/StringBuffer.hpp \
helpers/TcpListener.hpp


objectsCommon = GeoBox.o \
hash.o \
Coordinates.o \
Rectangle.o \
CompiledDataManager.o

objectsServer = Ping.o \
Geolocation.o \
RelationList.o \
RelationDetail.o \
WayDetail.o \
IdxList.o \
IdxDetail.o \
HttpProtocol.o \
HttpEncoder.o \
ServicesFactory.o \
Svg.o \
Tile.o \
SvgRenderer.o \
Msg.o \
TcpListener.o \
TcpConnection.o \
MapDisplay.o \
StringBuffer.o
helpers/NonGrowableQueue.hpp\
services/ServiceInterface.hpp

#objects used by all executables
objectsCommon = $(BUILD)/GeoBox.o \
$(BUILD)/helpers/hash.o \
$(BUILD)/Coordinates.o \
$(BUILD)/helpers/Rectangle.o \
$(BUILD)/CompiledDataManager.o

#objects used by server.cpp only
objectsServer = $(BUILD)/services/Ping.o \
$(BUILD)/services/Geolocation.o \
$(BUILD)/services/RelationList.o \
$(BUILD)/services/RelationDetail.o \
$(BUILD)/services/WayDetail.o \
$(BUILD)/services/IdxList.o \
$(BUILD)/services/IdxDetail.o \
$(BUILD)/messaging/HttpProtocol.o \
$(BUILD)/messaging/HttpEncoder.o \
$(BUILD)/services/ServicesFactory.o \
$(BUILD)/services/Svg.o \
$(BUILD)/services/Tile.o \
$(BUILD)/services/renderers/SvgRenderer.o \
$(BUILD)/messaging/Msg.o \
$(BUILD)/helpers/TcpListener.o \
$(BUILD)/helpers/TcpConnection.o \
$(BUILD)/services/MapDisplay.o \
$(BUILD)/helpers/StringBuffer.o

#libs=-lpthread -lz -latomic -lstdc++fs -fsanitize=address -static-libsan
libs=-lpthread -lz -latomic -lstdc++fs

all: renumber compile index geoserver

renumber: renumber.cpp $(headersCommon) Coordinates.o
$(cc) renumber.cpp Coordinates.o -o renumber

index: index.cpp $(headersCommon) Coordinates.o CompiledDataManager.o Rectangle.o GeoBox.o
$(cc) index.cpp Coordinates.o CompiledDataManager.o Rectangle.o GeoBox.o -o index

Coordinates.o: Coordinates.cpp Coordinates.hpp
$(cc) -c Coordinates.cpp -o Coordinates.o

compile: Coordinates.o compile.cpp $(headersCommon)
$(cc) compile.cpp Coordinates.o -o compile

CompiledDataManager.o: CompiledDataManager.hpp CompiledDataManager.cpp $(headersCommon)
$(cc) -c CompiledDataManager.cpp -o CompiledDataManager.o

hash.o: helpers/hash.hpp helpers/hash.cpp
$(cc) -c helpers/hash.cpp -o hash.o

TcpConnection.o: helpers/TcpConnection.hpp helpers/TcpConnection.cpp
$(cc) -c helpers/TcpConnection.cpp -o TcpConnection.o


TcpListener.o: helpers/TcpListener.hpp helpers/TcpListener.cpp
$(cc) -c helpers/TcpListener.cpp -o TcpListener.o


Rectangle.o: helpers/Rectangle.hpp helpers/Rectangle.cpp
$(cc) -c helpers/Rectangle.cpp -o Rectangle.o

GeoBox.o: GeoBox.hpp GeoBox.cpp
$(cc) -c GeoBox.cpp -o GeoBox.o

Ping.o: services/Ping.cpp services/Ping.hpp $(headersCommon) $(headersServer)
$(cc) -c services/Ping.cpp -o Ping.o

Geolocation.o: services/Geolocation.cpp services/Geolocation.hpp $(headersCommon) $(headersServer)
$(cc) -c services/Geolocation.cpp -o Geolocation.o

IdxList.o: services/IdxList.cpp services/IdxList.hpp $(headersCommon) $(headersServer)
$(cc) -c services/IdxList.cpp -o IdxList.o

IdxDetail.o: services/IdxDetail.cpp services/IdxDetail.hpp $(headersCommon) $(headersServer)
$(cc) -c services/IdxDetail.cpp -o IdxDetail.o

RelationList.o: services/RelationList.cpp services/RelationList.hpp $(headersCommon) $(headersServer)
$(cc) -c services/RelationList.cpp -o RelationList.o

RelationDetail.o: services/RelationDetail.cpp services/RelationDetail.hpp $(headersCommon) $(headersServer)
$(cc) -c services/RelationDetail.cpp -o RelationDetail.o

WayDetail.o: services/WayDetail.cpp services/WayDetail.hpp $(headersCommon) $(headersServer)
$(cc) -c services/WayDetail.cpp -o WayDetail.o

ServicesFactory.o: services/ServicesFactory.cpp services/ServicesFactory.hpp $(headersCommon) $(headersServer)
$(cc) -c services/ServicesFactory.cpp -o ServicesFactory.o
all: $(BUILD) $(BUILD)/renumber $(BUILD)/compile $(BUILD)/index $(BUILD)/geoserver

HttpProtocol.o: messaging/HttpProtocol.cpp messaging/HttpProtocol.hpp $(headersCommon) $(headersServer)
$(cc) -c messaging/HttpProtocol.cpp -o HttpProtocol.o
$(objectsCommon): $(BUILD)/%.o: %.cpp %.hpp $(headersCommon)
$(cc) -c $< -o $@

Msg.o: messaging/Msg.cpp messaging/Msg.hpp
$(cc) -c messaging/Msg.cpp -o Msg.o
$(objectsServer): $(BUILD)/%.o: %.cpp %.hpp $(headersCommon)
$(cc) -c $< -o $@

HttpEncoder.o: messaging/HttpEncoder.cpp messaging/HttpEncoder.hpp $(headersCommon) $(headersServer)
$(cc) -c messaging/HttpEncoder.cpp -o HttpEncoder.o

Svg.o: services/Svg.cpp services/Svg.hpp $(headersCommon) $(headersServer)
$(cc) -c services/Svg.cpp -o Svg.o
$(BUILD):
mkdir -p $(BUILD)
mkdir -p $(BUILD)/helpers
mkdir -p $(BUILD)/services
mkdir -p $(BUILD)/services/renderers
mkdir -p $(BUILD)/messaging

Tile.o: services/Tile.cpp services/Tile.hpp $(headersCommon) $(headersServer)
$(cc) -c services/Tile.cpp -o Tile.o
debug: cc=$(CC) -g -Wall -std=c++17 -D_FILE_OFFSET_BITS=64 -DVERSION=\"$(GIT_VERSION)\"
debug: $(BUILD) $(BUILD)/renumber $(BUILD)/compile $(BUILD)/index $(BUILD)/geoserver


SvgRenderer.o: services/renderers/SvgRenderer.cpp services/renderers/SvgRenderer.hpp $(headersCommon) $(headersServer)
$(cc) -c services/renderers/SvgRenderer.cpp -o SvgRenderer.o
$(BUILD)/renumber: renumber.cpp $(headersCommon) $(BUILD)/Coordinates.o
$(cc) renumber.cpp $(BUILD)/Coordinates.o -o $(BUILD)/renumber

MapDisplay.o: services/MapDisplay.cpp services/MapDisplay.hpp $(headersCommon) $(headersServer)
$(cc) -c services/MapDisplay.cpp -o MapDisplay.o
$(BUILD)/index: index.cpp $(headersCommon) $(BUILD)/Coordinates.o $(BUILD)/CompiledDataManager.o $(BUILD)/helpers/Rectangle.o $(BUILD)/GeoBox.o
$(cc) index.cpp $(BUILD)/Coordinates.o $(BUILD)/CompiledDataManager.o $(BUILD)/helpers/Rectangle.o $(BUILD)/GeoBox.o -o $(BUILD)/index

geoserver: server.cpp $(headersCommon) $(headersServer) $(objectsCommon) $(objectsServer)
$(cc) server.cpp $(objectsCommon) $(objectsServer) -o geoserver $(libs)
$(BUILD)/compile: $(BUILD)/Coordinates.o compile.cpp $(headersCommon)
$(cc) compile.cpp $(BUILD)/Coordinates.o -o $(BUILD)/compile

StringBuffer.o: helpers/StringBuffer.cpp helpers/StringBuffer.hpp
$(cc) -c helpers/StringBuffer.cpp -o StringBuffer.o
$(BUILD)/geoserver: server.cpp $(headersCommon) $(objectsCommon) $(objectsServer)
$(cc) server.cpp $(objectsCommon) $(objectsServer) -o $(BUILD)/geoserver $(libs)

clean:
rm -f *.o geoserver renumber normalize index compile geoserver
rm -rf build debug

0 comments on commit ae8b320

Please sign in to comment.