Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mac OS X port #1

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 39 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,35 @@ Prerequisites for all platforms
===============================

* CMake 2.8.0 or later
* GTest
* GTest (Google C++ Testing Framework, optional)

Mac OS X
========

* XCode
* CMake (install using homebrew or MacPorts)

To build without tests; open a terminal, then:
```
$ mkdir build
$ cd build
$ cmake ..
$ make
````

If tests should be built, add path to gtest install like this:
```
$ cmake .. -DGTEST_ROOT=~/gtest-1.7.0
```

CMake do support different generators. To create a Xcode project use the Xcode generator like this:
```
$ cmake cmake -G Xcode ..
```
CMake have now created a Xcode project file that can be opened:
```
$ open SOEM.xcodeproj
```

Windows
=======
Expand All @@ -14,37 +42,43 @@ Windows
* Visual Studio 2013 or later

Start a developer command prompt, then:

```
$ mkdir build
$ cd build
$ cmake .. -DPCAP_ROOT_DIR=p:/WpdPack/ -DGTEST_ROOT=p:/gtest-1.7.0
$ msbuild SOEM.sln
```

To build NSIS installer:

```
$ set PATH=%PATH%;p:\nsis
$ msbuild PACKAGE.vcxproj
```

Cygwin
======

* WinPCAP developer's pack
* GCC 4.6 or later

```
$ mkdir build
$ cd build
$ cmake .. -DPCAP_ROOT_DIR=~/WpdPack -DGTEST_ROOT=~/gtest-1.7.0
$ make
````

Linux
=====

* GCC 4.6 or later

```
$ mkdir build
$ cd build
$ cmake .. -DPCAP_ROOT_DIR=~/WpdPack -DGTEST_ROOT=~/gtest-1.7.0
$ make
````

rt-kernel
=========
Expand All @@ -54,11 +88,13 @@ rt-kernel

Start a command prompt, then:

```
$ mkdir build
$ cd build
$ export RTK=/p/rt-kernel-src
$ export BSP=integrator
$ cmake -DCMAKE_TOOLCHAIN_FILE=/p/cmake/toolchain/rt-kernel-arm9e.cmake .. -G "Unix Makefiles" -DGTEST_ROOT=/p/gtest-1.7.0
$ make
```

Substitute BSP and toolchain file as appropriate.
15 changes: 15 additions & 0 deletions cmake/Darwin.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

set(OSAL_SOURCES
osal/darwin/osal.c
osal/darwin/bpf.c
)
set(OSAL_INCLUDES
osal/darwin
)
set(OSAL_LIBS
""
)

# set(CMAKE_C_FLAGS "-Wall -Wextra -Wno-unused-parameter -ffunction-sections")
# set(CMAKE_CXX_FLAGS "-Wall -Wextra -Wno-unused-parameter -ffunction-sections")
# set(CMAKE_EXE_LINKER_FLAGS "-Wl,--gc-sections")
6 changes: 3 additions & 3 deletions src/alloc.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@

#include <alloc.h>
#include "alloc.h"

#include <options.h>
#include <log.h>
#include "options.h"
#include "log.h"

#include <string.h>

Expand Down
4 changes: 2 additions & 2 deletions src/alloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ extern "C"
{
#endif

#include <ec_api.h>
#include <ec_types.h>
#include "ec_api.h"
#include "ec_types.h"

ec_net_t * ec_alloc_net (void);
ec_slave_t * ec_alloc_slave (void);
Expand Down
10 changes: 5 additions & 5 deletions src/config.c
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@

#include <config.h>
#include "config.h"

#include <options.h>
#include <log.h>
#include "options.h"
#include "log.h"

#include <frame.h>
#include "frame.h"
#include <string.h>

int ec_config_static (ec_net_t * net, ec_slave_config_t * cfg)
{
uint8_t buffer[1400];
ec_frame_t * frame = ec_frame_init (buffer);
ec_frame_t * frame;
ec_pdu_t * pdu;
int wkc;
ec_slave_t * slave;
Expand Down
4 changes: 2 additions & 2 deletions src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ extern "C"
{
#endif

#include <ec_api.h>
#include <ec_types.h>
#include "ec_api.h"
#include "ec_types.h"

#ifdef __cplusplus
}
Expand Down
4 changes: 2 additions & 2 deletions src/ec_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ extern "C"
#include <stdint.h>
#include <stddef.h>

#include <cc.h>
#include <osal.h>
#include "cc.h"
#include "osal.h"

typedef struct ec_general
{
Expand Down
12 changes: 6 additions & 6 deletions src/eeprom.c
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@

#include <eeprom.h>
#include <ec_types.h>
#include <frame.h>
#include "eeprom.h"
#include "ec_types.h"
#include "frame.h"

#include <options.h>
#include <log.h>
#include "options.h"
#include "log.h"

#include <string.h>
#include <stdio.h>
Expand Down Expand Up @@ -181,7 +181,7 @@ static int ec_eeprom_read32 (ec_net_t * net, ec_slave_t * slave, int address,
size = (size > 4) ? 4 : size;
memcpy (data, pdu->data, size);

return size;
return (int)size;
}

int ec_eeprom_read (ec_net_t * net, ec_slave_t * slave, int address,
Expand Down
4 changes: 2 additions & 2 deletions src/eeprom.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ extern "C"
{
#endif

#include <ec_api.h>
#include <ec_types.h>
#include "ec_api.h"
#include "ec_types.h"

int ec_eeprom_broadcast_read (ec_net_t * net, uint16_t address, uint32_t offset);
int ec_eeprom_read (ec_net_t * net, ec_slave_t * slave, int address, void * data, size_t size);
Expand Down
11 changes: 6 additions & 5 deletions src/frame.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@

#include <frame.h>
#include <nic.h>
#include "frame.h"
#include "nic.h"

#include <options.h>
#include <log.h>
#include "options.h"
#include "log.h"

#include <stdint.h>
#include <string.h>
Expand Down Expand Up @@ -278,7 +278,7 @@ int ec_frame_txrx (ec_nic_t * nic, ec_frame_t * frame)
int length = sizeof(ec_frame_t) + frame->length + sizeof(uint16_t);
int result;
ec_pdu_t * pdu;
ec_pdu_t * previous;
ec_pdu_t * previous = NULL;
uint16_t wkc;

pdu = ec_frame_first_pdu (frame);
Expand All @@ -293,6 +293,7 @@ int ec_frame_txrx (ec_nic_t * nic, ec_frame_t * frame)
}

/* Clear NEXT field of final PDU */
CC_ASSERT(previous != NULL);
previous->len &= ~EC_PDU_LENGTH_NEXT;

/* Set DLPDU flag */
Expand Down
6 changes: 3 additions & 3 deletions src/frame.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ extern "C"
{
#endif

#include <ec_api.h>
#include <ec_types.h>
#include "ec_api.h"
#include "ec_types.h"

CC_PACKED_BEGIN
typedef struct CC_PACKED ec_frame
Expand Down Expand Up @@ -175,7 +175,7 @@ void ec_frame_FPWR16 (ec_frame_t * frame, uint16_t adp, uint16_t ado,
void ec_frame_FPWR32 (ec_frame_t * frame, uint16_t adp, uint16_t ado,
uint32_t value);

#include <nic.h>
#include "nic.h"
int ec_frame_txrx (ec_nic_t * nic, ec_frame_t * frame);

#ifdef __cplusplus
Expand Down
4 changes: 2 additions & 2 deletions src/log.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ extern "C"
{
#endif

#include <options.h>
#include <osal.h>
#include "options.h"
#include "osal.h"

#define LOG_LEVEL_DEBUG 0x00
#define LOG_LEVEL_INFO 0x01
Expand Down
18 changes: 9 additions & 9 deletions src/net.c
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@

#include <net.h>
#include <nic.h>
#include "net.h"
#include "nic.h"

#include <options.h>
#include <version.h>
#include <log.h>
#include <osal.h>
#include "options.h"
#include "version.h"
#include "log.h"
#include "osal.h"

#include <frame.h>
#include <eeprom.h>
#include "frame.h"
#include "eeprom.h"
#include <string.h>
#include <alloc.h>
#include "alloc.h"

static void ec_net_add_slave (ec_net_t * net, ec_slave_t * slave)
{
Expand Down
4 changes: 2 additions & 2 deletions src/net.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ extern "C"
{
#endif

#include <ec_api.h>
#include <ec_types.h>
#include "ec_api.h"
#include "ec_types.h"

#ifdef __cplusplus
}
Expand Down
4 changes: 2 additions & 2 deletions src/nic.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ extern "C"
{
#endif

#include <ec_api.h>
#include <ec_types.h>
#include "ec_api.h"
#include "ec_types.h"

int ec_nic_send (ec_nic_t * nic, const void * buffer, size_t size);
int ec_nic_receive (ec_nic_t * nic, void * buffer, size_t size);
Expand Down
2 changes: 1 addition & 1 deletion src/osal.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ extern "C"

#include <stdarg.h>
#include <stddef.h>
#include <nic.h>
#include "nic.h"

void os_log (int type, const char * fmt, ...);
void * os_malloc (size_t size);
Expand Down
Loading