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

WIP: mingw32 cross compile support (under OpenBSD and Ubuntu) #85

Open
wants to merge 23 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
4d2144c
Add cscope files to gitignore
n1000 Sep 20, 2015
d91b083
Use macros for byte swapping on WIN32 platforms
n1000 Sep 20, 2015
aeb23c3
Don't attempt to compile tools not supported under WIN32
n1000 Sep 20, 2015
d27ae85
Move mod2bits and mod2db to external C file
n1000 Sep 20, 2015
cf1dbc9
Remove some unnecessary extern statements
n1000 Sep 20, 2015
5beb9ce
Add missing object files to Makefiles for WIN32 builds
n1000 Sep 20, 2015
0173638
Add S_IRGRP and S_IROTH definitions for Windows (defined as 0)
n1000 Sep 20, 2015
d9269b7
Fix WIN32 compilation errors
n1000 Sep 20, 2015
659cf41
Add make.def definitions for MingGW Cross Compling
n1000 Sep 20, 2015
7e04cf3
Fix byte swap issue in coqos_add
n1000 Sep 20, 2015
9964708
Compile pcapdevs for mingw32 target
n1000 Sep 20, 2015
024723c
Add mingw required header files and pcap libraries
n1000 Sep 20, 2015
374e6d9
Only attempt to strip $TOOLS if $TOOLS is defined
n1000 Sep 20, 2015
f03b2b9
Strip MingGW generated executables by default
n1000 Sep 20, 2015
650bac1
Add SLEEP_MS to sleep for milliseconds
n1000 Sep 26, 2015
5711b95
Replace usage of sleep() with SLEEP()
n1000 Sep 20, 2015
e9ae73e
Add Ubuntu / OpenBSD MinGW32 cross-compile examples
n1000 Oct 4, 2015
edadddb
Remove now unused __bswap.c
n1000 Oct 4, 2015
ba4cae1
Fix a few compile errors in more recent mingw32 build
n1000 Oct 16, 2016
f18b141
Ensure ether_header is packed
n1000 Oct 16, 2016
340b170
Add cygwin TOOLPATH and CROSS variables
n1000 Oct 16, 2016
26cd599
Disable ms-bitfields, as this feature breaks structure packing
n1000 Oct 16, 2016
0edb802
Enable int6kdetect and hpav
n1000 Oct 17, 2016
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ t.*
temp.*
test.*
*.a
cscope.*
25 changes: 16 additions & 9 deletions ether/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,14 @@ CFLAGS+=
LDFLAGS+=
TRASH=*.o *.obj *.exe t t.* *~ *.[0-9][0-9][0-9]
FILES=Makefile *.mak *.sh *.c *.h
TOOLS=efbu efeu efru efsu edru edsu nics
TOOLS=efbu efeu efru efsu edru edsu

ifneq ($(TARGET), mingw32)
TOOLS+=nics
else
TOOLS+=pcapdevs
endif

PAGES=efbu.1 efeu.1 efru.1 efsu.1 edru.1 edsu.1 pcapdevs.1 nics.1

# ====================================================================
Expand All @@ -24,8 +31,8 @@ PAGES=efbu.1 efeu.1 efru.1 efsu.1 edru.1 edsu.1 pcapdevs.1 nics.1

all compile: ${TOOLS}
compact: compile
if [ ! -z ${STRIP} ]; then ${STRIP} ${TOOLS}; fi
if [ -x /usr/local/bin/upx ]; then upx --best ${TOOLS}; fi
if [ ! -z ${STRIP} -a ! -z ${TOOLS} ]; then ${STRIP} ${TOOLS}; fi
if [ -x /usr/local/bin/upx -a ! -z ${TOOLS} ]; then upx --best ${TOOLS}; fi
library:
install -m ${DIR_PERM} -o ${OWNER} -g ${GROUP} -d ${BIN}
scripts:
Expand Down Expand Up @@ -59,12 +66,12 @@ ignore:
# --------------------------------------------------------------------

pcapdevs: pcapdevs.o getoptv.o putoptv.o version.o error.o hexdecode.o gethwaddr.o
efbu: efbu.o getoptv.o putoptv.o version.o error.o todigit.o hexencode.o uintspec.o hexdump.o channel.o openchannel.o sendpacket.o readpacket.o closechannel.o todigit.o channel.o basespec.o
efru: efru.o getoptv.o putoptv.o version.o basespec.o uintspec.o todigit.o hexdump.o error.o channel.o openchannel.o closechannel.o sendpacket.o readpacket.o
efeu: efeu.o getoptv.o putoptv.o version.o basespec.o uintspec.o todigit.o hexdump.o error.o channel.o openchannel.o closechannel.o sendpacket.o readpacket.o memswap.o
efsu: efsu.o getoptv.o putoptv.o version.o error.o todigit.o hexencode.o uintspec.o hexload.o hexdump.o channel.o openchannel.o sendpacket.o readpacket.o closechannel.o todigit.o basespec.o channel.o synonym.o
edru: edru.o getoptv.o putoptv.o version.o error.o hexdump.o hexdecode.o hexstring.o channel.o openchannel.o closechannel.o sendpacket.o readpacket.o uintspec.o todigit.o basespec.o
edsu: edsu.o getoptv.o putoptv.o version.o efreopen.o uintspec.o todigit.o hexdump.o hexencode.o error.o channel.o openchannel.o closechannel.o readpacket.o sendpacket.o basespec.o
efbu: efbu.o getoptv.o putoptv.o version.o error.o todigit.o hexencode.o uintspec.o hexdump.o channel.o openchannel.o sendpacket.o readpacket.o closechannel.o todigit.o channel.o basespec.o getifname.o gethwaddr.o
efru: efru.o getoptv.o putoptv.o version.o basespec.o uintspec.o todigit.o hexdump.o error.o channel.o openchannel.o closechannel.o sendpacket.o readpacket.o getifname.o gethwaddr.o
efeu: efeu.o getoptv.o putoptv.o version.o basespec.o uintspec.o todigit.o hexdump.o error.o channel.o openchannel.o closechannel.o sendpacket.o readpacket.o memswap.o getifname.o gethwaddr.o
efsu: efsu.o getoptv.o putoptv.o version.o error.o todigit.o hexencode.o uintspec.o hexload.o hexdump.o channel.o openchannel.o sendpacket.o readpacket.o closechannel.o todigit.o basespec.o channel.o synonym.o getifname.o gethwaddr.o
edru: edru.o getoptv.o putoptv.o version.o error.o hexdump.o hexdecode.o hexstring.o channel.o openchannel.o closechannel.o sendpacket.o readpacket.o uintspec.o todigit.o basespec.o getifname.o gethwaddr.o
edsu: edsu.o getoptv.o putoptv.o version.o efreopen.o uintspec.o todigit.o hexdump.o hexencode.o error.o channel.o openchannel.o closechannel.o readpacket.o sendpacket.o basespec.o getifname.o gethwaddr.o
nics: nics.o getoptv.o putoptv.o version.o error.o hexdecode.o decdecode.o hexstring.o decstring.o hostnics.o
client: client.o getoptv.o putoptv.o version.o error.o
server: server.o getoptv.o putoptv.o version.o error.o
Expand Down
3 changes: 2 additions & 1 deletion ether/edsu.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
#include "../tools/error.h"
#include "../tools/files.h"
#include "../tools/flags.h"
#include "../tools/timer.h"
#include "../ether/ether.h"
#include "../ether/channel.h"

Expand Down Expand Up @@ -144,7 +145,7 @@ signed function (struct channel * channel, unsigned pause, signed fd)
{
error (1, errno, CHANNEL_CANTSEND);
}
sleep (pause);
SLEEP (pause);
}
return (0);
}
Expand Down
5 changes: 3 additions & 2 deletions ether/efsu.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
#include "../tools/memory.h"
#include "../tools/number.h"
#include "../tools/symbol.h"
#include "../tools/timer.h"
#include "../tools/flags.h"
#include "../ether/channel.h"

Expand Down Expand Up @@ -209,7 +210,7 @@ static void iterate (int argc, char const * argv [], struct channel * channel, u
argv++;
if ((argc) && (* argv))
{
sleep (pause);
SLEEP (pause);
}
}
return;
Expand Down Expand Up @@ -335,7 +336,7 @@ int main (int argc, char const * argv [])
iterate (argc, argv, &channel, pause);
if (loop)
{
sleep (delay);
SLEEP (delay);
}
}
closechannel (&channel);
Expand Down
2 changes: 0 additions & 2 deletions ether/fcs.c
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,6 @@ static uint32_t ReflectBits (uint32_t value, uint32_t bits)
static void InitCRCTable (uint32_t CRCTable [])

{
extern uint32_t CRCTable [];
uint32_t word;
uint32_t bit;
for (word = 0; word < 256; word++)
Expand Down Expand Up @@ -371,7 +370,6 @@ static void InitCRCTable (uint32_t CRCTable [])
uint32_t ComputeCRC (uint8_t buffer [], uint32_t length)

{
extern uint32_t CRCTable [];
uint32_t crc = ~0;
while (length--)
{
Expand Down
4 changes: 0 additions & 4 deletions ether/openchannel.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,6 @@
#include "../tools/flags.h"
#include "../tools/error.h"

#if defined (__APPLE__) || defined (__OpenBSD__) || defined (__NetBSD__)
# include "../ether/gethwaddr.c"
#endif

signed openchannel (struct channel * channel)

{
Expand Down
4 changes: 2 additions & 2 deletions iso15118/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ PAGES=evse.1 pev.1

all compile: ${TOOLS}
compact: compile
if [ ! -z ${STRIP} ]; then ${STRIP} ${TOOLS}; fi
if [ -x /usr/local/bin/upx ]; then upx --best ${TOOLS}; fi
if [ ! -z ${STRIP} -a ! -z ${TOOLS} ]; then ${STRIP} ${TOOLS}; fi
if [ -x /usr/local/bin/upx -a ! -z ${TOOLS} ]; then upx --best ${TOOLS}; fi
library:
install -m ${DIR_PERM} -o ${OWNER} -g ${GROUP} -d ${BIN}
scripts:
Expand Down
4 changes: 2 additions & 2 deletions key/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ PAGES=hpavkey.1 hpavkeys.1 rkey.1 mac2pw.1 mac2pwd.1

all compile: ${TOOLS} ${LIBS}
compact: compile
if [ ! -z ${STRIP} ]; then ${STRIP} ${TOOLS}; fi
if [ -x /usr/local/bin/upx ]; then upx --best ${TOOLS}; fi
if [ ! -z ${STRIP} -a ! -z ${TOOLS} ]; then ${STRIP} ${TOOLS}; fi
if [ -x /usr/local/bin/upx -a ! -z ${TOOLS} ]; then upx --best ${TOOLS}; fi
library:
install -m ${DIR_PERM} -o ${OWNER} -g ${GROUP} -d ${BIN}
scripts:
Expand Down
2 changes: 0 additions & 2 deletions key/mac2pw.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ void (* generate)(unsigned, unsigned, unsigned, unsigned, unsigned, char, flag_t
static void function (const char * string, unsigned range, unsigned alpha, unsigned bunch, unsigned space, flag_t flags)

{
extern void (* generate)(unsigned, unsigned, unsigned, unsigned, unsigned, char, flag_t);
const char * offset = string;
unsigned vendor = 0;
unsigned device = 0;
Expand Down Expand Up @@ -194,7 +193,6 @@ static void function (const char * string, unsigned range, unsigned alpha, unsig
int main (int argc, const char * argv [])

{
extern void (* generate)(unsigned, unsigned, unsigned, unsigned, unsigned, char, flag_t);
static const char * optv [] =
{
"b:el:mn:qv",
Expand Down
2 changes: 0 additions & 2 deletions key/mac2pwd.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ void (* generate)(unsigned, unsigned, unsigned, unsigned, unsigned, char, flag_t
static void function (const char * file, unsigned alpha, unsigned bunch, unsigned space, flag_t flags)

{
extern void (* generate)(unsigned, unsigned, unsigned, unsigned, unsigned, char, flag_t);
unsigned line = 1;
unsigned radix = 0x10;
unsigned width;
Expand Down Expand Up @@ -205,7 +204,6 @@ static void function (const char * file, unsigned alpha, unsigned bunch, unsigne
int main (int argc, const char * argv [])

{
extern void (* generate)(unsigned, unsigned, unsigned, unsigned, unsigned, char, flag_t);
static const char * optv [] =
{
"b:el:mqv",
Expand Down
21 changes: 21 additions & 0 deletions make.def
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,27 @@

# include ../../../../build/scripts/$(BOARD_TYPE)/config.$(BOARD_TYPE)

# ====================================================================
# MinGW32 Cross Compile;
# --------------------------------------------------------------------

# Ubuntu
#TOOLPATH=/usr/bin
#CROSS=$(TOOLPATH)/i686-w64-mingw32-

# OpenBSD
#TOOLPATH=/usr/local/mingw32/bin
#CROSS=$(TOOLPATH)/i386-mingw32-

# Cygwin
#TOOLPATH=/usr/bin
#CROSS=$(TOOLPATH)/i686-w64-mingw32-

# Common
#EXTRA_LDFLAGS=-s -L../mingw/lib -lwpcap -lPacket -lws2_32
#EXTRA_CFLAGS=-DWINPCAP -mno-ms-bitfields -I../mingw/include
#TARGET=mingw32

# ====================================================================
# Atheros Wifi Router Software Symbols;
# --------------------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions mdio/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ PAGES=mdioblock.1 mdioblock2.1 mdiodump.1

all compile: ${TOOLS}
compact: compile
if [ ! -z ${STRIP} ]; then ${STRIP} ${TOOLS}; fi
if [ -x /usr/local/bin/upx ]; then upx --best ${TOOLS}; fi
if [ ! -z ${STRIP} -a ! -z ${TOOLS} ]; then ${STRIP} ${TOOLS}; fi
if [ -x /usr/local/bin/upx -a ! -z ${TOOLS} ]; then upx --best ${TOOLS}; fi
library:
install -m ${DIR_PERM} -o ${OWNER} -g ${GROUP} -d ${BIN}
scripts:
Expand Down
2 changes: 0 additions & 2 deletions mdio/mdioblock.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ static signed mygetc ()
static uint16_t integer (unsigned radix)

{
extern signed c;
uint16_t value = 0;
unsigned digit = 0;
while ((digit = todigit (c)) < radix)
Expand Down Expand Up @@ -171,7 +170,6 @@ static uint16_t integer (unsigned radix)
static void assemble (flag_t flags)

{
extern signed c;
c = mygetc ();
while (c != EOF)
{
Expand Down
2 changes: 0 additions & 2 deletions mdio/mdioblock2.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,6 @@ static uint32_t mask;
static signed mygetc ()

{
extern unsigned row;
extern unsigned col;
signed c = getc (stdin);
if (c == '\n')
{
Expand Down
1 change: 1 addition & 0 deletions mdio/mdiogen.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
#include "../tools/memory.h"
#include "../tools/endian.h"
#include "../tools/error.h"
#include "../tools/files.h"
#include "../mdio/mdio.h"

/*====================================================================*
Expand Down
Loading