2009-08-06 08:08:32

by Philip Prindeville

[permalink] [raw]
Subject: CRDA and cross-compilation

--- crda-1.1.0/Makefile.orig 2009-04-17 14:49:45.000000000 -0700
+++ crda-1.1.0/Makefile 2009-08-06 00:53:47.000000000 -0700
@@ -1,6 +1,6 @@
# Modify as you see fit, note this is built into crda,
# so if you change it here you will have to change crda.c
-REG_BIN?=/usr/lib/crda/regulatory.bin
+REG_BIN?=$(DESTDIR)/usr/lib/crda/regulatory.bin
REG_GIT?=git://git.kernel.org/pub/scm/linux/kernel/git/linville/wireless-regdb.git

PREFIX ?= /usr/
@@ -22,46 +22,74 @@ UDEV_RULE_DIR?=/lib/udev/rules.d/
# with make PUBKEY_DIR=/usr/lib/crda/pubkeys
PUBKEY_DIR?=pubkeys

+MKDIR ?= mkdir -p
+INSTALL ?= install
+
CFLAGS += -Wall -g

all: $(REG_BIN) crda intersect verify

-ifeq ($(USE_OPENSSL),1)
+ifeq ($(CROSS_COMPILE),)
+
+ ifeq ($(USE_OPENSSL),1)
CFLAGS += -DUSE_OPENSSL `pkg-config --cflags openssl`
LDLIBS += `pkg-config --libs openssl`

reglib.o: keys-ssl.c

-else
+ else
CFLAGS += -DUSE_GCRYPT
LDLIBS += -lgcrypt

reglib.o: keys-gcrypt.c

-endif
-MKDIR ?= mkdir -p
-INSTALL ?= install
+ endif

NL1FOUND := $(shell pkg-config --atleast-version=1 libnl-1 && echo Y)
NL2FOUND := $(shell pkg-config --atleast-version=2 libnl-2.0 && echo Y)

-ifeq ($(NL1FOUND),Y)
+ ifeq ($(NL1FOUND),Y)
NLLIBNAME = libnl-1
-endif
+ endif

-ifeq ($(NL2FOUND),Y)
+ ifeq ($(NL2FOUND),Y)
CFLAGS += -DCONFIG_LIBNL20
NLLIBS += -lnl-genl
NLLIBNAME = libnl-2.0
-endif
+ endif

-ifeq ($(NLLIBNAME),)
+ ifeq ($(NLLIBNAME),)
$(error Cannot find development files for any supported version of libnl)
-endif
+ endif

NLLIBS += `pkg-config --libs $(NLLIBNAME)`
CFLAGS += `pkg-config --cflags $(NLLIBNAME)`

+else
+
+ ifeq ($(USE_OPENSSL),1)
+CFLAGS += -DUSE_OPENSSL
+LDLIBS += -lssl
+
+reglib.o: keys-ssl.c
+
+ else
+CFLAGS += -DUSE_GCRYPT
+LDLIBS += -lgcrypt
+
+reglib.o: keys-gcrypt.c
+
+ endif
+
+ ifeq ($(USE_LIBNL20),1)
+CFLAGS += DCONFIG_LIBNL20
+NLLIBS = -lnl-genl -lnl-2.0
+ else
+NLLIBS = -lnl
+ endif
+
+endif
+
ifeq ($(V),1)
Q=
NQ=@true
@@ -111,6 +139,10 @@ verify: $(REG_BIN) regdbdump
@$(NQ) ' GZIP' $<
$(Q)gzip < $< > $@

+install-reg:
+ git clone $(REG_GIT) wireless-regdb
+ $(INSTALL) -m 0444 -D wireless-regdb/regulatory.bin $(REG_BIN)
+
install: crda crda.8.gz regdbdump.8.gz
$(NQ) ' INSTALL crda'
$(Q)$(MKDIR) $(DESTDIR)/$(SBINDIR)


Attachments:
crda-cross-compile.patch (2.21 kB)

2009-08-06 19:22:08

by Jon Loeliger

[permalink] [raw]
Subject: Re: CRDA and cross-compilation

On Thu, 2009-08-06 at 12:14 -0700, Philip A. Prindeville wrote:

>
> Can someone roll *all* the patches together? For instance, "pkg-config" shouldn't be used on a cross-compile...
>
> -Philip


Philip,

These are the sorts of issues that made my patch seem
more complicated than first blush might suggest was needed.

jdl



2009-08-06 18:41:12

by Pavel Roskin

[permalink] [raw]
Subject: Re: CRDA and cross-compilation

On Thu, 2009-08-06 at 11:30 -0700, Philip A. Prindeville wrote:

> Dumb question but, why not just build a target and host version each of regdumpdb?

Because it's more complicated. Because we may want to disable
verification for reasons other than cross-compiling. Because it's
already possible:

set -e
make verify REG_BIN=/targetfs/regulatory.bin
make clean
make all_noverify CC=cross-gcc

--
Regards,
Pavel Roskin

2009-08-06 19:14:08

by Philip Prindeville

[permalink] [raw]
Subject: Re: CRDA and cross-compilation

Pavel Roskin wrote:
> On Thu, 2009-08-06 at 09:56 -0700, Luis R. Rodriguez wrote:
>
>> ACK, is it possible to make it simpler?
>
> OK, here's my take.
>
> We only need a native compiler to verify regulatory.bin. I believe it's
> orthogonal to building CRDA.
>
> For someone doing a cross-compilation, it makes no sense to verify the
> installed regulatory.bin. Thus, the verification should be optional.
>
> But the compilation of regdbdump shouldn't be. Firstly, it's installed
> by "make install". Secondly, somebody may want to verify regulatory.bin
> on the target system.
>
> Here's the patch:
>
>
> crda: make it possible to disable verification
>
> Signed-off-by: Pavel Roskin <[email protected]>
> ---
> Makefile | 7 +++++--
> 1 files changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/Makefile b/Makefile
> index b93b735..3cc61c2 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -24,7 +24,9 @@ PUBKEY_DIR?=pubkeys
>
> CFLAGS += -Wall -g
>
> -all: $(REG_BIN) crda intersect verify
> +all: all_noverify verify
> +
> +all_noverify: crda intersect regdbdump
>
> ifeq ($(USE_OPENSSL),1)
> CFLAGS += -DUSE_OPENSSL `pkg-config --cflags openssl`
> @@ -74,11 +76,12 @@ $(REG_BIN):
> $(NQ) ' EXIST ' $(REG_BIN)
> $(NQ)
> $(NQ) ERROR: The file: $(REG_BIN) is missing. You need this in place in order
> - $(NQ) to build CRDA. You can get it from:
> + $(NQ) to verify CRDA. You can get it from:
> $(NQ)
> $(NQ) $(REG_GIT)
> $(NQ)
> $(NQ) "Once cloned (no need to build) cp regulatory.bin to $(REG_BIN)"
> + $(NQ) "Use \"make noverify\" to disable verification"
> $(NQ)
> $(Q) exit 1
>
>

Can someone roll *all* the patches together? For instance, "pkg-config" shouldn't be used on a cross-compile...

-Philip


2009-08-06 17:45:09

by Pavel Roskin

[permalink] [raw]
Subject: Re: CRDA and cross-compilation

On Thu, 2009-08-06 at 09:56 -0700, Luis R. Rodriguez wrote:

> ACK, is it possible to make it simpler?

OK, here's my take.

We only need a native compiler to verify regulatory.bin. I believe it's
orthogonal to building CRDA.

For someone doing a cross-compilation, it makes no sense to verify the
installed regulatory.bin. Thus, the verification should be optional.

But the compilation of regdbdump shouldn't be. Firstly, it's installed
by "make install". Secondly, somebody may want to verify regulatory.bin
on the target system.

Here's the patch:


crda: make it possible to disable verification

Signed-off-by: Pavel Roskin <[email protected]>
---
Makefile | 7 +++++--
1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index b93b735..3cc61c2 100644
--- a/Makefile
+++ b/Makefile
@@ -24,7 +24,9 @@ PUBKEY_DIR?=pubkeys

CFLAGS += -Wall -g

-all: $(REG_BIN) crda intersect verify
+all: all_noverify verify
+
+all_noverify: crda intersect regdbdump

ifeq ($(USE_OPENSSL),1)
CFLAGS += -DUSE_OPENSSL `pkg-config --cflags openssl`
@@ -74,11 +76,12 @@ $(REG_BIN):
$(NQ) ' EXIST ' $(REG_BIN)
$(NQ)
$(NQ) ERROR: The file: $(REG_BIN) is missing. You need this in place in order
- $(NQ) to build CRDA. You can get it from:
+ $(NQ) to verify CRDA. You can get it from:
$(NQ)
$(NQ) $(REG_GIT)
$(NQ)
$(NQ) "Once cloned (no need to build) cp regulatory.bin to $(REG_BIN)"
+ $(NQ) "Use \"make noverify\" to disable verification"
$(NQ)
$(Q) exit 1


--
Regards,
Pavel Roskin

2009-08-06 18:43:06

by Luis R. Rodriguez

[permalink] [raw]
Subject: Re: CRDA and cross-compilation

On Thu, Aug 6, 2009 at 10:45 AM, Pavel Roskin<[email protected]> wrote:
> On Thu, 2009-08-06 at 09:56 -0700, Luis R. Rodriguez wrote:
>
>> ACK, is it possible to make it simpler?
>
> OK, here's my take.
>
> We only need a native compiler to verify regulatory.bin.  I believe it's
> orthogonal to building CRDA.
>
> For someone doing a cross-compilation, it makes no sense to verify the
> installed regulatory.bin.  Thus, the verification should be optional.
>
> But the compilation of regdbdump shouldn't be.  Firstly, it's installed
> by "make install".  Secondly, somebody may want to verify regulatory.bin
> on the target system.
>
> Here's the patch:
>
>
> crda: make it possible to disable verification
>
> Signed-off-by: Pavel Roskin <[email protected]>
> ---
>  Makefile |    7 +++++--
>  1 files changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/Makefile b/Makefile
> index b93b735..3cc61c2 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -24,7 +24,9 @@ PUBKEY_DIR?=pubkeys
>
>  CFLAGS += -Wall -g
>
> -all: $(REG_BIN) crda intersect verify
> +all: all_noverify verify
> +
> +all_noverify: crda intersect regdbdump

You removed REG_BIN from here, was that intentional?

>  ifeq ($(USE_OPENSSL),1)
>  CFLAGS += -DUSE_OPENSSL `pkg-config --cflags openssl`
> @@ -74,11 +76,12 @@ $(REG_BIN):
>        $(NQ) '  EXIST ' $(REG_BIN)
>        $(NQ)
>        $(NQ) ERROR: The file: $(REG_BIN) is missing. You need this in place in order
> -       $(NQ) to build CRDA. You can get it from:
> +       $(NQ) to verify CRDA. You can get it from:
>        $(NQ)
>        $(NQ) $(REG_GIT)
>        $(NQ)
>        $(NQ) "Once cloned (no need to build) cp regulatory.bin to $(REG_BIN)"
> +       $(NQ) "Use \"make noverify\" to disable verification"
>        $(NQ)
>        $(Q) exit 1
>
>
> --
> Regards,
> Pavel Roskin
>

2009-08-06 17:39:02

by Philip Prindeville

[permalink] [raw]
Subject: Re: CRDA and cross-compilation

Luis R. Rodriguez wrote:
> On Thu, Aug 6, 2009 at 9:41 AM, Pavel Roskin<[email protected]> wrote:
>> On Thu, 2009-08-06 at 09:46 -0500, Jon Loeliger wrote:
>>> On Thu, 2009-08-06 at 01:08 -0700, Philip A. Prindeville wrote:
>>>> Who currently owns CRDA?
>>>>
>>>> I started to stare at cross-compiling issues, but realized that we need
>>>> two versions of reglib.o and print-regdom.o...
>>>>
>>>> One to link with regdumpdb (compiled with HOSTCC) and one to link with
>>>> everything else (compiled with TARGET_CC)...
>>>>
>>>> No easy way to do this without a lot of changes.
>>> I posted a 5-part patch series to address this issue.
>>> To the best of my knowledge, it has not been applied yet.
>>>
>>> You can find it here:
>>>
>>> http://article.gmane.org/gmane.linux.kernel.wireless.general/35350
>> I objected against using the misleading use of the "TARGET" work in some
>> variables, but there was no reaction. Failure to react to objections is
>> the likely reason it wasn't applied.
>
> Indeed.
>
>> I also think that you add too much complexity to the Makefile.
>
> Agreed.
>
>> Also, the use of .config is not common. Most valuables can be specified
>> on the command line. That would override the definitions in Makefile,
>> and that's how it's done.
>
> Yeah for something so simple as CRDA it seems overkill to have a .config.
>
>> For instance, you can have this in Makefile:
>>
>> HOSTCC = gcc
>> CC = $(HOSTCC)
>>
>> Running "make CC=/opt/mips/bin/gcc" would override CC but not HOSTCC.
>
> ACK, is it possible to make it simpler?
>
> Luis

You could also have:

-include .config

HOSTCC ?= gcc
...

and that will only set (default) the unset variables...

-Philip


2009-08-06 16:41:28

by Pavel Roskin

[permalink] [raw]
Subject: Re: CRDA and cross-compilation

On Thu, 2009-08-06 at 09:46 -0500, Jon Loeliger wrote:
> On Thu, 2009-08-06 at 01:08 -0700, Philip A. Prindeville wrote:
> > Who currently owns CRDA?
> >
> > I started to stare at cross-compiling issues, but realized that we need
> > two versions of reglib.o and print-regdom.o...
> >
> > One to link with regdumpdb (compiled with HOSTCC) and one to link with
> > everything else (compiled with TARGET_CC)...
> >
> > No easy way to do this without a lot of changes.
>
> I posted a 5-part patch series to address this issue.
> To the best of my knowledge, it has not been applied yet.
>
> You can find it here:
>
> http://article.gmane.org/gmane.linux.kernel.wireless.general/35350

I objected against using the misleading use of the "TARGET" work in some
variables, but there was no reaction. Failure to react to objections is
the likely reason it wasn't applied.

I also think that you add too much complexity to the Makefile.

Also, the use of .config is not common. Most valuables can be specified
on the command line. That would override the definitions in Makefile,
and that's how it's done.

For instance, you can have this in Makefile:

HOSTCC = gcc
CC = $(HOSTCC)

Running "make CC=/opt/mips/bin/gcc" would override CC but not HOSTCC.

--
Regards,
Pavel Roskin

2009-08-06 15:16:05

by John W. Linville

[permalink] [raw]
Subject: Re: CRDA and cross-compilation

On Thu, Aug 06, 2009 at 01:08:30AM -0700, Philip A. Prindeville wrote:
> Who currently owns CRDA?

Luis Rodriguez <[email protected]>
Luis R. Rodriguez <[email protected]>

--
John W. Linville Someday the world will need a hero, and you
[email protected] might be all we have. Be ready.
?Viva Honduras Libre!

2009-08-06 19:08:08

by Pavel Roskin

[permalink] [raw]
Subject: Re: CRDA and cross-compilation

On Thu, 2009-08-06 at 11:42 -0700, Luis R. Rodriguez wrote:

> > -all: $(REG_BIN) crda intersect verify
> > +all: all_noverify verify
> > +
> > +all_noverify: crda intersect regdbdump
>
> You removed REG_BIN from here, was that intentional?

Yes. It's not needed for the build. As for the "verify" target, it
already depends on $(REG_BIN)

--
Regards,
Pavel Roskin

2009-08-06 16:57:11

by Luis R. Rodriguez

[permalink] [raw]
Subject: Re: CRDA and cross-compilation

On Thu, Aug 6, 2009 at 9:41 AM, Pavel Roskin<[email protected]> wrote:
> On Thu, 2009-08-06 at 09:46 -0500, Jon Loeliger wrote:
>> On Thu, 2009-08-06 at 01:08 -0700, Philip A. Prindeville wrote:
>> > Who currently owns CRDA?
>> >
>> > I started to stare at cross-compiling issues, but realized that we need
>> > two versions of reglib.o and print-regdom.o...
>> >
>> > One to link with regdumpdb (compiled with HOSTCC) and one to link with
>> > everything else (compiled with TARGET_CC)...
>> >
>> > No easy way to do this without a lot of changes.
>>
>> I posted a 5-part patch series to address this issue.
>> To the best of my knowledge, it has not been applied yet.
>>
>> You can find it here:
>>
>> http://article.gmane.org/gmane.linux.kernel.wireless.general/35350
>
> I objected against using the misleading use of the "TARGET" work in some
> variables, but there was no reaction.  Failure to react to objections is
> the likely reason it wasn't applied.

Indeed.

> I also think that you add too much complexity to the Makefile.

Agreed.

> Also, the use of .config is not common.  Most valuables can be specified
> on the command line.  That would override the definitions in Makefile,
> and that's how it's done.

Yeah for something so simple as CRDA it seems overkill to have a .config.

> For instance, you can have this in Makefile:
>
> HOSTCC = gcc
> CC = $(HOSTCC)
>
> Running "make CC=/opt/mips/bin/gcc" would override CC but not HOSTCC.

ACK, is it possible to make it simpler?

Luis

2009-08-06 19:24:16

by Luis R. Rodriguez

[permalink] [raw]
Subject: Re: CRDA and cross-compilation

On Thu, Aug 6, 2009 at 12:08 PM, Pavel Roskin<[email protected]> wrote:
> On Thu, 2009-08-06 at 11:42 -0700, Luis R. Rodriguez wrote:
>
>> > -all: $(REG_BIN) crda intersect verify
>> > +all: all_noverify verify
>> > +
>> > +all_noverify: crda intersect regdbdump
>>
>> You removed REG_BIN from here, was that intentional?
>
> Yes.  It's not needed for the build.  As for the "verify" target, it
> already depends on $(REG_BIN)

Oh nice, thanks applied!

Luis

2009-08-06 14:46:45

by Jon Loeliger

[permalink] [raw]
Subject: Re: CRDA and cross-compilation

On Thu, 2009-08-06 at 01:08 -0700, Philip A. Prindeville wrote:
> Who currently owns CRDA?
>
> I started to stare at cross-compiling issues, but realized that we need
> two versions of reglib.o and print-regdom.o...
>
> One to link with regdumpdb (compiled with HOSTCC) and one to link with
> everything else (compiled with TARGET_CC)...
>
> No easy way to do this without a lot of changes.

I posted a 5-part patch series to address this issue.
To the best of my knowledge, it has not been applied yet.

You can find it here:

http://article.gmane.org/gmane.linux.kernel.wireless.general/35350

HTH,
jdl



2009-08-06 18:31:05

by Philip Prindeville

[permalink] [raw]
Subject: Re: CRDA and cross-compilation


Pavel Roskin wrote:
> On Thu, 2009-08-06 at 09:56 -0700, Luis R. Rodriguez wrote:
>
>> ACK, is it possible to make it simpler?
>
> OK, here's my take.
>
> We only need a native compiler to verify regulatory.bin. I believe it's
> orthogonal to building CRDA.
>
> For someone doing a cross-compilation, it makes no sense to verify the
> installed regulatory.bin. Thus, the verification should be optional.
>
> But the compilation of regdbdump shouldn't be. Firstly, it's installed
> by "make install". Secondly, somebody may want to verify regulatory.bin
> on the target system.
>
> Here's the patch:
>
[snip]

Dumb question but, why not just build a target and host version each of regdumpdb?

-Philip