kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
From: Tomek The Messenger <tomekthemessenger@gmail.com>
To: kernelnewbies <kernelnewbies@kernelnewbies.org>
Subject: Re: How to pass flag from makefile to preprocesor when building external kernel module
Date: Fri, 21 Aug 2020 10:39:28 +0200	[thread overview]
Message-ID: <CAA4NGyt85cdJf_9wLKOYEMpW7GM8ZkndvX9MiF=0Jn6QEYH_LQ@mail.gmail.com> (raw)
In-Reply-To: <CAA4NGyuL_Hm41YOpojrQUnWUP-n0JpHHxRKfjGsoNx3mYn1gVQ@mail.gmail.com>


[-- Attachment #1.1: Type: text/plain, Size: 1128 bytes --]

OK, problem solved. The issue was that preprocesor directive in c: #elseif
doesn't work. I don't know why but I replaced this with #ifdef ... #endif
and #ifdef ... #endif instead of using #elseif in the middle and
everything works.

On Fri, Aug 21, 2020 at 10:01 AM Tomek The Messenger <
tomekthemessenger@gmail.com> wrote:

> Hi
> I have problem with passing flag from makefile to .c file.
> During building external kernel module my macro isn't seen by compiler. I
> used plenty of ways.
>
> First way:
> ccflags-y += -DMY_FLAG
> $(MAKE) -C $(KERNEL_SRC) M=$(SRC)
> Second:
> $(MAKE) -C $(KERNEL_SRC) M=$(SRC) CFLAGS_my-kernel-module.o="-DMY_FLAG"
> Third:
> $(MAKE) -C $(KERNEL_SRC) M=$(SRC) CFLAGS="-DMY_FLAG"
> Forth:
>  $(MAKE) -C $(KERNEL_SRC) M=$(SRC) ccflags-y="-DMY_FLAG"
>
> In general I use bitbake to build external kernel modules.  And I wonder
> if bitbake doesn't introduce issue as some of above solution really should
> work. And additionally I had to use absolute paths in headers because
> relative didn't work so -I append also doesn't work:
> SRC := $(shell pwd)
> ccflags-y := -I$(SRC)
>
> BR
> Tomek
>
>

[-- Attachment #1.2: Type: text/html, Size: 1699 bytes --]

[-- Attachment #2: Type: text/plain, Size: 170 bytes --]

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

      reply	other threads:[~2020-08-21  8:41 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-21  8:01 How to pass flag from makefile to preprocesor when building external kernel module Tomek The Messenger
2020-08-21  8:39 ` Tomek The Messenger [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAA4NGyt85cdJf_9wLKOYEMpW7GM8ZkndvX9MiF=0Jn6QEYH_LQ@mail.gmail.com' \
    --to=tomekthemessenger@gmail.com \
    --cc=kernelnewbies@kernelnewbies.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).