Skip to contentSkip to conversation

Allow kernel to build on Cygwin

PATCH In review Deepak Saxena 4 participants 7 messages Feb 23, 2007 – Feb 24, 2007

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Allow kernel to build on Cygwin

This patch contains a set of small fixes to allow the kernel to build under the Cygwin environment, which is unfortunately used by more people than one would think in the embedded world. :(

---
 lib/gen_crc32table.c                       |    2 ++
 scripts/kconfig/Makefile                   |    6 ++++++
 scripts/kconfig/lxdialog/check-lxdialog.sh |    4 ++++
 scripts/mod/file2alias.c                   |    4 ++++
 scripts/mod/mk_elfconfig.c                 |    4 ++++
 scripts/mod/modpost.h                      |    4 ++++
 scripts/mod/sumversion.c                   |    6 +++++-
 7 files changed, 29 insertions(+), 1 deletion(-)
lib/gen_crc32table.c +2 -0
index bea5d97..ce447ff 100644
@@ -1,6 +1,8 @@
 #include <stdio.h>
 #include "crc32defs.h"
+#ifndef __CYGWIN__
 #include <inttypes.h>
+#endif
 
 #define ENTRIES_PER_LINE 4
 
scripts/kconfig/Makefile +6 -0
index 7e7e147..ca57efe 100644
@@ -161,6 +161,12 @@ HOSTLOADLIBES_gconf	= `pkg-config --libs
 HOSTCFLAGS_gconf.o	= `pkg-config --cflags gtk+-2.0 gmodule-2.0 libglade-2.0` \
                           -D LKC_DIRECT_LINK
 
+HOST_OS := $(shell uname -o)
+ifeq ($(HOST_OS),Cygwin)
+HOSTLOADLIBES_mconf	= -lintl
+HOSTLOADLIBES_conf	= -lintl
+endif
+
 $(obj)/qconf.o: $(obj)/.tmp_qtcheck
 
 ifeq ($(qconf-target),1)
scripts/kconfig/lxdialog/check-lxdialog.sh +4 -0
index 120d624..c44b559 100644
@@ -4,6 +4,10 @@ # Check ncurses compatibility
 # What library to link
 ldflags()
 {
+	if [ "`uname -o`" == "Cygwin" ]; then
+		echo '-lintl -lncurses'
+		exit
+	fi
 	$cc -print-file-name=libncursesw.so | grep -q /
 	if [ $? -eq 0 ]; then
 		echo '-lncursesw'
scripts/mod/file2alias.c +4 -0
index f61c9cc..479293f 100644
@@ -29,7 +29,11 @@ #endif
 
 #include <ctype.h>
 
+#if defined(__CYGWIN__)
+typedef __uint32_t	__u32;
+#else
 typedef uint32_t	__u32;
+#endif
 typedef uint16_t	__u16;
 typedef unsigned char	__u8;
 
scripts/mod/mk_elfconfig.c +4 -0
index 725d61c..4908f7a 100644
@@ -1,7 +1,11 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#ifdef __CYGWIN__
+#include <libelf.h>
+#else
 #include <elf.h>
+#endif
 
 int
 main(int argc, char **argv)
scripts/mod/modpost.h +4 -0
index d398c61..7cdf2c6 100644
@@ -7,7 +7,11 @@ #include <sys/stat.h>
 #include <sys/mman.h>
 #include <fcntl.h>
 #include <unistd.h>
+#ifdef __CYGWIN__
+#include <libelf.h>
+#else
 #include <elf.h>
+#endif
 
 #include "elfconfig.h"
 
scripts/mod/sumversion.c +5 -1
index 8a28756..4404f87 100644
@@ -1,7 +1,11 @@
+#if defined(__sun__)
 #include <netinet/in.h>
-#ifdef __sun__
 #include <inttypes.h>
+#elif defined(__CYGWIN__)
+#include <asm/byteorder.h>	/* For ntohl/htonl */
+#include <limits.h>
 #else
+#include <netinet/in.h>
 #include <stdint.h>
 #endif
 #include <ctype.h>
Signature · 4 lines
Deepak Saxena - [email protected] - http://www.plexity.net

In the end, they will not say, "those were dark times,"  they will ask
"why were their poets silent?" - Bertolt Brecht
#1 lore raw

Hi,

Quoted 5 lines · Deepak Saxena <dsaxena <at> plexity.net> writes:

This patch contains a set of small fixes to allow the kernel to build under the Cygwin environment, which is unfortunately used by more people than one would think in the embedded world. :(

Yes, I did similar patch, and there are needed for everything (busybox, glibc, ...)
-D LKC_DIRECT_LINK

scripts/kconfig/Makefile HOSTLOADLIBES_gconf = `pkg-config --libs · line 169

Quoted 7 lines
scripts/kconfig/Makefile +6 -0
+HOST_OS := $(shell uname -o)
+ifeq ($(HOST_OS),Cygwin)
+HOSTLOADLIBES_mconf	= -lintl
+HOSTLOADLIBES_conf	= -lintl
+endif
+

Hum, this test should be done if we detect nls support. See ifeq ($(KBUILD_HAVE_NLS),no) ...

scripts/kconfig/lxdialog/check-lxdialog.sh # Check ncurses compatibility · line 10

Quoted 10 lines
scripts/kconfig/lxdialog/check-lxdialog.sh +4 -0
 <at>  <at>  -4,6 +4,10  <at>  <at>  # Check ncurses compatibility
 # What library to link
 ldflags()
 {
+	if [ "`uname -o`" == "Cygwin" ]; then
+		echo '-lintl -lncurses'
+		exit
+	fi

You should test against libncurses.a and not hardcode it for cygwin...

Matthieu

#2 lore raw

On Feb 23 2007, at 20:37, Matthieu CASTET was caught saying:

Quoted 13 lines

Hi,

Quoted 5 lines · Deepak Saxena <dsaxena <at> plexity.net> writes:

This patch contains a set of small fixes to allow the kernel to build under the Cygwin environment, which is unfortunately used by more people than one would think in the embedded world. :(

Yes, I did similar patch, and there are needed for everything (busybox, glibc, ...)
-D LKC_DIRECT_LINK

Quoted 1 line
Quoted 8 lines

scripts/kconfig/Makefile HOSTLOADLIBES_gconf = `pkg-config --libs · line 169

Quoted 6 lines
scripts/kconfig/Makefile +6 -0
+HOST_OS := $(shell uname -o)
+ifeq ($(HOST_OS),Cygwin)
+HOSTLOADLIBES_mconf	= -lintl
+HOSTLOADLIBES_conf	= -lintl
+endif
+

Hum, this test should be done if we detect nls support. See ifeq ($(KBUILD_HAVE_NLS),no) ...

OK, will do. I'm running into the same issue trying to fix building under uclibc and would defintely be nicer to have a single solution.

~Deepak

Signature · 4 lines
Deepak Saxena - [email protected] - http://www.plexity.net

In the end, they will not say, "those were dark times,"  they will ask
"why were their poets silent?" - Bertolt Brecht
#3 lore raw
In reply to Deepak Saxena
Quoted 6 lines · Deepak Saxena
lib/gen_crc32table.c +0 -0
index bea5d97..ce447ff 100644

lib/gen_crc32table.c line 8

Quoted 8 lines
lib/gen_crc32table.c +2 -0
@@ -1,6 +1,8 @@
 #include <stdio.h>
 #include "crc32defs.h"
+#ifndef __CYGWIN__
 #include <inttypes.h>
+#endif
 
 #define ENTRIES_PER_LINE 4
 

Cygwin has <inttypes.h> just fine; what are you trying to do here?

-hpa

#6 lore raw
In reply to Deepak Saxena
Quoted 5 lines · Deepak Saxena

This patch contains a set of small fixes to allow the kernel to build under the Cygwin environment, which is unfortunately used by more people than one would think in the embedded world. :(

I have one major problem with this patch: none of the hacks are commented, which invites cargo cult programming by people who needs to further maintain the code.

-hpa

#4 lore raw
In reply to H. Peter Anvin
Quoted 13 lines · H. Peter Anvin
Quoted 12 lines · Deepak Saxena
lib/gen_crc32table.c +2 -0
index bea5d97..ce447ff 100644
@@ -1,6 +1,8 @@
 # include <stdio.h>
 # include "crc32defs.h"
+#ifndef __CYGWIN__
 #include <inttypes.h>
+#endif
 
Quoted 3 lines

lib/gen_crc32table.c line 7

Quoted 1 line
lib/gen_crc32table.c +0 -0
 #define ENTRIES_PER_LINE 4

Cygwin has <inttypes.h> just fine; what are you trying to do here?

What's the benefit of inttypes.h over stdint.h?

Jan

Signature · 1 line
ft: http://freshmeat.net/p/chaostables/
#5 lore raw
Quoted 13 lines · Jan Engelhardt
Quoted 12 lines · H. Peter Anvin
Quoted 11 lines · Deepak Saxena
lib/gen_crc32table.c +2 -0
index bea5d97..ce447ff 100644
@@ -1,6 +1,8 @@
 # include <stdio.h>
 # include "crc32defs.h"
+#ifndef __CYGWIN__
 #include <inttypes.h>
+#endif
 
Quoted 5 lines
Quoted 2 lines

lib/gen_crc32table.c line 7

Quoted 1 line
lib/gen_crc32table.c +0 -0
 #define ENTRIES_PER_LINE 4

Cygwin has <inttypes.h> just fine; what are you trying to do here?

What's the benefit of inttypes.h over stdint.h?

<inttypes.h> is a superset of <stdint.h>; some older platforms don't have <stdint.h> (but has all the contents thereof in <inttypes.h>) however.

In general <inttypes.h> is what you want. The utility of <stdint.h> is relatively limited; it looks like it's intended so that <stdint.h> contains the compiler-specific portions rather than the library-specific portions.

-hpa