From ef5bc0a7c0e50cd766e13da0145c7eea9e7bc077 Mon Sep 17 00:00:00 2001 From: heck Date: Fri, 26 Mar 2021 18:02:38 +0100 Subject: [PATCH] LIB-13: Standard project layout (src dir added) --- Makefile | 41 ++++--------------- Makefile.conf | 1 + Adapter.cc => src/Adapter.cc | 0 Adapter.hh => src/Adapter.hh | 0 Adapter.hxx => src/Adapter.hxx | 0 src/Makefile | 37 +++++++++++++++++ Semaphore.hh => src/Semaphore.hh | 0 call_with_lock.cc => src/call_with_lock.cc | 0 call_with_lock.hh => src/call_with_lock.hh | 0 .../callback_dispatcher.cc | 0 .../callback_dispatcher.hh | 0 .../constant_time_algo.cc | 0 .../constant_time_algo.hh | 0 locked_queue.hh => src/locked_queue.hh | 0 message_cache.cc => src/message_cache.cc | 0 message_cache.hh => src/message_cache.hh | 0 pEpLog.cc => src/pEpLog.cc | 0 pEpLog.hh => src/pEpLog.hh | 0 .../passphrase_cache.cc | 0 .../passphrase_cache.hh | 0 .../passphrase_cache.hxx | 0 pc_container.hh => src/pc_container.hh | 0 slurp.cc => src/slurp.cc | 0 slurp.hh => src/slurp.hh | 0 .../status_to_string.cc | 0 .../status_to_string.hh | 0 test/Makefile | 6 +-- 27 files changed, 50 insertions(+), 35 deletions(-) rename Adapter.cc => src/Adapter.cc (100%) rename Adapter.hh => src/Adapter.hh (100%) rename Adapter.hxx => src/Adapter.hxx (100%) create mode 100644 src/Makefile rename Semaphore.hh => src/Semaphore.hh (100%) rename call_with_lock.cc => src/call_with_lock.cc (100%) rename call_with_lock.hh => src/call_with_lock.hh (100%) rename callback_dispatcher.cc => src/callback_dispatcher.cc (100%) rename callback_dispatcher.hh => src/callback_dispatcher.hh (100%) rename constant_time_algo.cc => src/constant_time_algo.cc (100%) rename constant_time_algo.hh => src/constant_time_algo.hh (100%) rename locked_queue.hh => src/locked_queue.hh (100%) rename message_cache.cc => src/message_cache.cc (100%) rename message_cache.hh => src/message_cache.hh (100%) rename pEpLog.cc => src/pEpLog.cc (100%) rename pEpLog.hh => src/pEpLog.hh (100%) rename passphrase_cache.cc => src/passphrase_cache.cc (100%) rename passphrase_cache.hh => src/passphrase_cache.hh (100%) rename passphrase_cache.hxx => src/passphrase_cache.hxx (100%) rename pc_container.hh => src/pc_container.hh (100%) rename slurp.cc => src/slurp.cc (100%) rename slurp.hh => src/slurp.hh (100%) rename status_to_string.cc => src/status_to_string.cc (100%) rename status_to_string.hh => src/status_to_string.hh (100%) diff --git a/Makefile b/Makefile index 6eac3c6..58019c3 100644 --- a/Makefile +++ b/Makefile @@ -3,45 +3,22 @@ # This file may be used under the terms of the GNU General Public License version 3 # see LICENSE.txt -include Makefile.conf +.PHONY: src test install uninstall clean -TARGET=libpEpAdapter.a +all: src -.PHONY: install uninstall clean +src: + $(MAKE) -C src -SOURCE=$(wildcard *.cc) -HEADERS=$(wildcard *.hh *.hxx) -OBJECTS=$(subst .cc,.o,$(SOURCE)) -DEPENDS=$(subst .cc,.d,$(SOURCE)) -CXXFLAGS+= -MMD -MP - -all: $(TARGET) - -ifneq ($(MAKECMDGOALS),clean) - -include $(DEPENDS) -endif - -lib: $(TARGET) - -all: lib - -test: lib +test: src $(MAKE) -C test -$(TARGET): $(OBJECTS) - $(AR) -rc $@ $^ - clean: - rm -vf $(TARGET) $(OBJECTS) $(DEPENDS) - rm -f *.d.* + $(MAKE) -C src clean $(MAKE) -C test clean -install: $(TARGET) - mkdir -p $(PREFIX)/include/pEp - mkdir -p $(PREFIX)/lib - cp -v $(HEADERS) $(PREFIX)/include/pEp/ - cp -v $(TARGET) $(PREFIX)/lib/ +install: + $(MAKE) -C src install uninstall: - cd $(PREFIX)/include/pEp && rm -vf $(HEADERS) - cd $(PREFIX)/lib && rm -vf $(TARGET) + $(MAKE) -C src uninstall \ No newline at end of file diff --git a/Makefile.conf b/Makefile.conf index 6e152b5..658919e 100644 --- a/Makefile.conf +++ b/Makefile.conf @@ -5,6 +5,7 @@ HERE:=$(dir $(lastword $(MAKEFILE_LIST))) +TARGET=libpEpAdapter.a # Defaults DEBUG=1 diff --git a/Adapter.cc b/src/Adapter.cc similarity index 100% rename from Adapter.cc rename to src/Adapter.cc diff --git a/Adapter.hh b/src/Adapter.hh similarity index 100% rename from Adapter.hh rename to src/Adapter.hh diff --git a/Adapter.hxx b/src/Adapter.hxx similarity index 100% rename from Adapter.hxx rename to src/Adapter.hxx diff --git a/src/Makefile b/src/Makefile new file mode 100644 index 0000000..2b3b74b --- /dev/null +++ b/src/Makefile @@ -0,0 +1,37 @@ +# Copyright 2018, pEp Foundation +# This file is part of lib pEp Adapter +# This file may be used under the terms of the GNU General Public License version 3 +# see LICENSE.txt + +include ../Makefile.conf + +SOURCE=$(wildcard *.cc) +HEADERS=$(wildcard *.hh *.hxx) +OBJECTS=$(subst .cc,.o,$(SOURCE)) +DEPENDS=$(subst .cc,.d,$(SOURCE)) +CXXFLAGS+= -MMD -MP + +ifneq ($(MAKECMDGOALS),clean) + -include $(DEPENDS) +endif + +.PHONY: install uninstall clean + +all: $(TARGET) + +$(TARGET): $(OBJECTS) + $(AR) -rc $@ $^ + +clean: + rm -vf $(TARGET) $(OBJECTS) $(DEPENDS) + rm -f *.d.* + +install: $(TARGET) + mkdir -p $(PREFIX)/include/pEp + mkdir -p $(PREFIX)/lib + cp -v $(HEADERS) $(PREFIX)/include/pEp/ + cp -v $(TARGET) $(PREFIX)/lib/ + +uninstall: + cd $(PREFIX)/include/pEp && rm -vf $(HEADERS) + cd $(PREFIX)/lib && rm -vf $(TARGET) diff --git a/Semaphore.hh b/src/Semaphore.hh similarity index 100% rename from Semaphore.hh rename to src/Semaphore.hh diff --git a/call_with_lock.cc b/src/call_with_lock.cc similarity index 100% rename from call_with_lock.cc rename to src/call_with_lock.cc diff --git a/call_with_lock.hh b/src/call_with_lock.hh similarity index 100% rename from call_with_lock.hh rename to src/call_with_lock.hh diff --git a/callback_dispatcher.cc b/src/callback_dispatcher.cc similarity index 100% rename from callback_dispatcher.cc rename to src/callback_dispatcher.cc diff --git a/callback_dispatcher.hh b/src/callback_dispatcher.hh similarity index 100% rename from callback_dispatcher.hh rename to src/callback_dispatcher.hh diff --git a/constant_time_algo.cc b/src/constant_time_algo.cc similarity index 100% rename from constant_time_algo.cc rename to src/constant_time_algo.cc diff --git a/constant_time_algo.hh b/src/constant_time_algo.hh similarity index 100% rename from constant_time_algo.hh rename to src/constant_time_algo.hh diff --git a/locked_queue.hh b/src/locked_queue.hh similarity index 100% rename from locked_queue.hh rename to src/locked_queue.hh diff --git a/message_cache.cc b/src/message_cache.cc similarity index 100% rename from message_cache.cc rename to src/message_cache.cc diff --git a/message_cache.hh b/src/message_cache.hh similarity index 100% rename from message_cache.hh rename to src/message_cache.hh diff --git a/pEpLog.cc b/src/pEpLog.cc similarity index 100% rename from pEpLog.cc rename to src/pEpLog.cc diff --git a/pEpLog.hh b/src/pEpLog.hh similarity index 100% rename from pEpLog.hh rename to src/pEpLog.hh diff --git a/passphrase_cache.cc b/src/passphrase_cache.cc similarity index 100% rename from passphrase_cache.cc rename to src/passphrase_cache.cc diff --git a/passphrase_cache.hh b/src/passphrase_cache.hh similarity index 100% rename from passphrase_cache.hh rename to src/passphrase_cache.hh diff --git a/passphrase_cache.hxx b/src/passphrase_cache.hxx similarity index 100% rename from passphrase_cache.hxx rename to src/passphrase_cache.hxx diff --git a/pc_container.hh b/src/pc_container.hh similarity index 100% rename from pc_container.hh rename to src/pc_container.hh diff --git a/slurp.cc b/src/slurp.cc similarity index 100% rename from slurp.cc rename to src/slurp.cc diff --git a/slurp.hh b/src/slurp.hh similarity index 100% rename from slurp.hh rename to src/slurp.hh diff --git a/status_to_string.cc b/src/status_to_string.cc similarity index 100% rename from status_to_string.cc rename to src/status_to_string.cc diff --git a/status_to_string.hh b/src/status_to_string.hh similarity index 100% rename from status_to_string.hh rename to src/status_to_string.hh diff --git a/test/Makefile b/test/Makefile index cdd2435..68a4624 100644 --- a/test/Makefile +++ b/test/Makefile @@ -1,8 +1,8 @@ include ../Makefile.conf -LDFLAGS=-L../ $(ENGINE_LIB) +LDFLAGS=-L../src $(ENGINE_LIB) LDLIBS=-lstdc++ -lpEpEngine -lpEpAdapter -CXXFLAGS+=-I../ $(ENGINE_INC) -std=c++11 -DENGINE_TEST=$(ENGINE_TEST) +CXXFLAGS+=-I../src $(ENGINE_INC) -std=c++11 -DENGINE_TEST=$(ENGINE_TEST) SRC=$(wildcard test_*.cc) TST=$(subst .cc,,$(SRC)) @@ -13,7 +13,7 @@ $(TST): framework.o .PHONY: clean rmtestdata -clean: +clean: rm -f $(TST) rm -Rf *.dSYM rm -f *.o