pkgsrc-Changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

CVS commit: pkgsrc/ham/direwolf



Module Name:    pkgsrc
Committed By:   jmcneill
Date:           Sun Apr 13 16:07:16 UTC 2025

Modified Files:
        pkgsrc/ham/direwolf: Makefile distinfo
        pkgsrc/ham/direwolf/patches: patch-CMakeLists.txt
Added Files:
        pkgsrc/ham/direwolf/patches: patch-src_CMakeLists.txt patch-src_cm108.c

Log Message:
direwolf: Add CM108 PTT support for NetBSD.

While here, mark BROKEN on big-endian machines since there appear to be
some audio processing issues.

Bump PKGREVISION.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 pkgsrc/ham/direwolf/Makefile \
    pkgsrc/ham/direwolf/distinfo
cvs rdiff -u -r1.1 -r1.2 pkgsrc/ham/direwolf/patches/patch-CMakeLists.txt
cvs rdiff -u -r0 -r1.1 pkgsrc/ham/direwolf/patches/patch-src_CMakeLists.txt \
    pkgsrc/ham/direwolf/patches/patch-src_cm108.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: pkgsrc/ham/direwolf/Makefile
diff -u pkgsrc/ham/direwolf/Makefile:1.1 pkgsrc/ham/direwolf/Makefile:1.2
--- pkgsrc/ham/direwolf/Makefile:1.1    Sat Apr 12 18:37:15 2025
+++ pkgsrc/ham/direwolf/Makefile        Sun Apr 13 16:07:15 2025
@@ -1,7 +1,8 @@
-# $NetBSD: Makefile,v 1.1 2025/04/12 18:37:15 jmcneill Exp $
+# $NetBSD: Makefile,v 1.2 2025/04/13 16:07:15 jmcneill Exp $
 
 DISTNAME=      1.7
 PKGNAME=       ${GITHUB_PROJECT}-${DISTNAME}
+PKGREVISION=   1
 CATEGORIES=    ham
 MASTER_SITES=  ${MASTER_SITE_GITHUB:=wb2osz/}
 GITHUB_PROJECT=        direwolf
@@ -22,7 +23,13 @@ CMAKE_CONFIGURE_ARGS+=       -DPORTAUDIO_LIBRA
 WRKSRC=                ${WRKDIR}/direwolf-1.7
 USE_LANGUAGES= c c++
 
+.include "../../mk/endian.mk"
+.if ${MACHINE_ENDIAN} == "big"
+BROKEN=                "Software does not function correctly on big-endian hosts"
+.endif
+
 .include "../../audio/portaudio/buildlink3.mk"
 .include "../../devel/cmake/build.mk"
 .include "../../ham/hamlib/buildlink3.mk"
+.include "../../sysutils/desktop-file-utils/desktopdb.mk"
 .include "../../mk/bsd.pkg.mk"
Index: pkgsrc/ham/direwolf/distinfo
diff -u pkgsrc/ham/direwolf/distinfo:1.1 pkgsrc/ham/direwolf/distinfo:1.2
--- pkgsrc/ham/direwolf/distinfo:1.1    Sat Apr 12 18:37:15 2025
+++ pkgsrc/ham/direwolf/distinfo        Sun Apr 13 16:07:15 2025
@@ -1,9 +1,11 @@
-$NetBSD: distinfo,v 1.1 2025/04/12 18:37:15 jmcneill Exp $
+$NetBSD: distinfo,v 1.2 2025/04/13 16:07:15 jmcneill Exp $
 
 BLAKE2s (direwolf/1.7.tar.gz) = 73c8f13681fa32683e7ca939effed4c4fc5fb302d4263c0e5176f21ca519b948
 SHA512 (direwolf/1.7.tar.gz) = e09b14d7a036546e042da8b536b70d07f485d6a7224b19f5626b33e43a21c48200591fd6680ca1ee4b3c9fb5909d6f1c54ae8160877d51e06278fe19516abe1e
 Size (direwolf/1.7.tar.gz) = 20587417 bytes
-SHA1 (patch-CMakeLists.txt) = 9a455c6bcb163b34d2904a08a4d0c1ce05de3df1
+SHA1 (patch-CMakeLists.txt) = 8d534090696b659544d14aae0182482947a05332
+SHA1 (patch-src_CMakeLists.txt) = 1611991ad7b85e764d409f387d01064def009dd3
 SHA1 (patch-src_audio.h) = 35f0683d1fd5ff16833e518ce2df8544cc3327be
+SHA1 (patch-src_cm108.c) = 74b39c8a6ac0ff85e92f34e0e02008db7d592968
 SHA1 (patch-src_decode__aprs.c) = 0a897894080d9921f3fe52a5bd971e90602d8b2b
 SHA1 (patch-src_symbols.c) = 510c0f1d98a3cd5710b7b05b362367483fb2f6c1

Index: pkgsrc/ham/direwolf/patches/patch-CMakeLists.txt
diff -u pkgsrc/ham/direwolf/patches/patch-CMakeLists.txt:1.1 pkgsrc/ham/direwolf/patches/patch-CMakeLists.txt:1.2
--- pkgsrc/ham/direwolf/patches/patch-CMakeLists.txt:1.1        Sat Apr 12 18:37:15 2025
+++ pkgsrc/ham/direwolf/patches/patch-CMakeLists.txt    Sun Apr 13 16:07:15 2025
@@ -1,4 +1,4 @@
-$NetBSD: patch-CMakeLists.txt,v 1.1 2025/04/12 18:37:15 jmcneill Exp $
+$NetBSD: patch-CMakeLists.txt,v 1.2 2025/04/13 16:07:15 jmcneill Exp $
 
 Allow pkgsrc to override INSTALL_MAN_DIR.
 
@@ -23,17 +23,21 @@ Allow pkgsrc to override INSTALL_MAN_DIR
  
  find_package(Git)
  if(GIT_FOUND AND EXISTS "${CMAKE_SOURCE_DIR}/.git/")
-@@ -177,6 +182,9 @@ elseif (WIN32)
+@@ -177,6 +182,13 @@ elseif (WIN32)
        set(CUSTOM_SHELL_BIN "")
      endif()
    endif()
 +elseif (PKGSRC)
 +  configure_file("${CMAKE_SOURCE_DIR}/cmake/cpack/${CMAKE_PROJECT_NAME}.desktop.in"
 +    "${CMAKE_BINARY_DIR}/${CMAKE_PROJECT_NAME}.desktop" @ONLY)
++endif()
++
++if(${CMAKE_SYSTEM_NAME} STREQUAL "NetBSD")
++  set(NETBSD TRUE)
  endif()
  
  if (C_CLANG OR C_GCC)
-@@ -254,7 +262,7 @@ else()
+@@ -254,7 +266,7 @@ else()
    set(INSTALL_DOC_DIR "share/doc/${CMAKE_PROJECT_NAME}")
    set(INSTALL_CONF_DIR "${INSTALL_DOC_DIR}/conf")
    set(INSTALL_SCRIPTS_DIR "${INSTALL_DOC_DIR}/scripts")
@@ -42,7 +46,18 @@ Allow pkgsrc to override INSTALL_MAN_DIR
      set(INSTALL_MAN_DIR "man/man1")
    else()
      set(INSTALL_MAN_DIR "share/man/man1")
-@@ -395,7 +403,7 @@ add_subdirectory(doc)
+@@ -361,6 +373,10 @@ else()
+   set(SNDIO_LIBRARIES "")
+ endif()
+ 
++if(NETBSD)
++  set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DUSE_CM108")
++endif()
++
+ # manage and fetch new data
+ add_subdirectory(data)
+ 
+@@ -395,7 +411,7 @@ add_subdirectory(doc)
  add_subdirectory(man)
  
  # install desktop link

Added files:

Index: pkgsrc/ham/direwolf/patches/patch-src_CMakeLists.txt
diff -u /dev/null pkgsrc/ham/direwolf/patches/patch-src_CMakeLists.txt:1.1
--- /dev/null   Sun Apr 13 16:07:16 2025
+++ pkgsrc/ham/direwolf/patches/patch-src_CMakeLists.txt        Sun Apr 13 16:07:16 2025
@@ -0,0 +1,36 @@
+$NetBSD: patch-src_CMakeLists.txt,v 1.1 2025/04/13 16:07:16 jmcneill Exp $
+
+Build and install cm108 utility on NetBSD.
+
+--- src/CMakeLists.txt.orig    2023-10-28 15:03:04.000000000 +0000
++++ src/CMakeLists.txt
+@@ -140,6 +140,12 @@ if(LINUX)
+     endif()
+ endif()
+ 
++if(NETBSD)
++  list(APPEND direwolf_SOURCES
++    cm108.c
++    )
++endif()
++
+ add_executable(direwolf
+   ${direwolf_SOURCES}
+   )
+@@ -472,7 +478,7 @@ endif()
+ # Version 1.7 adds it for Windows.  Needs hidapi library.
+ 
+ # cm108
+-if(UDEV_FOUND OR WIN32 OR CYGWIN)
++if(UDEV_FOUND OR WIN32 OR CYGWIN OR NETBSD)
+   list(APPEND cm108_SOURCES
+     cm108.c
+     textcolor.c
+@@ -568,6 +574,6 @@ install(TARGETS ttcalc DESTINATION ${INS
+ install(TARGETS kissutil DESTINATION ${INSTALL_BIN_DIR})
+ install(TARGETS tnctest DESTINATION ${INSTALL_BIN_DIR})
+ install(TARGETS appserver DESTINATION ${INSTALL_BIN_DIR})
+-if(UDEV_FOUND OR WIN32 OR CYGWIN)
++if(UDEV_FOUND OR WIN32 OR CYGWIN OR NETBSD)
+   install(TARGETS cm108 DESTINATION ${INSTALL_BIN_DIR})
+ endif()
Index: pkgsrc/ham/direwolf/patches/patch-src_cm108.c
diff -u /dev/null pkgsrc/ham/direwolf/patches/patch-src_cm108.c:1.1
--- /dev/null   Sun Apr 13 16:07:16 2025
+++ pkgsrc/ham/direwolf/patches/patch-src_cm108.c       Sun Apr 13 16:07:16 2025
@@ -0,0 +1,283 @@
+$NetBSD: patch-src_cm108.c,v 1.1 2025/04/13 16:07:16 jmcneill Exp $
+
+NetBSD support for CM108 PTT.
+
+--- src/cm108.c.orig   2023-10-28 15:03:04.000000000 +0000
++++ src/cm108.c
+@@ -138,6 +138,17 @@ int main (void)
+ #if __WIN32__
+ #include <wchar.h>
+ #include "hidapi.h"
++#elif defined(__NetBSD__)
++#include <sys/types.h>
++#include <sys/ioctl.h>
++#include <sys/audioio.h>
++#include <dev/usb/usb.h>
++#include <dev/usb/usbhid.h>
++#include <dirent.h>
++#include <errno.h>
++#include <fcntl.h>
++#include <string.h>
++#include <unistd.h>
+ #else
+ #include <libudev.h>
+ #include <sys/types.h>
+@@ -240,7 +251,7 @@ static int cm108_write (char *name, int 
+ 
+ // Used to process regular expression matching results.
+ 
+-#ifndef __WIN32__
++#if !defined(__WIN32__) && !defined(__NetBSD__)
+ 
+ static void substr_se (char *dest, const char *src, int start, int endp1)
+ {
+@@ -415,28 +426,40 @@ int main (int argc, char **argv)
+ /////////////////////////////////////////////
+ 
+ 
++#ifndef __NetBSD__
+       dw_printf ("    VID  PID   %-*s %-*s %-*s %-*s %-*s"
++#else
++      dw_printf ("    VID  PID   %-*s %-*s %-*s"
++#endif
+ #if EXTRA
+                                               " %-*s"
+ #endif
+                                               "\n",   (int)sizeof(things[0].product), "Product",
+                                                       (int)sizeof(things[0].devnode_sound), "Sound",
++#ifndef __NetBSD__
+                                                       (int)sizeof(things[0].plughw)/5, "ADEVICE",
+                                                       (int)sizeof(things[0].plughw2)/4, "ADEVICE",
++#endif
+                                                       17, "HID [ptt]"
+ #if EXTRA
+                                                       , (int)sizeof(things[0].devnode_usb), "USB"
+ #endif
+                                                       );
+ 
++#ifndef __NetBSD__
+       dw_printf ("    ---  ---   %-*s %-*s %-*s %-*s %-*s"
++#else
++      dw_printf ("    ---  ---   %-*s %-*s %-*s"
++#endif
+ #if EXTRA
+                                               " %-*s"
+ #endif
+                                               "\n",   (int)sizeof(things[0].product), "-------",
+                                                       (int)sizeof(things[0].devnode_sound), "-----",
++#ifndef __NetBSD__
+                                                       (int)sizeof(things[0].plughw)/5, "-------",
+                                                       (int)sizeof(things[0].plughw2)/4, "-------",
++#endif
+                                                       17, "---------"
+ #if EXTRA
+                                                       , (int)sizeof(things[0].devnode_usb), "---"
+@@ -444,7 +467,11 @@ int main (int argc, char **argv)
+                                                       );
+       for (i = 0; i < num_things; i++) {
+ 
++#ifndef __NetBSD__
+         dw_printf ("%2s  %04x %04x  %-*s %-*s %-*s %-*s %s"
++#else
++        dw_printf ("%2s  %04x %04x  %-*s %-*s %s"
++#endif
+ #if EXTRA
+                                               " %-*s"
+ #endif
+@@ -453,8 +480,10 @@ int main (int argc, char **argv)
+                                                       things[i].vid, things[i].pid,
+                                                       (int)sizeof(things[i].product), things[i].product,
+                                                       (int)sizeof(things[i].devnode_sound), things[i].devnode_sound,
++#ifndef __NetBSD__
+                                                       (int)sizeof(things[0].plughw)/5, things[i].plughw,
+                                                       (int)sizeof(things[0].plughw2)/4, things[i].plughw2,
++#endif
+                                                       things[i].devnode_hidraw
+ #if EXTRA
+                                                       , (int)sizeof(things[i].devnode_usb), things[i].devnode_usb
+@@ -466,6 +495,7 @@ int main (int argc, char **argv)
+       dw_printf ("** = Can use Audio Adapter GPIO for PTT.\n");
+       dw_printf ("\n");
+ 
++#ifndef __NetBSD__
+       static const char *suggested_names[] = {"Fred", "Wilma", "Pebbles", "Dino", "Barney", "Betty", "Bamm_Bamm", "Chip", "Roxy" };
+       int iname = 0;
+ 
+@@ -509,6 +539,8 @@ int main (int argc, char **argv)
+       dw_printf ("LABEL=\"my_usb_audio_end\"\n");
+       dw_printf ("\n");
+ #endif
++
++#endif
+       return (0);
+ }
+ 
+@@ -575,6 +607,117 @@ int cm108_inventory (struct thing_s *thi
+       }
+       hid_free_enumeration(devs);
+ 
++#elif defined(__NetBSD__)
++
++      DIR *dirp;
++      struct dirent *dp;
++
++      dirp = opendir("/dev");
++      if (dirp == NULL) {
++        text_color_set(DW_COLOR_ERROR);
++        dw_printf("cm108_inventory: opendir /dev failed.\n");
++        return (-1);
++      }
++
++      /* First look for audio devices. */
++      while ((dp = readdir(dirp)) != NULL) {
++        char *path;
++        int fd, ret;
++        struct audio_device adev;
++
++        if (dp->d_namlen <= 5 || strncmp(dp->d_name, "audio", 5) != 0) {
++          continue;
++        }
++        if (dp->d_name[5] < '0' || dp->d_name[5] > '9') {
++          continue;
++        }
++
++        if (asprintf(&path, "/dev/%s", dp->d_name) == -1) {
++          continue;
++        }
++        fd = open(path, O_RDWR);
++        if (fd == -1) {
++          free(path);
++          continue;
++        }
++
++        ret = ioctl(fd, AUDIO_GETDEV, &adev);
++        if (ret == 0 && num_things < max_things) {
++          char *product;
++
++          if (asprintf(&product, "%s %s", adev.name, adev.version) != -1) {
++            SAFE_STRCPY (things[num_things].product, product);
++            free(product);
++          } else {
++            SAFE_STRCPY (things[num_things].product, adev.name);
++          }
++          SAFE_STRCPY (things[num_things].card_name, path);
++          SAFE_STRCPY (things[num_things].devnode_usb, adev.config);
++          SAFE_STRCPY (things[num_things].devnode_sound, path);
++          things[num_things].vid = 0xffff;
++          things[num_things].pid = 0xffff;
++          num_things++;
++        }
++
++        free(path);
++        close(fd);
++      }
++      
++
++      /* Now look for USB HID devices. */
++      rewinddir(dirp);
++      while ((dp = readdir(dirp)) != NULL) {
++        char *path;
++        int fd, ret;
++        struct usb_device_info udi;
++
++        if (dp->d_namlen <= 4 || strncmp(dp->d_name, "uhid", 4) != 0) {
++          continue;
++        }
++        if (dp->d_name[4] < '0' || dp->d_name[4] > '9') {
++          continue;
++        }
++
++        if (asprintf(&path, "/dev/%s", dp->d_name) == -1) {
++          continue;
++        }
++        fd = open(path, O_RDWR);
++        if (fd == -1) {
++          free(path);
++          continue;
++        }
++
++        ret = ioctl(fd, USB_GET_DEVICEINFO, &udi);
++        if (ret == 0) {
++          char *usbdev;
++
++          if (asprintf(&usbdev, "usb:%08x", udi.udi_cookie.cookie) != -1) {
++            for (int i = 0; i < num_things; i++) {
++              if (strcmp(usbdev, things[i].devnode_usb) == 0) {
++                char *product;
++
++                things[i].vid = udi.udi_vendorNo;
++                things[i].pid = udi.udi_productNo;
++                SAFE_STRCPY (things[i].devnode_hidraw, path);
++                if (asprintf(&product, "%s %s", udi.udi_vendor, udi.udi_product) != -1) {
++                  SAFE_STRCPY (things[i].product, product);
++                  free(product);
++                } else {
++                  SAFE_STRCPY (things[i].product, udi.udi_product);
++                }
++                break;
++              }
++              }
++              free(usbdev);
++            }
++        }
++
++        free(path);
++        close(fd);
++      }
++
++      closedir(dirp);
++
+ #else // Linux, with udev
+ 
+       struct udev *udev;
+@@ -812,6 +955,20 @@ void cm108_find_ptt (char *output_audio_
+       }
+       dw_printf ("Run the \"cm108\" utility for more details.\n");
+       text_color_set(DW_COLOR_INFO);
++
++#elif defined(__NetBSD__)
++      for (int i = 0; i < num_things; i++) {
++        if (strcmp(output_audio_device, things[i].card_name) == 0) {
++          strlcpy (ptt_device, things[i].devnode_hidraw, ptt_device_size);
++          if ( ! GOOD_DEVICE(things[i].vid,things[i].pid) ) {
++            text_color_set(DW_COLOR_ERROR);
++            dw_printf ("Warning: USB audio card %s (%s) is not a device known to work with GPIO PTT.\n",
++                              things[i].card_number, things[i].card_name);
++          }
++          return;
++        }
++      }
++
+ #else
+       regex_t sound_re;
+       char emsg[100];
+@@ -962,6 +1119,29 @@ static int cm108_write (char *name, int 
+ 
+       hid_close(handle);
+ 
++#elif defined(__NetBSD__)
++      struct usb_ctl_report ucr = {
++        .ucr_report = UHID_OUTPUT_REPORT,
++        .ucr_data = { 0, iodata, iomask, 0 },
++      };
++      int fd;
++
++      fd = open(name, O_RDWR);
++      if (fd == -1) {
++        text_color_set(DW_COLOR_ERROR);
++        dw_printf ("Could not open %s for write: %s\n", name, strerror(errno));
++        return (-1);
++      }
++
++      if (ioctl(fd, USB_SET_REPORT, &ucr) == -1) {
++        text_color_set(DW_COLOR_ERROR);
++        dw_printf ("Could not set %s report: %s\n", name, strerror(errno));
++        close(fd);
++        return (-1);
++      }
++
++      close(fd);
++
+ #else
+       int fd;
+       struct hidraw_devinfo info;



Home | Main Index | Thread Index | Old Index