Hide libx52 internal symbols

Prior to this change, all symbols were being exported in the generated
library. This change adds libtool directives to only export the public
symbols in libx52.
pull/22/head
nirenjan 2020-06-06 07:41:13 -07:00
parent 89c233e244
commit bac20b410d
4 changed files with 22 additions and 15 deletions

View File

@ -10,10 +10,17 @@ lib_LTLIBRARIES = libx52.la
# Core libx52 library
# This library handles the USB communication between the host and the X52
# Libtool Version Info
# See: https://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
libx52_v_CUR=4
libx52_v_AGE=2
libx52_v_REV=0
libx52_la_SOURCES = x52_control.c x52_core.c x52_date_time.c x52_mfd_led.c \
x52_strerror.c
libx52_la_CFLAGS = @LIBUSB_CFLAGS@ -DLOCALEDIR=\"$(localedir)\" -I $(top_srcdir)
libx52_la_LDFLAGS = -version-info 4:0:2 @LIBUSB_LIBS@
libx52_la_LDFLAGS = \
-export-symbols-regex '^libx52_' \
-version-info $(libx52_v_CUR):$(libx52_v_REV):$(libx52_v_AGE) @LIBUSB_LIBS@
libx52_la_LIBADD = @LTLIBINTL@
# Header files that need to be copied

View File

@ -104,6 +104,6 @@ static inline uint32_t tst_bit(uint32_t *value, uint32_t bit)
return (*value & (1UL << bit));
}
int libx52internal_translate_libusb_error(enum libusb_error errcode);
int _x52_translate_libusb_error(enum libusb_error errcode);
#endif /* !defined X52JOY_COMMON_H */

View File

@ -18,7 +18,7 @@
#include "x52_common.h"
/* Translate a libusb error to a libx52 error */
int libx52internal_translate_libusb_error(enum libusb_error errcode)
int _x52_translate_libusb_error(enum libusb_error errcode)
{
switch (errcode) {
case LIBUSB_SUCCESS:
@ -89,10 +89,10 @@ int libx52_vendor_command(libx52_device *x52, uint16_t index, uint16_t value)
}
}
return libx52internal_translate_libusb_error(rc);
return _x52_translate_libusb_error(rc);
}
static int libx52_write_line(libx52_device *x52, uint8_t line_index)
static int _x52_write_line(libx52_device *x52, uint8_t line_index)
{
uint8_t i;
uint16_t value;
@ -125,7 +125,7 @@ static int libx52_write_line(libx52_device *x52, uint8_t line_index)
return rc;
}
static int libx52_write_date(libx52_device *x52)
static int _x52_write_date(libx52_device *x52)
{
uint16_t value1; //dd-mm
uint16_t value2; //yy
@ -162,7 +162,7 @@ static int libx52_write_date(libx52_device *x52)
return rc;
}
static int libx52_write_time(libx52_device *x52, libx52_clock_id clock)
static int _x52_write_time(libx52_device *x52, libx52_clock_id clock)
{
uint16_t value = 0;
uint16_t index;
@ -280,15 +280,15 @@ int libx52_update(libx52_device *x52)
break;
case X52_BIT_MFD_LINE1:
rc = libx52_write_line(x52, 0);
rc = _x52_write_line(x52, 0);
break;
case X52_BIT_MFD_LINE2:
rc = libx52_write_line(x52, 1);
rc = _x52_write_line(x52, 1);
break;
case X52_BIT_MFD_LINE3:
rc = libx52_write_line(x52, 2);
rc = _x52_write_line(x52, 2);
break;
case X52_BIT_POV_BLINK:
@ -308,19 +308,19 @@ int libx52_update(libx52_device *x52)
break;
case X52_BIT_MFD_DATE:
rc = libx52_write_date(x52);
rc = _x52_write_date(x52);
break;
case X52_BIT_MFD_TIME:
rc = libx52_write_time(x52, LIBX52_CLOCK_1);
rc = _x52_write_time(x52, LIBX52_CLOCK_1);
break;
case X52_BIT_MFD_OFFS1:
rc = libx52_write_time(x52, LIBX52_CLOCK_2);
rc = _x52_write_time(x52, LIBX52_CLOCK_2);
break;
case X52_BIT_MFD_OFFS2:
rc = libx52_write_time(x52, LIBX52_CLOCK_3);
rc = _x52_write_time(x52, LIBX52_CLOCK_3);
break;
default:

View File

@ -89,7 +89,7 @@ int libx52_connect(libx52_device *dev)
if (libx52_check_product(desc.idVendor, desc.idProduct)) {
rc = libusb_open(device, &hdl);
if (rc) {
return libx52internal_translate_libusb_error(rc);
return _x52_translate_libusb_error(rc);
}
dev->hdl = hdl;