From e08421abf39267f0b11884512f0447c3510b5f77 Mon Sep 17 00:00:00 2001
From: DL1YCF <dl1ycf@darc.de>
Date: Thu, 21 May 2020 23:14:06 +0200
Subject: [PATCH] consilidated manual merge

---
 Makefile.mac | 23 +++++------------------
 band.c       |  1 +
 rigctl.c     |  9 +++++++++
 3 files changed, 15 insertions(+), 18 deletions(-)

diff --git a/Makefile.mac b/Makefile.mac
index 6d6fdec..54424fc 100644
--- a/Makefile.mac
+++ b/Makefile.mac
@@ -478,7 +478,7 @@ hpsdrsim:       hpsdrsim.o newhpsdrsim.o
 #############################################################################
 app:	$(OBJS) $(REMOTE_OBJS) $(USBOZY_OBJS) \
 		$(LOCALCW_OBJS) \
-		$(PURESIGNAL_OBJS) $(MIDI_OBJS) $(STEMLAB_OBJS)
+		$(PURESIGNAL_OBJS) $(MIDI_OBJS) $(SOAPYSDR_OBJS) $(STEMLAB_OBJS)
 	$(LINK) -headerpad_max_install_names -o $(PROGRAM) $(OBJS) $(REMOTE_OBJS) \
 		$(USBOZY_OBJS)  \
 		$(LOCALCW_OBJS) $(PURESIGNAL_OBJS) \
@@ -493,22 +493,9 @@ app:	$(OBJS) $(REMOTE_OBJS) $(USBOZY_OBJS) \
 	@cp MacOS/hpsdr.icns pihpsdr.app/Contents/Resources/hpsdr.icns
 	@cp MacOS/pihpsdr.sh pihpsdr.app/Contents/MacOS/pihpsdr
 	@cp MacOS/hpsdr.png pihpsdr.app/Contents/Resources
-	@for lib in `otool -L pihpsdr.app/Contents/MacOS/pihpsdr-bin | grep dylib | sed -e "s/ (.*//" | grep -Ev "/(usr/lib|System)" | grep -Ev /libg  | grep -Ev pango | grep -Ev cairo`; do \
-	  libfn="`basename $$lib`"; \
-	  cp "$$lib" "pihpsdr.app/Contents/Frameworks/$$libfn"; \
-	  chmod u+w "pihpsdr.app/Contents/Frameworks/$$libfn"; \
-	  install_name_tool -id "@executable_path/../Frameworks/$$libfn" "pihpsdr.app/Contents/Frameworks/$$libfn"; \
-	  install_name_tool -change "$$lib" "@executable_path/../Frameworks/$$libfn" pihpsdr.app/Contents/MacOS/pihpsdr-bin; \
-	done
-	@# once more to install libraries on which libs just copied depend (such as wdsp -> fftw)
-	@for file in pihpsdr.app/Contents/Frameworks/*.dylib; do \
-	  for lib in `otool -L pihpsdr.app/Contents/Frameworks/*.dylib | grep -v pihpsdr.app | grep -v "executable_path" | grep dylib | sed -e "s/ (.*//" | grep -Ev "/(usr/lib|System)" | grep -Ev /libg  | grep -Ev pango | grep -Ev cairo`; do \
-	    libfn="`basename $$lib`"; \
-	    cp "$$lib" "pihpsdr.app/Contents/Frameworks/$$libfn"; \
-	    chmod u+w "pihpsdr.app/Contents/Frameworks/$$libfn"; \
-	    install_name_tool -id "@executable_path/../Frameworks/$$libfn" "pihpsdr.app/Contents/Frameworks/$$libfn"; \
-	    install_name_tool -change "$$lib" "@executable_path/../Frameworks/$$libfn" $$file; \
-	  done; \
-	done
+#
+#       Copying the libraries is too error-prone at the end
+#       So *do not do* that, instead the app will only work if the libraries are installed in the correct place
+#
 #############################################################################
 
diff --git a/band.c b/band.c
index 5ca08cf..de1712e 100644
--- a/band.c
+++ b/band.c
@@ -517,6 +517,7 @@ void bandRestoreState() {
 	// The number of entries is a compile-time constant,
         // which changes when compiling piHPSDR with different
 	// options (e.g. with and without SOAPYSDR)
+	// Therefore this number cannot be "restored" from a props file
 
         //sprintf(name,"band.%d.entries",b);
         //lue=getProperty(name);
diff --git a/rigctl.c b/rigctl.c
index a0df83f..3c36c37 100644
--- a/rigctl.c
+++ b/rigctl.c
@@ -2147,6 +2147,7 @@ gboolean parse_extended_cmd (char *command,CLIENT *client) {
             sprintf(reply,"ZZSP%d;",split);
             send_resp(client->fd,reply) ;
           } else if(command[5]==';') {
+	    // use ext_set_split to take care of antenna switching
             split=atoi(&command[4]);
             tx_set_mode(transmitter,get_tx_mode());
             vfo_update();
@@ -2173,6 +2174,7 @@ gboolean parse_extended_cmd (char *command,CLIENT *client) {
             sprintf(reply,"ZZSW%d;",split);
             send_resp(client->fd,reply) ;
           } else if(command[5]==';') {
+	    // use ext_set_split to take care of antenna switching
             split=atoi(&command[4]);
             tx_set_mode(transmitter,get_tx_mode());
             vfo_update();
@@ -2724,6 +2726,7 @@ int parse_cmd(void *data) {
             sprintf(reply,"FT%d;",split);
             send_resp(client->fd,reply) ;
           } else if(command[3]==';') {
+	    // use ext_set_split to take care of antenna switching
             split=atoi(&command[2]);
             tx_set_mode(transmitter,get_tx_mode());
             vfo_update();
@@ -3135,7 +3138,10 @@ static gpointer serial_server(gpointer data) {
      int command_index=0;
      int numbytes;
      int i;
+     g_mutex_lock(&mutex_a->m);
      cat_control++;
+     if(rigctl_debug) g_print("RIGCTL: SER INC cat_contro=%d\n",cat_control);
+     g_mutex_unlock(&mutex_a->m);
      serial_running=TRUE;
      while(serial_running) {
        numbytes = read (fd, cmd_input, sizeof cmd_input);
@@ -3163,7 +3169,10 @@ static gpointer serial_server(gpointer data) {
        //usleep(100L);
      }
      close(client->fd);
+     g_mutex_lock(&mutex_a->m);
      cat_control--;
+     if(rigctl_debug) g_print("RIGCTL: SER DEC - cat_control=%d\n",cat_control);
+     g_mutex_unlock(&mutex_a->m);
      return NULL;
 }
 
-- 
2.45.2