# Starter to building webrtc on FreeBSD



## sossego (Feb 2, 2014)

For reason that this project will be a continuing effort, I have decided to include the information and processes known to me to this date.

Set $PATH to include /usr/local/bin/python

```
export PATH=$PATH:/usr/local/bin/python
```
Download depot_tools from Google:: Instructions: http://www.chromium.org/developers/how-tos/depottools
Add depot_tools to PATH with 
	
	



```
export PATH=$PATH:/home/$USER/depot_tools
```
Download brltty:: http://mielke.cc/brltty/

You will need to do the following with brltty: 
 A visual editor such as SciTE must be ran as root - i.e su to root - for reason you will be editing files in /usr/local/include/unicode.
 The command of 
	
	



```
./configure --prefix=/usr/local && gmake
```
 must be ran after each instance of editing the unicode variables.

Download webrtc from Google: http://www.webrtc.org/reference/getting-started
You will need to create a directory for the version of FreeBSD that you are using. 
	
	



```
mkdir webrtc/trunk/build/$FReeBSD_version_number
```
 It should look like webrtc/trunk/build/freebsd10 or such.
The files in webrtc/trunk/build/linux must be redited and moved to the webrtc/trunk/build/FreeBSD_version_number

This is as far as I have been able to build because I am still working on this. Anyone else that decides to work on installing webrtc on FreeBSD and wants to port it, please include additional instructions to this howto for others to see your work.

At this point brltty-4.4/Programs/unicode.c as .unicode.c will come up in the error. Edit it and just do `gmake distclean` followed by `gmake`.
You will need to import prologue.h from the parent directory. `cp ../prologue.h $PWD/`
The next error that I am stuck at is:

```
./usb_serial.c:455:34: warning: unused variable 'usbSerialOperations_FTDI_SIO'
      [-Wunused-const-variable]
static const UsbSerialOperations usbSerialOperations_FTDI_SIO = {
                                 ^
1 warning generated.
/usr/local/bin/clang -I. -I. -I./../Programs -I../Programs -I./.. -I..    -DHAVE_CONFIG_H -g -O2 -std=gnu99 -Wall -fPIC  -c ./usb_freebsd.c
In file included from ./usb_freebsd.c:34:
./usb_bsd.h:38:21: error: use of undeclared identifier 'USB_SET_TIMEOUT'
    if (ioctl(file, USB_SET_TIMEOUT, &arg) == -1) {
                    ^
./usb_bsd.h:49:19: error: use of undeclared identifier 'USB_SET_SHORT_XFER'
  if (ioctl(file, USB_SET_SHORT_XFER, &arg) != -1) return 1;
                  ^
./usb_bsd.h:75:25: error: use of undeclared identifier 'USB_SET_CONFIG'
  if (ioctl(devx->file, USB_SET_CONFIG, &arg) != -1) return 1;
                        ^
./usb_bsd.h:113:28: error: variable has incomplete type 'struct
      usb_alt_interface'
  struct usb_alt_interface arg;
                           ^
./usb_bsd.h:113:10: note: forward declaration of 'struct usb_alt_interface'
  struct usb_alt_interface arg;
         ^
./usb_bsd.h:117:25: error: use of undeclared identifier 'USB_SET_ALTINTERFACE'
  if (ioctl(devx->file, USB_SET_ALTINTERFACE, &arg) != -1) return 1;
                        ^
./usb_bsd.h:146:26: error: variable has incomplete type 'struct usb_ctl_request'
  struct usb_ctl_request arg;
                         ^
./usb_bsd.h:146:10: note: forward declaration of 'struct usb_ctl_request'
  struct usb_ctl_request arg;
         ^
./usb_bsd.h:154:19: error: use of undeclared identifier 'USBD_SHORT_XFER_OK'
  arg.ucr_flags = USBD_SHORT_XFER_OK;
                  ^
./usb_bsd.h:156:27: error: use of undeclared identifier 'USB_DO_REQUEST'
    if (ioctl(devx->file, USB_DO_REQUEST, &arg) != -1) return arg.ucr_actlen;
                          ^
./usb_bsd.h:246:25: error: use of undeclared identifier 'USB_GET_DEVICE_DESC'
  if (ioctl(devx->file, USB_GET_DEVICE_DESC, &device->descriptor) != -1) {
                        ^
./usb_bsd.h:323:32: error: variable has incomplete type 'struct usb_device_info'
        struct usb_device_info info;
                               ^
./usb_bsd.h:323:16: note: forward declaration of 'struct usb_device_info'
        struct usb_device_info info;
               ^
./usb_bsd.h:326:24: error: use of undeclared identifier 'USB_DEVICEINFO'
        if (ioctl(bus, USB_DEVICEINFO, &info) != -1) {
                       ^
./usb_bsd.h:334:43: error: use of undeclared identifier 'USB_MAX_DEVNAMES'
            for (nameNumber=0; nameNumber<USB_MAX_DEVNAMES; nameNumber++) {
                                          ^
12 errors generated.
gmake[1]: *** [usb_freebsd.o] Error 1
gmake[1]: Leaving directory `/usr/home/raspycat/Firefox_Downloads/brltty-4.4/Programs'
```

I have set configure as `./configure CC=/usr/local/bin/clang CXX=/usr/local/bin/clang++ CPP=/usr/local/bin/clang-cpp --prefix=/usr/local/` . You can use this for whatever compiler and preprocessor you have.

Running `./configure` will need the following flag of `CXXFLAGS=-Wno-unused-variable` appended to the `./configure` suggested earlier.

Forgive me if things may seem repetitive; but, I want this "porting effort" to be public. WebRTC is not a bad idea considering it means using firefox, chrome, or even konqueror for voice and video chat. Perhaps a no-Skype-dependency allowing people to use whatever they want on their own machines.

Further error reporting by comparison::
	
	



```
static int
usbSetTimeout (int file, int new, int *old) {
  if (!old || (new != *old)) {
    int arg = new;
    if (ioctl(file, USB_SET_TIMEOUT, &arg) == -1) {
      logSystemError("USB timeout set");
      return 0;
    }
    if (old) *old = new;
  }
  return 1;
}
```

Notice that "usbSetTimeout" and USB_SET_TIMEOUT don't match. I'm thinking that either they should both match or that 
	
	



```
usbSetTimeout = USB_SET_TIMEOUT
```
 somewhere in the picture.


----------



## sossego (Feb 3, 2014)

In usb_bsd.h add 
	
	



```
#include </usr/include/libusb.h>
```
 to the other lists of includes. 
References to 





> USB_SET_TIMEOUT


 and a solution- to which I do not know currently how to implement:: http://permalink.gmane.org/gmane.os.fre ... l.usb/5915

The following is  a corrected version of usb_bsd.h and should be saved as such to replace the current in brltty-4.4/Programs

```
/*
 * BRLTTY - A background process providing access to the console screen (when in
 *          text mode) for a blind person using a refreshable braille display.
 *
 * Copyright (C) 1995-2012 by The BRLTTY Developers.
 *
 * BRLTTY comes with ABSOLUTELY NO WARRANTY.
 *
 * This is free software, placed under the terms of the
 * GNU General Public License, as published by the Free Software
 * Foundation; either version 2 of the License, or (at your option) any
 * later version. Please see the file LICENSE-GPL for details.
 *
 * Web Page: http://mielke.cc/brltty/
 *
 * This software is maintained by Dave Mielke <dave@mielke.cc>.
 */

#include </usr/include/libusb.h>
#include <limits.h>
#include </usr/include/dev/usb/usb.h>
#include </usr/include/dev/usb/usb_ioctl.h>
#include </usr/include/dev/usb/usb_compat_linux.h>
#include </usr/include/dev/usb/usbdi.h>
#include </usr/include/dev/usb/ufm_ioctl.h>
#include </usr/include/dev/usb/usb_bus.h>
#include </usr/include/dev/usb/usb_busdma.h>
#include </usr/include/dev/usb/usb_cdc.h>
#include </usr/include/dev/usb/usb_controller.h>
#include </usr/include/dev/usb/usb_core.h>
#include </usr/include/dev/usb/usb_debug.h>
#include </usr/include/dev/usb/usb_dev.h>
#include </usr/include/dev/usb/usb_device.h>
#include </usr/include/dev/usb/usb_dynamic.h>
#include </usr/include/dev/usb/usb_endian.h>
#include </usr/include/dev/usb/usb_freebsd.h>
#include </usr/include/dev/usb/usb_freebsd_loader.h>
#include </usr/include/dev/usb/usb_generic.h>
#include </usr/include/dev/usb/usb_hub.h>
#include </usr/include/dev/usb/usb_mbuf.h>
#include </usr/include/dev/usb/usb_msctest.h>
#include </usr/include/dev/usb/usb_pci.h>
#include </usr/include/dev/usb/usb_pf.h>
#include </usr/include/dev/usb/usb_process.h>
#include </usr/include/dev/usb/usb_request.h>
#include </usr/include/dev/usb/usb_transfer.h>
#include </usr/include/dev/usb/usb_util.h>
#include </usr/inlcude/dev/usb/usbdi_util.h>
#include </usr/include/dev/usb/usbhid.h>
#include </usr/include/syslog.h>
#include </usr/include/limits.h>
#include </usr/include/sys/limits.h>
S



#include "log.h"

struct UsbDeviceExtensionStruct {
  char *path;
  int file;
  int timeout;
};

struct UsbEndpointExtensionStruct {
  int file;
  int timeout;
};

#define USB_SET_TX_TIMEOUT _IOW ('U', 137, int)

static int
usbSetTimeout (int file, int new, int *old) {
  if (!old || (new != *old)) {
    int arg = new;
    if (ioctl(file, USB_SET_TX_TIMEOUT, &arg) == -1) {
      logSystemError("USB timeout set");
      return 0;
    }
    if (old) *old = new;
  }
  return 1;
}

#define USB_SET_RX_SHORT_XFER
static int
usbSetShortTransfers (int file, int arg) {
  if (ioctl(file, USB_SET_RX_SHORT_XFER, &arg) != -1) return 1;
  logSystemError("USB set short transfers");
  return 0;
}

int
usbResetDevice (UsbDevice *device) {
  errno = ENOSYS;
  logSystemError("USB device reset");
  return 0;
}

int
usbDisableAutosuspend (UsbDevice *device) {
  errno = ENOSYS;
  logSystemError("USB device autosuspend disable");
  return 0;
}

#define USB_SET_CONFIG
int
usbSetConfiguration (
  UsbDevice *device,
  unsigned char configuration
) {
  UsbDeviceExtension *devx = device->extension;
  int arg = configuration;
  if (ioctl(devx->file, USB_SET_CONFIG, &arg) != -1) return 1;
  logSystemError("USB configuration set");
  return 0;
}

int
usbClaimInterface (
  UsbDevice *device,
  unsigned char interface
) {
  return 1;
/*
  errno = ENOSYS;
  logSystemError("USB interface claim");
  return 0;
*/
}

int
usbReleaseInterface (
  UsbDevice *device,
  unsigned char interface
) {
  return 1;
/*
  errno = ENOSYS;
  logSystemError("USB interface release");
  return 0;
*/
}

#define USB_SET_ALTINTERFACE

int
usbSetAlternative (
  UsbDevice *device,
  unsigned char interface,
  unsigned char alternative
) {
  UsbDeviceExtension *devx = device->extension;
  struct usb_alt_interface arg;
  memset(&arg, 0, sizeof(arg));
  arg.uai_interface_index = interface;
  arg.uai_alt_no = alternative;
  if (ioctl(devx->file, USB_SET_ALTINTERFACE, &arg) != -1) return 1;
  logSystemError("USB alternative set");
  return 0;
}

#define USB_DO_REQUEST
#define USBD_SHORT_XFER_OK
int
usbClearEndpoint (
  UsbDevice *device,
  unsigned char endpointAddress
) {
  errno = ENOSYS;
  logSystemError("USB endpoint clear");
  return 0;
}

ssize_t
usbControlTransfer (
  UsbDevice *device,
  uint8_t direction,
  uint8_t recipient,
  uint8_t type,
  uint8_t request,
  uint16_t value,
  uint16_t index,
  void *buffer,
  uint16_t length,
  int timeout
) {
  UsbDeviceExtension *devx = device->extension;
  struct usb_ctl_request arg;
  memset(&arg, 0, sizeof(arg));
  arg.ucr_request.bmRequestType = direction | recipient | type;
  arg.ucr_request.bRequest = request;
  USETW(arg.ucr_request.wValue, value);
  USETW(arg.ucr_request.wIndex, index);
  USETW(arg.ucr_request.wLength, length);
  arg.ucr_data = buffer;
  arg.ucr_flags = USBD_SHORT_XFER_OK;
  if (usbSetTimeout(devx->file, timeout, &devx->timeout)) {
    if (ioctl(devx->file, USB_DO_REQUEST, &arg) != -1) return arg.ucr_actlen;
    logSystemError("USB control transfer");
  }
  return -1;
}

void *
usbSubmitRequest (
  UsbDevice *device,
  unsigned char endpointAddress,
  void *buffer,
  size_t length,
  void *context
) {
  errno = ENOSYS;
  logSystemError("USB request submit");
  return NULL;
}

int
usbCancelRequest (
  UsbDevice *device,
  void *request
) {
  errno = ENOSYS;
  logSystemError("USB request cancel");
  return 0;
}

void *
usbReapResponse (
  UsbDevice *device,
  unsigned char endpointAddress,
  UsbResponse *response,
  int wait
) {
  errno = ENOSYS;
  logSystemError("USB request reap");
  return NULL;
}

ssize_t
usbReadEndpoint (
  UsbDevice *device,
  unsigned char endpointNumber,
  void *buffer,
  size_t length,
  int timeout
) {
  ssize_t count = -1;
  UsbEndpoint *endpoint = usbGetInputEndpoint(device, endpointNumber);
  if (endpoint) {
    UsbEndpointExtension *eptx = endpoint->extension;
    if (usbSetTimeout(eptx->file, timeout, &eptx->timeout)) {
      if ((count = read(eptx->file, buffer, length)) != -1) {
        if (!usbApplyInputFilters(device, buffer, length, &count)) {
          errno = EIO;
          count = -1;
        }
      } else if (errno != ETIMEDOUT) {
        logSystemError("USB endpoint read");
      }
    }
  }
  return count;
}

ssize_t
usbWriteEndpoint (
  UsbDevice *device,
  unsigned char endpointNumber,
  const void *buffer,
  size_t length,
  int timeout
) {
  UsbEndpoint *endpoint = usbGetOutputEndpoint(device, endpointNumber);
  if (endpoint) {
    UsbEndpointExtension *eptx = endpoint->extension;
    if (usbSetTimeout(eptx->file, timeout, &eptx->timeout)) {
      ssize_t count = write(eptx->file, buffer, length);
      if (count != -1) return count;
      logSystemError("USB endpoint write");
    }
  }
  return -1;
}

#define USB_GET_DEVICE_DESC

int
usbReadDeviceDescriptor (UsbDevice *device) {
  UsbDeviceExtension *devx = device->extension;
  if (ioctl(devx->file, USB_GET_DEVICE_DESC, &device->descriptor) != -1) {
    return 1;
  }
  logSystemError("USB device descriptor read");
  return 0;
}

#define PATH_MAX

int
usbAllocateEndpointExtension (UsbEndpoint *endpoint) {
  UsbDeviceExtension *devx = endpoint->device->extension;
  UsbEndpointExtension *eptx;

  if ((eptx = malloc(sizeof(*eptx)))) {
    const char *prefix = devx->path;
    const char *dot = strchr(prefix, '.');
    int length = dot? (dot - prefix): strlen(prefix);
    char path[PATH_MAX+1];
    int flags = O_RDWR;

    snprintf(path, sizeof(path), USB_ENDPOINT_PATH_FORMAT,
             length, prefix, USB_ENDPOINT_NUMBER(endpoint->descriptor));

    switch (USB_ENDPOINT_DIRECTION(endpoint->descriptor)) {
      case UsbEndpointDirection_Input : flags = O_RDONLY; break;
      case UsbEndpointDirection_Output: flags = O_WRONLY; break;
    }

    if ((eptx->file = open(path, flags)) != -1) {
      if (((flags & O_ACCMODE) != O_RDONLY) || 
          usbSetShortTransfers(eptx->file, 1)) {
        eptx->timeout = -1;

        endpoint->extension = eptx;
        return 1;
      }

      close(eptx->file);
    }

    free(eptx);
  }

  return 0;
}

void
usbDeallocateEndpointExtension (UsbEndpointExtension *eptx) {
  if (eptx->file != -1) {
    close(eptx->file);
    eptx->file = -1;
  }

  free(eptx);
}

void
usbDeallocateDeviceExtension (UsbDeviceExtension *devx) {
  if (devx->file != -1) {
    close(devx->file);
    devx->file = -1;
  }

  free(devx->path);
  free(devx);
}

#define USB_DEVICEINFO
#define USB_MAX_DEVICES   128 /* units */
#define USB_MAX_DEVNAMES
#define USB_CONTROL_PATH_FORMAT
#define LOG_DEBUG

UsbDevice *
usbFindDevice (UsbDeviceChooser chooser, void *data) {
  UsbDevice *device = NULL;
  int busNumber = 0;
  while (1) {
    char busPath[PATH_MAX+1];
    int bus;
    snprintf(busPath, sizeof(busPath), "/dev/usb%d", busNumber);
    if ((bus = open(busPath, O_RDONLY)) != -1) {
      int deviceNumber;
      for (deviceNumber=1; deviceNumber<USB_MAX_DEVICES; deviceNumber++) {
        struct usb_device_info info;
        memset(&info, 0, sizeof(info));
        info.udi_addr = deviceNumber;
        if (ioctl(bus, USB_DEVICEINFO, &info) != -1) {
          static const char *driver = "ugen";
          const char *deviceName = info.udi_devnames[0];

          logMessage(LOG_DEBUG, "USB device [%d,%d]: vendor=%s product=%s",
                     busNumber, deviceNumber, info.udi_vendor, info.udi_product);
          {
            int nameNumber;
            for (nameNumber=0; nameNumber<USB_MAX_DEVNAMES; nameNumber++) {
              const char *name = info.udi_devnames[nameNumber];
              if (*name)
                logMessage(LOG_DEBUG, "USB name %d: %s", nameNumber, name);
            }
          }

          if (strncmp(deviceName, driver, strlen(driver)) == 0) {
            char devicePath[PATH_MAX+1];
            snprintf(devicePath, sizeof(devicePath), USB_CONTROL_PATH_FORMAT, deviceName);

            {
              UsbDeviceExtension *devx;
              if ((devx = malloc(sizeof(*devx)))) {
                if ((devx->path = strdup(devicePath))) {
                  if ((devx->file = open(devx->path, O_RDWR)) != -1) {
                    devx->timeout = -1;
                    if ((device = usbTestDevice(devx, chooser, data))) {
                      close(bus);
                      return device;
                    }
                    close(devx->file);
                  }
                  free(devx->path);
                }
                free(devx);
              }
            }
          }
        } else if (errno != ENXIO) {
          logSystemError("USB device query");
        }
      }
      close(bus);
    } else if (errno == ENOENT) {
      break;
    } else if (errno != ENXIO) {
      logSystemError("USB bus open");
    }
    busNumber++;
  }
  return device;
}

void
usbForgetDevices (void) {
}
```
The next set of errors you will encounter is

```
cd Programs && gmake all
gmake[1]: Entering directory `/usr/home/raspycat/Firefox_Downloads/brltty-4.4/Programs'
/usr/local/bin/clang -I. -I. -I./../Programs -I../Programs -I./.. -I..    -DHAVE_CONFIG_H -Wno-unused-variable -std=gnu99 -Wall -fPIC  -c ./usb_freebsd.c
In file included from ./usb_freebsd.c:34:
In file included from ./usb_bsd.h:23:
/usr/include/dev/usb/usb_compat_linux.h:59:20: warning: declaration of
      'struct usb_device_id' will not be visible outside of this function
      [-Wvisibility]
                const   struct usb_device_id *id);
                               ^
/usr/include/dev/usb/usb_compat_linux.h:73:2: error: type name requires a
      specifier or qualifier
        LIST_ENTRY(usb_driver) linux_driver_list;
        ^
/usr/include/dev/usb/usb_compat_linux.h:73:13: error: a parameter list without
      types is only allowed in a function definition
        LIST_ENTRY(usb_driver) linux_driver_list;
                   ^
/usr/include/dev/usb/usb_compat_linux.h:73:24: error: expected ';' at end of
      declaration list
        LIST_ENTRY(usb_driver) linux_driver_list;
                              ^
                              ;
/usr/include/dev/usb/usb_compat_linux.h:230:2: error: type name requires a
      specifier or qualifier
        TAILQ_ENTRY(urb) bsd_urb_list;
        ^
/usr/include/dev/usb/usb_compat_linux.h:230:14: error: a parameter list without
      types is only allowed in a function definition
        TAILQ_ENTRY(urb) bsd_urb_list;
                    ^
/usr/include/dev/usb/usb_compat_linux.h:230:18: error: expected ';' at end of
      declaration list
        TAILQ_ENTRY(urb) bsd_urb_list;
                        ^
                        ;
/usr/include/dev/usb/usb_compat_linux.h:231:12: error: field has incomplete type
      'struct cv'
        struct cv cv_wait;
                  ^
/usr/include/dev/usb/usb_compat_linux.h:231:9: note: forward declaration of
      'struct cv'
        struct cv cv_wait;
               ^
In file included from ./usb_freebsd.c:34:
In file included from ./usb_bsd.h:26:
/usr/include/dev/usb/usb_bus.h:36:22: error: field has incomplete type
      'struct usb_proc_msg'
        struct usb_proc_msg hdr;
                            ^
/usr/include/dev/usb/usbdi.h:38:8: note: forward declaration of
      'struct usb_proc_msg'
struct usb_proc_msg;
       ^
In file included from ./usb_freebsd.c:34:
In file included from ./usb_bsd.h:26:
/usr/include/dev/usb/usb_bus.h:69:21: error: field has incomplete type
      'struct usb_process'
        struct usb_process giant_callback_proc;
                           ^
/usr/include/dev/usb/usbdi.h:37:8: note: forward declaration of
      'struct usb_process'
struct usb_process;
       ^
In file included from ./usb_freebsd.c:34:
In file included from ./usb_bsd.h:26:
/usr/include/dev/usb/usb_bus.h:70:21: error: field has incomplete type
      'struct usb_process'
        struct usb_process non_giant_callback_proc;
                           ^
/usr/include/dev/usb/usbdi.h:37:8: note: forward declaration of
      'struct usb_process'
struct usb_process;
       ^
In file included from ./usb_freebsd.c:34:
In file included from ./usb_bsd.h:26:
/usr/include/dev/usb/usb_bus.h:73:21: error: field has incomplete type
      'struct usb_process'
        struct usb_process explore_proc;
                           ^
/usr/include/dev/usb/usbdi.h:37:8: note: forward declaration of
      'struct usb_process'
struct usb_process;
       ^
In file included from ./usb_freebsd.c:34:
In file included from ./usb_bsd.h:26:
/usr/include/dev/usb/usb_bus.h:76:21: error: field has incomplete type
      'struct usb_process'
        struct usb_process control_xfer_proc;
                           ^
/usr/include/dev/usb/usbdi.h:37:8: note: forward declaration of
      'struct usb_process'
struct usb_process;
       ^
In file included from ./usb_freebsd.c:34:
In file included from ./usb_bsd.h:26:
/usr/include/dev/usb/usb_bus.h:88:13: error: field has incomplete type
      'struct mtx'
        struct mtx bus_mtx;
                   ^
/usr/include/dev/usb/usb_bus.h:88:9: note: forward declaration of 'struct mtx'
        struct mtx bus_mtx;
               ^
/usr/include/dev/usb/usb_bus.h:89:24: error: field has incomplete type
      'struct usb_xfer_queue'
        struct usb_xfer_queue intr_q;
                              ^
/usr/include/dev/usb/usb_bus.h:89:9: note: forward declaration of
      'struct usb_xfer_queue'
        struct usb_xfer_queue intr_q;
               ^
/usr/include/dev/usb/usb_bus.h:90:21: error: field has incomplete type
      'struct usb_callout'
        struct usb_callout power_wdog;  /* power management */
                           ^
/usr/include/dev/usb/usb_bus.h:90:9: note: forward declaration of
      'struct usb_callout'
        struct usb_callout power_wdog;  /* power management */
               ^
/usr/include/dev/usb/usb_bus.h:92:2: error: unknown type name 'device_t'
        device_t parent;
        ^
/usr/include/dev/usb/usb_bus.h:93:2: error: unknown type name 'device_t'
        device_t bdev;                  /* filled by HC driver */
        ^
/usr/include/dev/usb/usb_bus.h:96:42: error: array has incomplete element type
      'struct usb_dma_parent_tag'
        struct usb_dma_parent_tag dma_parent_tag[1];
                                                ^
/usr/include/dev/usb/usb_bus.h:96:9: note: forward declaration of 'struct
      usb_dma_parent_tag'
        struct usb_dma_parent_tag dma_parent_tag[1];
               ^
/usr/include/dev/usb/usb_bus.h:97:30: error: use of undeclared identifier
      'USB_BUS_DMA_TAG_MAX'
        struct usb_dma_tag dma_tags[USB_BUS_DMA_TAG_MAX];
                                    ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
1 warning and 20 errors generated.
gmake[1]: *** [usb_freebsd.o] Error 1
gmake[1]: Leaving directory `/usr/home/raspycat/Firefox_Downloads/brltty-4.4/Programs'
gmake: *** [all] Error 2
```

I will post the error corrections later along with a short list of what should have been edited in /usr/local/include/unicode



For me, the chromium does not include webrtc options with `make config`.
I had to build firefox-esr. There is no webrtc reference when `make config` is ran within that directory.

A standalone version would allow developers who use FreeBSD to build applications using WebRTC. Also, if a Qt or GTK application requires WebRTC, then it will be available on the system. The FreeBSD community will have a direct say in the development of WebRTC. The brltty application will be available for FreeBSD, which will add another accessibility/at application for sight impaired people and others.

Personally, I see nothing wrong with my efforts. The corrections are made public. No one will be confused as to when or where what is located because it will be here on the forums.

Because this requires moving between the system and two environments, posts will be labeled as such.
This post is system values and search commands.

The following need to be edited  
	
	



```
#include <filetype>
```
 has the entire path of 
	
	



```
[file]/usr/local/include/unicode[/file] [file]alphaindex.h[/file], [file]appendable.h[/file], [file]basictz.h[/file], [file]bms.h[/file], [file]localpointer.h[/file], [file]platform.h[file], [file]ptypes.h[/file], [file]uchar.h[/file], [file]uiter.h[/file], [file]umachine.h[/file], [file]unorm.h[/file], [file]unorm2.h[/file], [file]urename.h[/file], [file]uset.h[/file], [file]ushape.h[/file], [file]utf.h[/file], [file]utf16.h[/file], [file]utypes.h[/file], and [file]uversion.h[/file]
```

Searching for an expression `find /$PATH -exec grep -H -E -o "EXACT_EXPRESSION" {} \;` Keep this command to ensure that you will be able to search.
Because CLang works differently than GCC, you may need to edit system files to include exact paths and values. _*Be sure to keep a copy of the original file if something unexpected happens*_.


brltty-4.4
In brltty-4.4/Programs/usb_freebsd.c, edit to 
	
	



```
#include </usr/include/dev/usb/usb.h>
```
 
WebRTC.

`mkdir $WEBRTC_SOURCE/trunk/webrtc/tests/freebsd`

These following files need to be saved as the name stated and in that created directory.

glx_renderer.cc

```
/*
 *
 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
 *
 * Use of this source code is governed by a BSD-style license
 * that can be found in the LICENSE file in the root of the source
 * tree. An additional intellectual property rights grant can be found
 * in the file PATENTS. All contributing project authors may
 * be found in the AUTHORS file in the root of the source tree.
 */
 
 
 #include "webrtc/test/freebsd/glx_renderer.h"
 
 #include <assert.h>
 
 #include </usr/local/include/X11/Xatom.h>
 #include </usr/local/include/X11/Xlib.h>
 
 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h"
 
 namespace webrtc {
 namespace test {
	 
GlxRenderer::GlxRenderer(size_t width, size_t height)
     : width_(width),
        height_(height),
	 display_(NULL),
	 context_(NULL) {
 assert(width > 0);
 assert(height > 0);
}

GlxRenderer::~GlxRenderer() { Destroy(); }

bool GlxRenderer::Init(const char* window_title) {
 if ((display_ = XOpenDisplay(NULL)) == NULL) {
   Destroy();
   return false;
 }
 
 int screen = DefaultScreen(display_);
 
 XVisualInfo* vi;
 int attr_list[] = { GLX_DOUBLEBUFFER, GLX_RGBA, GLX_RED_SIZE, 4,
	               GLX_GREEN_SIZE, 4, GLX_BLUE_SIZE, 4, GLX_DEPTH_SIZE, 16,
	                NONE, };
			
if ((vi = glXChooseVisual(display_, screen, attr_list)) == NULL) {
   Destroy();
   return false;
 }
 
 XSetWindowAttributes window_attributes;
 window_attributes.colormap = XCreateColormap(
      display_, RootWindow(display_, vi->screen), vi->visual, AllocNone);
 window_attributes.border_pixel = 0;
 window_attributes.event_mask = StructureNotifyMask | ExposureMask;
 window_= XCreateWindow(display_, RootWindow(display_, vi->screen), 0, 0,
			width_, height_, 0, vi->depth, InputOutput,
			vi->visual, CWBorderPixel | CWColormap | CWEventMask,
			&window_attributes);
 XFree(vi);
 
 XSetStandardProperties(display_, window_, window_title, window_title, None,
			NULL, 0, NULL);
 
 Atom wm_delete = XInternAtom(display_, "WM_DELETE_WINDOW", True);
 if (wm_delete != None) {
    XSetWMProtocols(display_, window_, &wm_delete, 1);
 }
 
 XMapRaised(display_, window_);
 
 if (!glXMakeCurrent(display_, window_, context_)) {
    Destroy();
    return false;
 }
 GlRenderer::Init();
 if (!glXMakeCurrent(display_, None, NULL)) {
    Destroy();
    return false;
 }
 
 Resize(width_, height_);
 return true;
 }
 
 void GlxRenderer::Destroy() {
   if (context_ != NULL) {
      glXMakeCurrent(display_, window_, context_);
    GlRenderer::Destroy();
    glXMakeCurrent(display_, None, NULL);
    glXDestroyContext(display_, context_);
    context_ = NULL;
  }

  if (display_ != NULL) {
    XCloseDisplay(display_);
    display_ = NULL;
  }
}

GlxRenderer* GlxRenderer::Create(const char* window_title, size_t width,
                                 size_t height) {
  GlxRenderer* glx_renderer = new GlxRenderer(width, height);
  if (!glx_renderer->Init(window_title)) {
    // TODO(pbos): Add GLX-failed warning here?
    delete glx_renderer;
    return NULL;
  }
  return glx_renderer;
}

void GlxRenderer::Resize(size_t width, size_t height) {
  width_ = width;
  height_ = height;
  if (!glXMakeCurrent(display_, window_, context_)) {
    abort();
  }
  GlRenderer::ResizeViewport(width_, height_);
  if (!glXMakeCurrent(display_, None, NULL)) {
    abort();
  }

  XSizeHints* size_hints = XAllocSizeHints();
  if (size_hints == NULL) {
    abort();
  }
  size_hints->flags = PAspect;
  size_hints->min_aspect.x = size_hints->max_aspect.x = width_;
  size_hints->min_aspect.y = size_hints->max_aspect.y = height_;
  XSetWMNormalHints(display_, window_, size_hints);
  XFree(size_hints);

  XWindowChanges wc;
  wc.width = static_cast<int>(width);
  wc.height = static_cast<int>(height);
  XConfigureWindow(display_, window_, CWWidth | CWHeight, &wc);
}

void GlxRenderer::RenderFrame(const webrtc::I420VideoFrame& frame,
                              int /*render_delay_ms*/) {
  if (static_cast<size_t>(frame.width()) != width_ ||
      static_cast<size_t>(frame.height()) != height_) {
    Resize(static_cast<size_t>(frame.width()),
           static_cast<size_t>(frame.height()));
  }

  XEvent event;
  if (!glXMakeCurrent(display_, window_, context_)) {
    abort();
  }
  while (XPending(display_)) {
    XNextEvent(display_, &event);
    switch (event.type) {
      case ConfigureNotify:
        GlRenderer::ResizeViewport(event.xconfigure.width,
                                   event.xconfigure.height);
        break;
      default:
        break;
    }
  }

  GlRenderer::RenderFrame(frame, 0);
  glXSwapBuffers(display_, window_);

  if (!glXMakeCurrent(display_, None, NULL)) {
    abort();
  }
}
}  // test
}  // webrtc
```

glx_renderer.h 

```
/*
 *  Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
 *
 *  Use of this source code is governed by a BSD-style license
 *  that can be found in the LICENSE file in the root of the source
 *  tree. An additional intellectual property rights grant can be found
 *  in the file PATENTS.  All contributing project authors may
 *  be found in the AUTHORS file in the root of the source tree.
 */

#ifndef WEBRTC_VIDEO_ENGINE_TEST_COMMON_LINUX_GLX_RENDERER_H_
#define WEBRTC_VIDEO_ENGINE_TEST_COMMON_LINUX_GLX_RENDERER_H_

#include </usr/local/include/GL/glx.h>
#include </usr/local/include/X11/Xlib.h>

#include "webrtc/test/gl/gl_renderer.h"
#include "webrtc/typedefs.h"

namespace webrtc {
namespace test {

class GlxRenderer : public GlRenderer {
 public:
  static GlxRenderer* Create(const char* window_title, size_t width,
                             size_t height);
  virtual ~GlxRenderer();

  virtual void RenderFrame(const webrtc::I420VideoFrame& frame, int delta)
      OVERRIDE;
 private:
  GlxRenderer(size_t width, size_t height);

  bool Init(const char* window_title);
  void Resize(size_t width, size_t height);
  void Destroy();

  size_t width_, height_;

  Display* display_;
  Window window_;
  GLXContext context_;
};
}  // test
}  // webrtc

#endif  // WEBRTC_VIDEO_ENGINE_TEST_COMMON_LINUX_GLX_RENDERER_H_
```

video_renderer_freebsd.cc

```
/*
 *  Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
 *
 *  Use of this source code is governed by a BSD-style license
 *  that can be found in the LICENSE file in the root of the source
 *  tree. An additional intellectual property rights grant can be found
 *  in the file PATENTS.  All contributing project authors may
 *  be found in the AUTHORS file in the root of the source tree.
 */
#include "webrtc/test/video_renderer.h"

#include "webrtc/test/freebsd/glx_renderer.h"

namespace webrtc {
namespace test {

VideoRenderer* VideoRenderer::CreatePlatformRenderer(const char* window_title,
                                                     size_t width,
                                                     size_t height) {
  GlxRenderer* glx_renderer = GlxRenderer::Create(window_title, width, height);
  if (glx_renderer != NULL) {
    return glx_renderer;
  }
  return NULL;
}
}  // test
}  // webrtc
```



`mkdir $WEBRTC_SOURCE/trunk/webrtc/modules/audio_device/freebsd`
`mkdir $WEBRTC_SOURCE/trunk/webrtc/modules/video_capture/freebsd`
`mkdir $WEBRTC_SOURCE/trunk/webrtc/modules/video_render/freebsd`


General::
Still working on this. Trying to find a starting place.

WebRTC::

In trunk/third_party/clang_format/bin `mkdir freebsd[/file].
In [file]trunk/third_party/gflags/src[/file] [cmd]mkdir freebsd[/file].
In [file]trunk/third_party/icu[/file] [cmd]mkdir freebsd`.
In trunk/third_party/libyuv add the following with the name listed at the top::
freebsd.mk

```
# This is a generic makefile for libyuv for freebsd.
# make -f  CXX=/usr/local/bin/clang++

CXX?=/usr/local/bin/clang++
CXXFLAGS?=-O2 -fomit-frame-pointer
CXXFLAGS+=-I/usr/local/include/ -l/usr/include/

LOCAL_OBJ_FILES := \
    source/compare.o           \
    source/compare_common.o    \
    source/compare_posix.o     \
    source/convert.o           \
    source/convert_argb.o      \
    source/convert_from.o      \
    source/convert_from_argb.o \
    source/convert_to_argb.o   \
    source/convert_to_i420.o   \
    source/cpu_id.o            \
    source/format_conversion.o \
    source/planar_functions.o  \
    source/rotate.o            \
    source/rotate_argb.o       \
    source/rotate_mips.o       \
    source/row_any.o           \
    source/row_common.o        \
    source/row_mips.o          \
    source/row_posix.o         \
    source/scale.o             \
    source/scale_argb.o        \
    source/scale_common.o      \
    source/scale_mips.o        \
    source/scale_posix.o       \
    source/video_common.o

.cc.o:
	$(CXX) -c $(CXXFLAGS) $*.cc -o $*.o

all: libyuv.a convert

libyuv.a: $(LOCAL_OBJ_FILES)
	$(AR) $(ARFLAGS) -o $@ $(LOCAL_OBJ_FILES)

# A test utility that uses libyuv conversion.
convert: util/convert.cc libyuv.a
	$(CXX) $(CXXFLAGS) -Iutil/ -o $@ util/convert.cc libyuv.a

clean:
	/bin/rm -f source/*.o *.ii *.s libyuv.a convert
```

For those who are following this: My apologies for being erratic; but, as usual, I am approaching things as they come about. 

Continuing with WebRTC

In trunk/third_party/openssl/openssl/crypto edit LPdir_unix.c to include the entire path for 





> #include


 to have the complete path name and rename as LPdir_freebsd.c, saving in the same area.

If you have little patience, then `# /usr/libexec/locate.updatedb && locate linux|grep $WEBRTC_SOURCE/trunk` and then tee or &> to a file. 

Thanks muchly.



I am adding to this:

1. You must use the 
	
	



```
sync --force
```
 flag when running gclient. If that does not work, then create a new directory, pull the changes, and copy the old files to the new directory.
2. The `find /` option above should be replaced with `grep -RH -E -o "PATTERN" "$PATH"`.
thanks

`SciTE $WEBRTC_SOURCE/trunk/tools/gn/bootstrap/bootstrap.py` Change every 'linux' reference to 'freebsd'. Do not correct this spelling. Save the file.
In WEBRTC_SOURCE/trunk/third_party `mkdir libevent`.
`cp /usr/src/contrib/pf/libevent/*  SOURCE/trunk/third_party/libevent/`

You will need to copy the missing libraries by searching for "libevent/$FILE" on the internet.


http://martine.github.io/ninja/

Follow all directions. the `git checkout release` doesn't seem to work. Do add the clang references.


https://chromium.googlesource.com/chromium/src/base/
`cp -r $NINJA_DIRECTORY/* CHROMIUM_BASE_DIRECTORY/`
`ninja`

You will need this in base.

Ninja:

You are going to edit configure.py in $NINJA_SRC_DIR.
Comment out _f (platform.is_()_ and the following line of code for that entry.
Use `nvi $NINJA/configure.py` and search for _configure_env.get_ changing _g++_ to *clang++*.

Now, run `./configure.py`.


Alright. Let's continue.

Open the chromium base folder and edit the following files: unix_domain_socket_linux.h, unix_domain_socket_linux.cc,  and unix_domain_socket_linux_unittest.cc.
Rename every reference of Linux to FreeBSD according to coding style. Include the entire FreeBSD paths. 

Look in base/threading and edit platform_thread_posix.cc to include

```
#if defined(OS_FREEBSD)
#include </usr/src/include/sys/resource.h>
#include </usr/include/sys/syscall.h>
#include </usr/include/sys/procctl.h>
#include </usr/include/sys/time.h>
#include </usr/include/sys/uninstd.h>
#endif
```


----------



## sossego (Feb 3, 2014)

The following posts are left blank so that I may edit and add to this tutorial without it being set to the forefront.
I want to be able to work on this without it grabbing too much attention. . For the record, this is not some trolling attempt at attention. What it happens to be is a subtle request to do a public active porting tutorial and to be able to allow others' to have their howto's printed without my updates causing trouble.

Thank you for reading and not replying.


----------



## sossego (Feb 5, 2014)

Left blank for future editing.


----------



## sossego (Feb 5, 2014)

Wrong post in thread.


----------



## sossego (Feb 5, 2014)

Left blank for future editing.


----------



## ondra_knezour (Feb 5, 2014)

You probably want to search included files for macro definition in linked files, add it if isn't there and replace USB_SET_TIMEOUT with USB_SET_TX_TIMEOUT.

Given message you have linked I would try first modify shown code as follows:

```
#define USB_SET_TX_TIMEOUT      _IOW ('U', 137, int)

static int
usbSetTimeout (int file, int new, int *old) {
  if (!old || (new != *old)) {
    int arg = new;
    if (ioctl(file, USB_SET_TX_TIMEOUT, &arg) == -1) {
      logSystemError("USB timeout set");
      return 0;
    }
    if (old) *old = new;
  }
  return 1;
}
```


----------



## sossego (Feb 6, 2014)

http://lists.freebsd.org/pipermail/free ... 66284.html
Page references your suggestion and the solution to the next error.

http://www.freebsd.org/cgi/man.cgi?query=ugen 
I've decided to use 
	
	



```
#define $REFERENCES _TO_USB_
```
 with the ugen() .

Seems that I will need to 
	
	



```
#include </all/from/usr/include/dev/usb/>
```
 along with adding the 
	
	



```
#define(s)
```
 for each.

Thanks muchly for the help.


----------



## sossego (Feb 6, 2014)

This is the new post from which all things should start.
Rebuild world and kernel according to the handbook. http://www.freebsd.org/doc/handbook/makeworld.html
Setup the jail according to the handbook. The jail's name will be FreeBSD-Google_projects. https://www.freebsd.org/doc/handbook/jails-build.html
Because of the depth of change, we must have a pristine system from which to do our porting. 
I will re-implement all changes properly. I had to change the installation on my laptop from i386-RELEASE to AMD64-RELEASE; however, you must be sure that the release matches the architecture of your machine.
Thanks.


----------



## sossego (Feb 6, 2014)

Edited on February 28, 2014 between 16:25 and 16:30.
Since the next step in this process will take me some time, I will inform you on what I am doing if you are impatient.
Create a directory in /home named Chromium_OS. `$mkdir /home/Chromium_OS`.
Change to that directory. `$ cd /home/ChromiumOS`.
What you do next is taken from http://www.chromium.org/chromium-os/developer-guide.
`repo init -u [url=https://chromium.googlesource.com/chromiumos/manifest.git]https://chromium.googlesource.com/chrom ... nifest.git[/url] --repo-url [url=https://chromium.googlesource.com/external/repo.git]https://chromium.googlesource.com/external/repo.git[/url]
repo sync`

Every Linux system will keep a cache of packages in /var/cache/$PACKAGING_TOOL until you clean them out.
`cd /home/ChromiumOS && ls -la $PWD|tee /home/ChromiumOS_packages.txt`

Follow the example from the handbook on installing the ports tree to the jail.
With every file listed from /home/ChromiumOS_packages.txt look through the ports with `#make search name=$PACKAGE_IN_QUESTION|grep /usr/ports`.
On a separate terminal emulator, chroot to the jail and install the packages for which can be found with the ports search command.

From within the jail, download depot_tools from Google: http://www.chromium.org/developers/how-tos/depottools
Add depot_tools to PATH with `export PATH=$PATH:/home/$USER/depot_tools`

Because Google does not have a FreeBSD or any other BSD developer environment, we must create one. What we are doing is making a jailed environment with the exact same software with the exception that it follows the FreeBSD hierarchy. This same method can be used with making a chroot of OpenBSD ports and NetBSD ports that are exactly similar to those on a Chrome/ChromiumOS installment.

Congratulations, you have just now setup your FreeBSD-Google developer environment.

After I complete my environment building- I am doing it while writing this tutorial- the updated instructions for patching the system will be posted. Any emphasis that was put on brltty will not be brought up until after such instructions.
Please be patient.


----------



## sossego (Feb 6, 2014)

Edit March 02 19:00 to 19:10

If the repo command does not work, then try the following: `git [url=https://chromium.googlesource.com/external/repo.git]https://chromium.googlesource.com/external/repo.git[/url]`. That will solve any short term difficulties.


----------



## sossego (Feb 7, 2014)

March 02 21:22 to 21:30

We are going to need a jail.conf file so:

```
bsdevelop {
     path = /home/FreeBSD-Google_projects
     allow.mount;
     mount.devfs;
     host.hostname = bsdoodle.com;
     ip4.addr = 127.0.0.10;
     interface = lo0;
    }
```

Modify that to whatever name you want.

Edit: Fixed that.
Fixed again on March 11, 2014


----------



## sossego (Feb 9, 2014)

Left blank for future editing.


----------



## sossego (Feb 16, 2014)

Left blank for future editing.


----------



## sossego (Feb 18, 2014)

Left blank for future editing.


----------



## sossego (Feb 19, 2014)

Left blank for future editing.


----------



## sossego (Feb 19, 2014)

Left blank for future editing.


----------



## sossego (Feb 20, 2014)

Left blank for future editing.


----------



## sossego (Feb 28, 2014)

Read through the earlier posts on this thread. The setup that I suggested is wrong and needs to be corrected.


----------



## sossego (Mar 3, 2014)

I am working on building the jail and moving things inside the chroot.


----------



## sossego (Mar 3, 2014)

Redoing the jail setup, I've copied the template from viewtopic.php?f=39&t=41470 .
 The layout will continue to evolve and edit.
Remove the reference in home  for the project database. `# cd /home/$PROJECT && chflags -R noschg * && rm -rf * && cd .. && rm -rf $PROJECT_DIRECTORY` The garbage is gone.
`#zfs create -o mountpoint=/jails $ZROOT/jails`

`# zfs create zroot/jails/FreeBSD-Google_projects`

`mkdir /jails/etc`

This your jailed environment created a better way. I had to wrap my head around various options to get the right ones.

Give me a moment to import all variables into the jail.


----------



## sossego (Mar 6, 2014)

March 05, 2014 16:35

I have to use public wireless access points and creating a clone/bridge to wlan0 means setting up a script. While I am trying to solve my dilemma, here is what you need to do:
Create the jail. Install world into the jail. 
`mkdir $JAIL/usr/ports && portsnap -p $JAIL/usr/ports fetch extract`
Install python and other base languages. This can be done with installing lynx as the first port within the jail.
Install git and other developer tools.
Go to the first few posts in this thread. You will need to add depot_tools, python, and perl to the $PATH. Keep in mind that you are within the jail.
`mkdir /android && mkdir /chromeos` These need to be separate from /usr. 
`cd /android`
http://source.android.com/source/downloading.html Follow the instructions. 
This will be edited and rewritten.
After the initial download, do the following.
`cd /chromeos`

http://dev.chromium.org/chromium-os/dev ... requisites

Forget the references to Linux at this point because we need to manipulate both the ChromiumOS and Android environments.
Be sure that you have git, svn, and curl as stated within the document.

You will not configure git. Instead you will clone the source into /chromeos.

http://dev.chromium.org/chromium-os/dev ... the-Source

My resources are extremely limited.


----------



## sossego (Mar 6, 2014)

http://source.android.com/source/initializing.html and others.

I'm adding and all of this will be redone. 
Yes, you can build a Linux kernel and modules on FreeBSD- with modifications to the Linuxlator. Yes, there is a tutorial for that. It will be added later.
There is a tool called heimdall which can load a ROM to an Android device. I'll add the link to that later.

Some of the reasons for the changes in this tutorial:
1. The Google developers did not keep records of how the build method changed. For systems that had not yet worked on their projects, this would cause some difficulties.
2. The build environment is more complex than just Chrome browser.
3. No package configuration to include FreeBSD or other systems.

Everything can not be set up on each system the exact same way; however, programs which are similar can be used as substitutes.  

WebRTC requires brltty and its libraries to work- this was stated earlier in the tutorial. This has to be removed from the package requirements.

Anywhere on here that you want to jump to or if you want to continue on your own, you can. This is a skeleton for a developer's environment- a template, if you will- and does not need to be followed step by step. I decided that a jailed system would eliminate the need for the users to hack their own systems into oblivion.


----------



## sossego (Mar 8, 2014)

So the question is: How does one start a jail when one does not have a home/dedicated internet connection?
1. You hack an Android based smartphone and use it as a router. This will make permanent assignment of addresses easier provided that you always connect through the router.
2. You follow a set of commands or a script to help you out.

```
#!/bin/sh
ifconfig lo0 127.1.2.7/32 alias && jail -c path=/$JAIL_PATH mount.devfs host.hostname=$JAIL_HOSTNAME ip4.addr=127.x.x.x command=/bin/sh
```
 Do not use 127.0.0.1 .

What I am missing is the proper setup of pf.conf.

Think of this as me laying out a blueprint for us to follow.

First, let's look at the problem. I wanted to work on WebRTC on FreeBSD. What I found was that there is no environment suitable nor set up for such.
Second, it was necessary to see what would be required. Could the paths be simply changed or was more needed?
Third, with all of that known, what do I need to correct?

The build environment only exists for Windows, MacOSX, and Linux. 
Are we able to access such environments without OS virtualization- e.g. VirtualBox, QEmu, Xen, etc?  Yes. We can set up a jailed Linux compatibility environment which would allow the building with and the studying of related Google projects.
Are we able to explore the file system of certain projects and adjust our system to them? Yes.  We are setting up an environment for that purpose.
Are we able to build such a project on FreeBSD? Yes. We will use the jailed Linux compatibility environments to work on the projects.

It's time to do some homework. 
viewtopic.php?&t=37868 Link is in the last post. This will be one jailed environment. Create it. As a FreeBSD user, you need to remember that each Linux flavor has something to add.  You will use the references earlier in this thread to create the Android, ChromiumOS, and WebRTC/source files within that environment.

viewtopic.php?f=39&t=41470 yes, you need to create a second jailed Linux compatibility environment.

According to my current setup, my experience with different Linux distributions, and previous virtualized/emulated environments; the following will be a good hardware configuration for this project.
My system has 1024M RAM, 120GB drive, 2x1.6GHz core processors, architecture is amd64. This project requires a single host plus three jailed environments. To run this without strain a minimum setup will need: 
1. 3GB of RAM. 
2. 3GB of swap.
3. 250GB of disk space.
4. QuadCore processor.


You need to populate the FreeBSD jail with the basics from /usr/ports and start importing all of the variables into that jail.
You will need: viewtopic.php?f=15&t=45085 Why? Because you are building Android while studying it. This gives you a chance to use your FreeBSD machine with another environment.

Notice that when this thread was started, I was telling you to rewrite some paths on your system. I realized that doing such for beginners was a bad idea. Here, in the jailed FreeBSD system, you can hack away at what there is and not screw up your actual machine installation.

"What if my system is hosed by now?" Don't worry. Restart with a fresh install and then setup the jails right after that install. You can look at the changes here, implement them, and then have the base environment done.

"Why are you telling us what to do but not writing it down as in directions?" I've gone through the starter process of porting WebRTC as a native FreeBSD build and realized that the entire Google developer environment needs to be ported for this. I have problems due to lack of a home ISP. I can map out what I see there is to do and share that with others.

"What else is this good for?" It will allow some of the Google and Linux developers to work on a system similar to theirs- jailed Linux compatibility- along with learning the FreeBSD system. It allows different parts of the Open Source community to work together.

"Will this tutorial be in depth?" Not quite, I am afraid. There is only so much I can do at the moment. 

"Why?" What I am going to write is not there for pity, attention, manipulation, or any of that. It is there to put things into perspective for you. Do not take it out of context.

1. I'm doing all of this while homeless and struggling; but, if there is a problem I can help with, I will. This is such a problem. My laptop was given to me to help out others. I remain anonymous. I earn my money through physical labor. 
2. Google asked me what my coding style was; it's helping others when they don't have the means but have the ability and initiative.
3. People forget that others may want to help. Other times, we don't desire to be patient enough to assist and aide or fellows. It was necessary to see and be both in this case.
4. There are others in my predicament and worse who still want something positive to do. We can give and that means we earn what we receive. 
5. Sometimes growth means helping others before you can move on despite your limitations.


Now, anything from the above section from "Why?" to "limitations" will not be referred to again. It is there only to put things into perspective.


Returning:

"Now what?" Be patient. As soon as I am able to enable networking from within the jail, the scripts for such will be correctly presented.


----------



## sossego (Mar 9, 2014)

http://lists.freebsd.org/pipermail/free ... 44441.html

Read through the posting. This is also on freebsd-x11@freebsd.org mailing list. 

Why am I adding this? Because you may need extra functionality with Xorg in the jail.

The ninja binary is available in ports at /usr/ports/devel/ninja . This is needed in the jailed FreeBSD environment.

viewtopic.php?f=39&t=30063 This is what I am using to setup my pf.conf . You do not have to use the exact same cloned interface value, make up your own.

http://kbeezie.com/freebsd-jail-single-ip/ I am also using this as another reference.


----------



## sossego (Mar 9, 2014)

I think that I should put this on hold.
I am not able to deal with the negativity, bullshit, or jerking around.

Here are the lessons that none of you desire to learn:
You have to work together so get this crap about which system is better out of your thoughts. Nothing will improve until you work together on problems.
If I can do things with what little I have, then the rest of you have absolutely no excuse. 
Instead of openly hoping and asking, make an effort. 
If you are stuck at a certain step, then let others know what they can work on- in your tutorial/project- while you search for a solution.
Use references for others to follow. It keeps you from doing their homework and helps them to learn and improve their own.

I am pissed but I am not leaving anyone hanging in mid air. 

If any of you actually want anything on this thread to be a reality.....
 If any of you want FreeBSD to affect web standards in a positive way....
If any of you want to learn...
then you will find a way of doing it as I found a way of starting.


I want to be left alone for a little while.


----------



## sossego (Mar 11, 2014)

You may also use the ezjail utility in /usr/ports/sysutils for setting up the jailed environment.

For right now:
Any feedback on the environment of the jail- and nothing else- please let me know.

1. Were you able to setup a jailed environment on your own?
2. Were you able to setup the same environment as listed in the two linked tutorials and earlier in this thread?

If you had trouble as far as 1 goes, I will try to find a set of tutorials and link them here. 
If you had trouble as far as 2 goes, let me know where you stopped. I will try to find you the references you need.

For me, networking within the jail is frustrating. 

I need to clean this tutorial up quite a bit.

Let me know where there is difficulty in understanding. All personal references will be removed unless they are used to encourage others, then you will get a fortune cookie.


----------



## sossego (Mar 23, 2014)

There's something that most people forget to tell you about jails, and that is the kernel configuration options.

Take note on this.

From /kern/root/kernels/MY_KERNEL.conf

```
options         VPS
options         VIMAGE
options         MROUTING
```

Whenever you build any jail, it should be done with a kernel compiled with the above options.


----------



## sossego (Mar 31, 2014)

Alright.
1. Vimage does not work well with pf.  There is a patch. One could also disable pf within the jail, if that is possible. I'll look into that later.
2. VPS is testing. The diff is against 10.0
 I have upgraded to 11.0 revision 263906 and have patched source for udplite.


----------



## sossego (Apr 4, 2014)

New start.

This is AMD64/x86_64 only _*for the current moment*_. 

What you will need is listed earlier in this thread; but, for the sake of convenience:
1. A minimum of a dual core processor.
2. A minimum of 1G RAM.
3. A minimum of a 120G hard disk.
4. An internet connection.
5. CURRENT amd64 burned to a disk or set onto USB.

Installation:
Choose ZFS-on-root option.

Installation can be done by using svn- which will be used soon- to get HEAD from svn on your current disk. It's easier just to avoid the headache by backing up and reinstalling.

After system setup:

`#svn checkout [url=svn://svn.freebsd.org/base/head]svn://svn.freebsd.org/base/head[/url] /usr/src`

There are four patches/diffs that I applied to my source. The reason is that I am trying to setup OS level virtualization options to go along with OS emulation and system sharing while using an optional passive networking mode. 
In other words, we will be attempting to hack an Android device and GoogleOS through and with FreeBSD.

`#cd /usr/src`

The patches/diffs:
1. VPS http://www.7he.at/freebsd/vps/files/diffs/vps-r215.diff
`# patch -p1<vps-r215.diff` 
2. UDPLite http://people.freebsd.org/~kevlo/udplite.diff
`# patch <udplite.diff`
3. PF_MTAG 1 & 2
a. http://people.freebsd.org/~mm/patches/pf_mtag.patch
`# patch <pf_mtag.patch`
b. http://people.freebsd.org/~mm/patches/pf_mtag.2.patch
`# patch <pf_mtag.2.patch`

The build should be done with -j3(+X )with X=number of cores above 2.
Keep the kernel hertz rate at 2000.


----------



## sossego (Apr 5, 2014)

I've encountered an Error 2 with the parallel build; so, for now, scratch the "-j3(+X)" option.


----------



## sossego (Apr 5, 2014)

Okay, temporary file in /usr/obj/... of time.h is the breaking point.


----------



## sossego (Apr 5, 2014)

Edit /usr/src/sys/sys/time.h to include the full path of /usr/src/sys/vps/vps.h.


----------



## sossego (Apr 14, 2014)

My laptop fizzled out on me. If anyone has made a record of your progress with this project, 
then please let it be known here. Thanks muchly.


----------



## sossego (May 10, 2014)

Be sure to have your Android embedded device rooted. When it is possible, I will inquire on loading alternate- Read that as non-Linux based- system.


----------

