Makefile with flags

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • amitbern
    New Member
    • Oct 2006
    • 6

    Makefile with flags

    Hi,
    Small question regarding makefiles:
    I want to add a new target: release
    that will compile my driver with additional flag
    (EXTRA_CFLAGS += -Drelease_flag)

    how can i do that on this example:


    KERNELPATH := /home/kernel-2.6.24/

    .PHONY: all clean
    EXTRA_CFLAGS += -Werror
    EXTRA_CFLAGS += -I$(src)/dir1
    EXTRA_CFLAGS += -I$(src)/dir2

    all: modules
    obj-m := driver.o
    driver-objs := file1.o
    driver-objs += file2.o

    modules:
    make -C $(KERNELPATH) M=$(PWD) modules

    clean:
    make -C $(KERNELPATH) M=$(PWD) clean

    thanks
  • ashitpro
    Recognized Expert Contributor
    • Aug 2007
    • 542

    #2
    Originally posted by amitbern
    Hi,
    Small question regarding makefiles:
    I want to add a new target: release
    that will compile my driver with additional flag
    (EXTRA_CFLAGS += -Drelease_flag)

    how can i do that on this example:


    KERNELPATH := /home/kernel-2.6.24/

    .PHONY: all clean
    EXTRA_CFLAGS += -Werror
    EXTRA_CFLAGS += -I$(src)/dir1
    EXTRA_CFLAGS += -I$(src)/dir2

    all: modules
    obj-m := driver.o
    driver-objs := file1.o
    driver-objs += file2.o

    modules:
    make -C $(KERNELPATH) M=$(PWD) modules

    clean:
    make -C $(KERNELPATH) M=$(PWD) clean

    thanks
    Can't you do something like this:

    release:
    make -C $(KERNELPATH) M=$(PWD) -Drelease_flag modules

    Regards,
    Ash

    Comment

    • amitbern
      New Member
      • Oct 2006
      • 6

      #3
      tried.. not working.. :(

      Comment

      • ashitpro
        Recognized Expert Contributor
        • Aug 2007
        • 542

        #4
        Originally posted by amitbern
        tried.. not working.. :(
        What error does it gives?
        First of all make sure whether that "make" (after release) is valid.
        You can put "echo" statements inside release, so that you can debug the make file..

        Regards,
        Ash

        Comment

        Working...