Skip to content

Commit

Permalink
tools/nut-scanner/nutscan-init.c, include/nut_platform.h, m4/ax_realp…
Browse files Browse the repository at this point in the history
…ath_lib.m4: move definition of SOEXT to the header [networkupstools#2431]

This would allow the multiplatform-aware library-picking
logic to be used elsewhere (e.g. DMF) eventually.

Signed-off-by: Jim Klimov <[email protected]>
  • Loading branch information
jimklimov committed Jul 15, 2024
1 parent d927fa0 commit dc49c95
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 26 deletions.
30 changes: 30 additions & 0 deletions include/nut_platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@
/** Apple OS based on Mach ukernel */
# define NUT_PLATFORM_APPLE_MACH

/* https://stackoverflow.com/a/2339910/4715872 */
# ifndef SOEXT
# define SOEXT ".dylib"
# endif

# include <TargetConditionals.h>

# if (defined TARGET_OS_EMBEDDED)
Expand Down Expand Up @@ -64,6 +69,10 @@
/** Windows */
# define NUT_PLATFORM_MS_WINDOWS

# ifndef SOEXT
# define SOEXT ".dll"
# endif

# if (defined NTDDI_WIN8 && NTDDI_VERSION >= NTDDI_WIN8)
/** Windows 8 */
# define NUT_PLATFORM_MS_WINDOWS8
Expand Down Expand Up @@ -94,6 +103,22 @@
# if (defined __hpux)
/** Hewlett-Packard HP-UX (implies \ref NUT_PLATFORM_UNIX) */
# define NUT_PLATFORM_HPUX

/* Note: depending on CPU arch and OS version, library file
* name patterns here could have been "*.so" as well.
* E.g. per
* https://community.hpe.com/t5/operating-system-hp-ux/so-and-sl-files/td-p/3780528
* *.sl are used in PA-RISC (11.11)
* *.so shared libraries are used in HP-UX 11.20 and upwards.
* Integrity (Itanium-based) HPUX can use *.sl as well,
* but it is not recommended, see ld(1) under -lx:
* https://web.archive.org/web/20090925153446/http://docs.hp.com/en/B2355-60103/ld.1.html
*/
/* FIXME: May want to detect better the CPU or OS version
* to decide the SOEXT here*/
# ifndef SOEXT
# define SOEXT ".sl"
# endif
# endif
# if (defined _AIX)
/** AIX (implies \ref NUT_PLATFORM_UNIX) */
Expand Down Expand Up @@ -121,5 +146,10 @@
# endif
#endif

/* not WIN32, not MACOS, not HPUX... */
#ifndef SOEXT
# define SOEXT ".so"
#endif

#endif /* NUT_PLATFORM_H_SEEN */

2 changes: 1 addition & 1 deletion m4/ax_realpath_lib.m4
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ AC_DEFUN([AX_REALPATH_LIB],
[*mingw*], [myLIBNAME="${myLIBNAME}.dll"],
[*darwin*], [myLIBNAME="${myLIBNAME}.dylib"],
[*hpux*|*hp?ux*], [
dnl # See detailed comments in nutscan-init.c
dnl # See detailed comments in nut_platform.h
myLIBNAME="${myLIBNAME}.sl"
],[myLIBNAME="${myLIBNAME}.so"])
]
Expand Down
25 changes: 0 additions & 25 deletions tools/nut-scanner/nutscan-init.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,31 +43,6 @@
# endif
#endif

/* FIXME: We may want to (also?) use lt_dlopenext(), so
* that libtool would offer platform-specific extensions */
#ifdef WIN32
# define SOEXT ".dll"
#else
# ifdef NUT_PLATFORM_APPLE_OSX
# define SOEXT ".dylib"
# else
# ifdef NUT_PLATFORM_HPUX
/* Note: depending on CPU arch and OS version, library file name
* patterns here could have been "*.so" as well. E.g. per
* https://community.hpe.com/t5/operating-system-hp-ux/so-and-sl-files/td-p/3780528
* *.sl are used in PA-RISC (11.11)
* *.so shared libraries are used in HP-UX 11.20 and upwards.
* Integrity (Itanium-based) HPUX can use *.sl as well, but it
* is not recommended, see ld(1) under -lx:
* https://web.archive.org/web/20090925153446/http://docs.hp.com/en/B2355-60103/ld.1.html
*/
# define SOEXT ".sl"
# else /* not WIN32, not MACOS, not HPUX */
# define SOEXT ".so"
# endif
# endif
#endif

/* Flags for code paths we can support in this run (libs available or not
* needed). For consistency, only set non-zero values via nutscan_init() call.
*/
Expand Down

0 comments on commit dc49c95

Please sign in to comment.