Initial NetBSD port

This commit is contained in:
Tom Ivar Helbekkmo 2018-04-29 10:07:52 +02:00
parent c8441b106a
commit c8f4fdc713
6 changed files with 26 additions and 9 deletions

View file

@ -57,6 +57,9 @@ endif
endif
# For 10.2 and later, use iconv from base, no extra include path required.
else ifeq ($(UNAME),NetBSD)
CFLAGS += -I/usr/pkg/include/libusb-1.0
LDFLAGS+= -shared -L/usr/pkg/lib -lusb-1.0 -Wl,-rpath=/usr/pkg/lib
else
LDFLAGS += -shared -Wl,-soname,$(SHARED_LIB_NAME)
LIBS += -ludev
@ -72,6 +75,8 @@ ifeq ($(UNAME),Darwin)
SOURCES_HIDAPI =$(top_srcdir)/cpp/hidapi/mac
else ifeq ($(UNAME),FreeBSD)
SOURCES_HIDAPI =$(top_srcdir)/cpp/hidapi/libusb
else ifeq ($(UNAME),NetBSD)
SOURCES_HIDAPI =$(top_srcdir)/cpp/hidapi/libusb
else
SOURCES_HIDAPI =$(top_srcdir)/cpp/hidapi/linux
endif
@ -82,13 +87,14 @@ SOURCES := $(top_srcdir)/cpp/src $(top_srcdir)/cpp/src/command_classes $(top_sr
VPATH = $(top_srcdir)/cpp/src:$(top_srcdir)/cpp/src/command_classes:$(top_srcdir)/cpp/tinyxml:\
$(top_srcdir)/cpp/src/value_classes:$(top_srcdir)/cpp/src/platform:$(top_srcdir)/cpp/src/platform/unix:$(SOURCES_HIDAPI):$(top_srcdir)/cpp/src/aes/
tinyxml := $(notdir $(wildcard $(top_srcdir)/cpp/tinyxml/*.cpp))
ifeq ($(UNAME),Darwin)
hidapi := $(notdir $(wildcard $(top_srcdir)/cpp/hidapi/mac/*.c))
else ifeq ($(UNAME),FreeBSD)
hidapi := $(notdir $(wildcard $(top_srcdir)/cpp/hidapi/libusb/*.c))
else ifeq ($(UNAME),NetBSD)
hidapi := $(notdir $(wildcard $(top_srcdir)/cpp/hidapi/libusb/*.c))
else
hidapi := $(notdir $(wildcard $(top_srcdir)/cpp/hidapi/linux/*.c)) # we do not want the libusb version
endif

View file

@ -123,15 +123,18 @@ export top_builddir
OBJDIR = $(top_builddir)/.lib
DEPDIR = $(top_builddir)/.dep
ifeq ($(UNAME),NetBSD)
FMTCMD = fmt -g 1
else
FMTCMD = fmt -1
endif
$(OBJDIR)/%.o : %.cpp
@echo "Building $(notdir $@)"
@$(CXX) -MM $(CFLAGS) $(INCLUDES) $< > $(DEPDIR)/$*.d
@mv -f $(DEPDIR)/$*.d $(DEPDIR)/$*.d.tmp
@$(SED) -e 's|.*:|$(OBJDIR)/$*.o: $(DEPDIR)/$*.d|' < $(DEPDIR)/$*.d.tmp > $(DEPDIR)/$*.d;
@$(SED) -e 's/.*://' -e 's/\\$$//' < $(DEPDIR)/$*.d.tmp | fmt -1 | \
@$(SED) -e 's/.*://' -e 's/\\$$//' < $(DEPDIR)/$*.d.tmp | $(FMTCMD) | \
$(SED) -e 's/^ *//' -e 's/$$/:/' >> $(DEPDIR)/.$*.d;
@rm -f $(DEPDIR)/$*.d.tmp
@$(CXX) $(CFLAGS) $(TARCH) $(INCLUDES) -o $@ $<
@ -142,7 +145,7 @@ $(OBJDIR)/%.o : %.c
@$(CC) -MM $(CFLAGS) $(INCLUDES) $< > $(DEPDIR)/$*.d
@mv -f $(DEPDIR)/$*.d $(DEPDIR)/$*.d.tmp
@$(SED) -e 's|.*:|$(OBJDIR)/$*.o: $(DEPDIR)/$*.d|' < $(DEPDIR)/$*.d.tmp > $(DEPDIR)/$*.d;
@$(SED) -e 's/.*://' -e 's/\\$$//' < $(DEPDIR)/$*.d.tmp | fmt -1 | \
@$(SED) -e 's/.*://' -e 's/\\$$//' < $(DEPDIR)/$*.d.tmp | $(FMTCMD) | \
$(SED) -e 's/^ *//' -e 's/$$/:/' >> $(DEPDIR)/.$*.d;
@rm -f $(DEPDIR)/$*.d.tmp
@$(CC) $(CFLAGS) $(TARCH) $(INCLUDES) -o $@ $<

View file

@ -53,6 +53,8 @@ LDFLAGS+= -L/usr/local/lib -liconv
endif
endif
else ifeq ($(UNAME),NetBSD)
LDFLAGS+= -L/usr/pkg/lib -lusb-1.0
endif
$(OBJDIR)/MinOZW: $(patsubst %.cpp,$(OBJDIR)/%.o,$(minozwsrc))

View file

@ -369,7 +369,7 @@ static wchar_t *get_usb_string(libusb_device_handle *dev, uint8_t idx)
inbytes = len-2;
outptr = (char*) wbuf;
outbytes = sizeof(wbuf);
res = iconv(ic, &inptr, &inbytes, &outptr, &outbytes);
res = iconv(ic, (const char ** restrict)&inptr, &inbytes, &outptr, &outbytes);
if (res == (size_t)-1) {
LOG("iconv() failed\n");
goto err;

View file

@ -52,7 +52,9 @@ EventImpl::EventImpl
pthread_condattr_t ca;
pthread_condattr_init( &ca );
#ifndef __NetBSD__
pthread_condattr_setpshared( &ca, PTHREAD_PROCESS_PRIVATE );
#endif
pthread_cond_init( &m_condition, &ca );
pthread_condattr_destroy( &ca );
}

View file

@ -185,7 +185,11 @@ bool SerialControllerImpl::Init
Log::Write( LogLevel_Info, "Trying to open serial port %s (attempt %d)", device.c_str(), _attempts );
#ifdef __NetBSD__
m_hSerialController = open( device.c_str(), O_RDWR | O_NOCTTY | O_NONBLOCK);
#else
m_hSerialController = open( device.c_str(), O_RDWR | O_NOCTTY, 0 );
#endif
if( -1 == m_hSerialController )
{