From 7f095416d3e4561d7fbf3db1406e95e6a131d742 Mon Sep 17 00:00:00 2001
From: Alexander Mueller <alexander.mueller@hs.uni-hamburg.de>
Date: Fri, 2 Sep 2005 14:23:29 +0000
Subject: [PATCH] BugID: 163 All .conf and .log_prop files will be installed in
 sysconf_DATA (which means 'etc' beside of the 'bin' directory). The
 GCFTask::init method sets this 'etc' as default path for all *.conf files,
 which will be adopted to the same (singleton) instance of the ParameterSet.

---
 MAC/APL/PAC/_VirtualBackend/src/Makefile.am |  3 +-
 MAC/APL/PIC/MIS/src/Makefile.am             |  6 ++--
 MAC/APL/PIC/_NodeManager/src/Makefile.am    |  6 ++--
 MAC/GCF/LogSys/CLP/src/Makefile.am          |  7 ++--
 MAC/GCF/LogSys/KVLogSys/src/Makefile.am     |  6 ++--
 MAC/GCF/TM/src/GCF_Task.cc                  | 30 +++++++++++++----
 MAC/GCF/TM/src/Makefile.am                  | 12 +++----
 MAC/GCF/TM/src/ServiceBroker/Makefile.am    | 13 +++-----
 MAC/GCF/TM/test/Makefile.am                 | 37 +++++++++------------
 MAC/GCF/_PAL/PA/src/Makefile.am             |  8 ++++-
 MAC/GCF/_PAL/PI/src/Makefile.am             |  7 ++--
 MAC/GCF/_PAL/PML/src/Makefile.am            |  7 ++--
 MAC/GCF/_PAL/SAL/test/Makefile.am           | 37 +++++++++------------
 MAC/GCF/_PALlight/PMLlight/src/Makefile.am  |  4 ++-
 MAC/Test/GCF/MAC/src/Makefile.am            |  9 ++---
 MAC/Test/GCF/RTC/src/Makefile.am            |  6 ++--
 16 files changed, 105 insertions(+), 93 deletions(-)

diff --git a/MAC/APL/PAC/_VirtualBackend/src/Makefile.am b/MAC/APL/PAC/_VirtualBackend/src/Makefile.am
index 37e53dc63e5..e30a50c3392 100644
--- a/MAC/APL/PAC/_VirtualBackend/src/Makefile.am
+++ b/MAC/APL/PAC/_VirtualBackend/src/Makefile.am
@@ -32,8 +32,7 @@ VirtualBackend_CPPFLAGS			= \
 	-fdiagnostics-show-location=once \
 	-DUSE_TCPPORT_INSTEADOF_PVSSPORT
 
-configfilesdir=$(bindir)
-configfiles_DATA= \
+sysconf_DATA= \
 	VirtualBackend.conf \
 	CEPAppDefault.param
 	
diff --git a/MAC/APL/PIC/MIS/src/Makefile.am b/MAC/APL/PIC/MIS/src/Makefile.am
index 25bc968eded..c99af2e1a03 100644
--- a/MAC/APL/PIC/MIS/src/Makefile.am
+++ b/MAC/APL/PIC/MIS/src/Makefile.am
@@ -32,11 +32,9 @@ MACInformationServer_CPPFLAGS			=
 BUILT_SOURCES = \
 	MIS_Protocol.ph
 
-EXTRA_DIST = \
-	MIS_Protocol.ph
+EXTRA_DIST = $(BUILT_SOURCES) 
 	
-configfilesdir=$(bindir)
-configfiles_DATA= \
+sysconf_DATA= \
 	MACInformationServer.conf
 	
 %.conf: %.conf.in
diff --git a/MAC/APL/PIC/_NodeManager/src/Makefile.am b/MAC/APL/PIC/_NodeManager/src/Makefile.am
index 29c4842d22d..b8a73133a14 100644
--- a/MAC/APL/PIC/_NodeManager/src/Makefile.am
+++ b/MAC/APL/PIC/_NodeManager/src/Makefile.am
@@ -47,11 +47,9 @@ NodeManager_CPPFLAGS			=
 BUILT_SOURCES = \
 	NM_Protocol.ph
 
-EXTRA_DIST = \
-	NM_Protocol.ph
+EXTRA_DIST = $(BUILT_SOURCES)
 	
-configfilesdir=$(bindir)
-configfiles_DATA= \
+sysconf_DATA= \
 	NodeManager.conf
 	
 %.conf: %.conf.in
diff --git a/MAC/GCF/LogSys/CLP/src/Makefile.am b/MAC/GCF/LogSys/CLP/src/Makefile.am
index b28a2bdbc91..3980e5bba30 100644
--- a/MAC/GCF/LogSys/CLP/src/Makefile.am
+++ b/MAC/GCF/LogSys/CLP/src/Makefile.am
@@ -25,8 +25,11 @@ CodeLoggingProcessor_DEPENDENCIES	= libclp.la $(LOFAR_DEPEND) \
 CodeLoggingProcessor_CPPFLAGS			= -DLOFARLOGGER_SUBPACKAGE=\"CLP\" \
 	-I$(top_srcdir)/include
 
-configfilesdir=$(bindir)
-configfiles_DATA= \
+BUILT_SOURCES =
+
+EXTRA_DIST = $(BUILT_SOURCES)
+
+sysconf_DATA= \
 	CodeLoggingProcessor.conf \
 	CodeLoggingProcessor.log_prop
 	
diff --git a/MAC/GCF/LogSys/KVLogSys/src/Makefile.am b/MAC/GCF/LogSys/KVLogSys/src/Makefile.am
index 0de3ab6e35b..cb9535f46fe 100644
--- a/MAC/GCF/LogSys/KVLogSys/src/Makefile.am
+++ b/MAC/GCF/LogSys/KVLogSys/src/Makefile.am
@@ -60,11 +60,9 @@ KeyValueLoggerMaster_CPPFLAGS			= -DLOFARLOGGER_SUBPACKAGE=\"KVLM\"
 BUILT_SOURCES = \
 	KVL_Protocol.ph
 
-EXTRA_DIST = \
-	KVL_Protocol.ph
+EXTRA_DIST = $(BUILT_SOURCES)
 	
-configfilesdir=$(bindir)
-configfiles_DATA= \
+sysconf_DATA= \
 	KeyValueLoggerDaemon.conf \
 	KeyValueLoggerMaster.conf \
 	KeyValueLoggerDaemon.log_prop \
diff --git a/MAC/GCF/TM/src/GCF_Task.cc b/MAC/GCF/TM/src/GCF_Task.cc
index 6c5cdd9493a..ce5c8950bd6 100644
--- a/MAC/GCF/TM/src/GCF_Task.cc
+++ b/MAC/GCF/TM/src/GCF_Task.cc
@@ -71,16 +71,33 @@ void GCFTask::init(int argc, char** argv)
   _argc = argc;
   _argv = argv;
   
-  string appName(argv[0]);
-
+  string procName(argv[0]);
+  
   ifstream    logPropFile;
 
-  // Try to open the log_prop file
-  string logPropFileName = appName + ".log_prop";
+  // Construct the etc path for config files
+  string etcPath(procName);
+  // Find last '/'
+  string::size_type pos = etcPath.rfind('/');
+  if (pos == string::npos) pos = 0; // not found: so erase whole filename
+  else pos++;                       // found : increase pos to avoid erasing the '/' too
+  
+  if (pos == 0 || pos == 1) etcPath = "/etc/"; // no '/' or only one '/' (at the 0 position)
+  else 
+  {
+    etcPath.erase(pos);
+    etcPath += "../etc/"; // becomes e.g. /opt/lofar/bin/../etc/
+  }
+  
+  procName.erase(0, pos); // erase path
+  
+  // Try to open the log_prop file, if process has its own log_prop file then use it in 
+  // the INIT_LOGGER otherwise use the default mac.log_prop
+  string logPropFileName = etcPath + procName + ".log_prop";
   logPropFile.open(logPropFileName.c_str(), ifstream::in);
   if (!logPropFile) 
   {
-    logPropFileName = "./mac.log_prop";
+    logPropFileName = etcPath + "mac.log_prop";
   }
   else
   {
@@ -90,7 +107,8 @@ void GCFTask::init(int argc, char** argv)
   INIT_LOGGER(logPropFileName.c_str());   
 
   ParameterSet* pParamSet = ParameterSet::instance();
-  pParamSet->adoptFile(appName + ".conf");
+  pParamSet->setSearchPath(etcPath);
+  pParamSet->adoptFile(procName + ".conf");
 
   if (_doExit)
     exit(-1);
diff --git a/MAC/GCF/TM/src/Makefile.am b/MAC/GCF/TM/src/Makefile.am
index bc734a8a464..bd826b7822d 100644
--- a/MAC/GCF/TM/src/Makefile.am
+++ b/MAC/GCF/TM/src/Makefile.am
@@ -62,14 +62,14 @@ libgcftm_la_CPPFLAGS=-I$(top_srcdir)/include \
 
 libgcftm_la_CXXFLAGS=-fmessage-length=0
 
-BUILT_SOURCES = \
-	SB_Protocol.ph \
-	mac.log_prop
+BUILT_SOURCES =  \
+	SB_Protocol.ph
 
-EXTRA_DIST = \
-	SB_Protocol.ph \
-	mac.log_prop
+EXTRA_DIST = $(BUILT_SOURCES)
 	
+sysconf_DATA = \
+	mac.log_prop
+
 %.log_prop: %.log_prop.in
 	cp $< $@
 
diff --git a/MAC/GCF/TM/src/ServiceBroker/Makefile.am b/MAC/GCF/TM/src/ServiceBroker/Makefile.am
index 736be1275db..a16fa65d262 100644
--- a/MAC/GCF/TM/src/ServiceBroker/Makefile.am
+++ b/MAC/GCF/TM/src/ServiceBroker/Makefile.am
@@ -22,19 +22,16 @@ ServiceBroker_DEPENDENCIES	= libsb.la $(LOFAR_DEPEND) \
 ServiceBroker_CPPFLAGS= -I$(top_srcdir)/include
 ServiceBroker_CXXFLAGS=-fmessage-length=0
 
-BUILT_SOURCES = \
-	ServiceBroker.conf
+BUILT_SOURCES = 
 
-EXTRA_DIST = \
-	ServiceBroker.conf
+EXTRA_DIST = $(BUILT_SOURCES)
 
-configfilesdir=$(bindir)
-configfiles_DATA= \
+sysconf_DATA= \
 	ServiceBroker.conf
 
 install-data-local:
-	echo "mac.gcf.sb.host=`hostname -s`" >> $(bindir)/ServiceBroker.conf
-	echo "mac.gcf.sb.range1.host=`hostname`" >> $(bindir)/ServiceBroker.conf
+	echo "mac.gcf.sb.host=`hostname -s`" >> $(sysconfdir)/ServiceBroker.conf
+	echo "mac.gcf.sb.range1.host=`hostname`" >> $(sysconfdir)/ServiceBroker.conf
 	
 %.conf: gcf-sb.conf.in
 	cp $< $@
diff --git a/MAC/GCF/TM/test/Makefile.am b/MAC/GCF/TM/test/Makefile.am
index 171b9cb8c98..1e046cb71e9 100644
--- a/MAC/GCF/TM/test/Makefile.am
+++ b/MAC/GCF/TM/test/Makefile.am
@@ -1,16 +1,14 @@
-check_PROGRAMS 		= echoapp ping
+bin_PROGRAMS 		= tmEcho tmPing
 
-TESTS			= #echoapp ping
+tmEcho_SOURCES 		= Echo.cc Echo_Protocol.cc
+tmEcho_LDADD		= ../src/libgcftm.la
+tmEcho_DEPENDENCIES	= ../src/libgcftm.la $(LOFAR_DEPEND)
+tmEcho_CPPFLAGS=-I$(top_srcdir)/include
 
-echoapp_SOURCES 		= Echo.cc Echo_Protocol.cc
-echoapp_LDADD		= ../src/libgcftm.la
-echoapp_DEPENDENCIES	= ../src/libgcftm.la $(LOFAR_DEPEND)
-echoapp_CPPFLAGS=-I$(top_srcdir)/include
-
-ping_SOURCES 		= Ping.cc Echo_Protocol.cc
-ping_LDADD		= ../src/libgcftm.la
-ping_DEPENDENCIES	= ../src/libgcftm.la $(LOFAR_DEPEND)
-ping_CPPFLAGS=-I$(top_srcdir)/include
+tmPing_SOURCES 		= Ping.cc Echo_Protocol.cc
+tmPing_LDADD		= ../src/libgcftm.la
+tmPing_DEPENDENCIES	= ../src/libgcftm.la $(LOFAR_DEPEND)
+tmPing_CPPFLAGS=-I$(top_srcdir)/include
 
 AUTOGEN = autogen
 SUFFIXES = .ph
@@ -18,23 +16,18 @@ SUFFIXES = .ph
 	$(AUTOGEN) --writable -L $(top_srcdir)/autogen $<
 
 BUILT_SOURCES = \
-	Echo_Protocol.ph \
-	echoapp.conf \
-	ping.conf \
-	ServiceBroker.conf
+	Echo_Protocol.ph
 
 EXTRA_DIST = \
-	Echo_Protocol.ph \
-	echoapp.conf \
-	ping.conf \
-	ServiceBroker.conf
+	Echo_Protocol.ph
+
+sysconf_DATA=\
+	tmEcho.conf \
+	tmPing.conf
 	
 %.conf:	tm-test.conf.in
 	ln -sf $< $@
 
-ServiceBroker.conf:	$(bindir)/ServiceBroker.conf
-	cp $< $@
-	
 clean-local:
 	rm -f *.ph
 
diff --git a/MAC/GCF/_PAL/PA/src/Makefile.am b/MAC/GCF/_PAL/PA/src/Makefile.am
index c1dfbd7d114..472043c7cc9 100644
--- a/MAC/GCF/_PAL/PA/src/Makefile.am
+++ b/MAC/GCF/_PAL/PA/src/Makefile.am
@@ -34,7 +34,13 @@ AM_CPPFLAGS = -DLOFARLOGGER_SUBPACKAGE=\"PA\"
 configfilesdir=$(bindir)
 configfiles_DATA= \
 	loadAPC \
-	preparePVSS-DB \
+	preparePVSS-DB
+
+BUILT_SOURCES = 
+
+EXTRA_DIST = $(BUILT_SOURCES)
+
+sysconf_DATA= \
 	PropertyAgent.conf
 
 install-data-local:
diff --git a/MAC/GCF/_PAL/PI/src/Makefile.am b/MAC/GCF/_PAL/PI/src/Makefile.am
index 993e3fcf975..38e92f4c4d0 100644
--- a/MAC/GCF/_PAL/PI/src/Makefile.am
+++ b/MAC/GCF/_PAL/PI/src/Makefile.am
@@ -36,8 +36,11 @@ PropertyInterface_DEPENDENCIES	= libpi.la \
 
 AM_CPPFLAGS = -DLOFARLOGGER_SUBPACKAGE=\"PI\"
 
-configfilesdir=$(bindir)
-configfiles_DATA= \
+BUILT_SOURCES = 
+
+EXTRA_DIST = $(BUILT_SOURCES)
+
+sysconf_DATA= \
 	PropertyInterface.conf
 		
 %.conf: gcf-pi.conf.in
diff --git a/MAC/GCF/_PAL/PML/src/Makefile.am b/MAC/GCF/_PAL/PML/src/Makefile.am
index 160642d67ff..aebb37e50aa 100644
--- a/MAC/GCF/_PAL/PML/src/Makefile.am
+++ b/MAC/GCF/_PAL/PML/src/Makefile.am
@@ -43,8 +43,11 @@ libpml_la_CPPFLAGS= -I$(top_srcdir)/include \
 
 AM_CPPFLAGS = -DLOFARLOGGER_SUBPACKAGE=\"PML\"
 	
-configfilesdir=$(bindir)
-configfiles_DATA= \
+BUILT_SOURCES = 
+
+EXTRA_DIST = $(BUILT_SOURCES)
+
+sysconf_DATA= \
 	gcf-pml.conf
 
 %.conf: %.conf.in
diff --git a/MAC/GCF/_PAL/SAL/test/Makefile.am b/MAC/GCF/_PAL/SAL/test/Makefile.am
index d87926d40f0..c06691baf58 100644
--- a/MAC/GCF/_PAL/SAL/test/Makefile.am
+++ b/MAC/GCF/_PAL/SAL/test/Makefile.am
@@ -1,19 +1,19 @@
 cppflags = -I$(top_srcdir)/SAL/src \
 	-I$(top_srcdir)/include
 
-check_PROGRAMS 		= echoapp ping
+check_PROGRAMS 		= salEcho salPing
 
-TESTS			= #echoapp ping
+TESTS			= #salEcho salPing
 
-echoapp_SOURCES 			= Echo.cc Service.cc Echo_Protocol.cc
-echoapp_LDADD					= ../src/libsal.la $(LOFAR_DEPEND)
-echoapp_DEPENDENCIES	= ../src/libsal.la $(LOFAR_DEPEND)
-echoapp_CPPFLAGS			= $(cppflags)
+salEcho_SOURCES 			= Echo.cc Service.cc Echo_Protocol.cc
+salEcho_LDADD					= ../src/libsal.la $(LOFAR_DEPEND)
+salEcho_DEPENDENCIES	= ../src/libsal.la $(LOFAR_DEPEND)
+salEcho_CPPFLAGS			= $(cppflags)
 
-ping_SOURCES 					= Ping.cc  Echo_Protocol.cc
-ping_LDADD						=  ../src/libsal.la $(LOFAR_DEPEND)
-ping_DEPENDENCIES			= ../src/libsal.la $(LOFAR_DEPEND)
-ping_CPPFLAGS= $(cppflags)
+salPing_SOURCES 					= Ping.cc  Echo_Protocol.cc
+salPing_LDADD						=  ../src/libsal.la $(LOFAR_DEPEND)
+salPing_DEPENDENCIES			= ../src/libsal.la $(LOFAR_DEPEND)
+salPing_CPPFLAGS= $(cppflags)
 
 AUTOGEN = autogen
 SUFFIXES = .ph
@@ -21,22 +21,17 @@ SUFFIXES = .ph
 	$(AUTOGEN) --writable -L $(datadir)/GCF/TM $<
 
 BUILT_SOURCES = \
-	Echo_Protocol.ph \
-	echoapp.conf \
-	ping.conf \
-	ServiceBroker.conf
+	Echo_Protocol.ph
 
-EXTRA_DIST = \
-	Echo_Protocol.ph \
-	echoapp.conf \
-	ping.conf
+EXTRA_DIST = $(BUILT_SOURCES)
+
+sysconf_DATA= \
+	salEcho.conf \
+	salPing.conf
 
 %.conf: sal-test.conf.in
 	ln -sf $< $@
 
-ServiceBroker.conf:	$(bindir)/ServiceBroker.conf
-	cp $< $@
-
 clean-local:
 	rm -f *.ph
 
diff --git a/MAC/GCF/_PALlight/PMLlight/src/Makefile.am b/MAC/GCF/_PALlight/PMLlight/src/Makefile.am
index 9e2e276177c..7891bac1491 100644
--- a/MAC/GCF/_PALlight/PMLlight/src/Makefile.am
+++ b/MAC/GCF/_PALlight/PMLlight/src/Makefile.am
@@ -27,9 +27,11 @@ libgcfpallight_la_DEPENDENCIES= libpmllight.la $(LOFAR_DEPEND)
 
 AM_CPPFLAGS = -DLOFARLOGGER_SUBPACKAGE=\"RTC\"
 
+sysconf_DATA= \
+	gcf-pmllight.conf
+	
 configfilesdir=$(bindir)
 configfiles_DATA= \
-	gcf-pmllight.conf \
 	genTypeInfo
 
 %.conf: %.conf.in
diff --git a/MAC/Test/GCF/MAC/src/Makefile.am b/MAC/Test/GCF/MAC/src/Makefile.am
index 13d61057501..6278efd5e9d 100644
--- a/MAC/Test/GCF/MAC/src/Makefile.am
+++ b/MAC/Test/GCF/MAC/src/Makefile.am
@@ -34,18 +34,19 @@ Application3_DEPENDENCIES		= libgcftest.la $(LOFAR_DEPEND)
 BUILT_SOURCES = \
 	TST_Protocol.ph
 
-EXTRA_DIST = \
-	TST_Protocol.ph
+EXTRA_DIST = $(BUILT_SOURCES)
 	
 AM_CXXFLAGS=-fmessage-length=0
 	
 #in case of make install these files will be copied to the bindir beside the test apps
 configfilesdir=$(bindir)
 configfiles_DATA= \
+	customPrepPVSSDB.ctl
+
+sysconf_DATA= \
 	Application1.conf \
 	Application2.conf \
-	Application3.conf \
-	customPrepPVSSDB.ctl
+	Application3.conf
 
 %.conf: gcf-test.conf.in
 	cp $< $@
diff --git a/MAC/Test/GCF/RTC/src/Makefile.am b/MAC/Test/GCF/RTC/src/Makefile.am
index a3d313e3516..4cdcbfcc40f 100644
--- a/MAC/Test/GCF/RTC/src/Makefile.am
+++ b/MAC/Test/GCF/RTC/src/Makefile.am
@@ -26,14 +26,12 @@ RTPing_DEPENDENCIES					= librtc.la $(LOFAR_DEPEND)
 BUILT_SOURCES = \
 	Echo_Protocol.ph
 
-EXTRA_DIST = \
-	Echo_Protocol.ph
+EXTRA_DIST = $(BUILT_SOURCES)
 	
 AM_CXXFLAGS=-fmessage-length=0
 	
 #in case of make install these files will be copied to the bindir beside the test apps
-configfilesdir=$(bindir)
-configfiles_DATA= \
+sysconf_DATA= \
 	RTEcho.conf \
 	RTPing.conf
 	
-- 
GitLab