Addvariant

You have source code, and want to build it. you need give the compiler the instructions on how to build the code: common.mk and Makefile.

An useful binary “addvariant” will help do the magic.

  • first, using the option “-i” creates the initial common.mk and Makefile in the current working directory.
  • second, add directories as you need, without supplying “-i” option.
  • Or the two steps can be combined together if you just need one level of directory.

 Example 1: addvariant -i OS/CPU/VARIANT nto arm dll.le.v7

This will:

  • Create a Makefile in the current directory, with contents:

LIST=OS CPU VARIANT

ifndef QRECURSE

QRECURSE=recurse.mk

ifdef QCONFIG

QRDIR=$(dir $(QCONFIG))

endif

endif

include $(QRDIR)$(QRECURSE)

  • create a common.mk

ifndef QCONFIG

QCONFIG=qconfig.mk

endif

include $(QCONFIG)

include $(MKFILES_ROOT)/qtargets.mk

  • Create nto-arm-dll.le.v7 directory, with Makefile in this directory says include ../common.mk”.

Example 2: addvariant -i OS

  • create a Makefile,

LIST=OS

ifndef QRECURSE

QRECURSE=recurse.mk

ifdef QCONFIG

QRDIR=$(dir $(QCONFIG))

endif

endif

include $(QRDIR)$(QRECURSE)

  • create a common.mk.
  • but no sub-directory created yet until addvariant nto arm dll.le.v7. this will create the directory nto, nto/arm, nto/arm/dll.le.v7, with Makefile inside each directory,
    • nto/Makefile: LIST= CPU;
    • nto/arm/Makefile: LIST=VARIANT;
    • nto/arm/dll.le.v7/Makefile: include ../../../common.mk
  • other directories will be added, if you do “addvariant nto x86 dll”, “addvariant nto arm dll.le.v7.hbas”, etc.
    • in the latter case, compiler will add CCFLAGS “-DVARIANT_dll –DVARIANT_le –DVARIANT_v7 -Dhbas”.
  • But “addvariant nto arm dll.le.v7.hbas adv7280m” gives an error: “too many directory levels specified”.
    • you can still add extra level of VARIANT manually, by:
      • add variant nto arm dll.le.v7.hbas first,
      • then create adv7280m folder under dll.le.v7.hbas,
      • create a makefile with “LIST=VARIANT” in dll.le.v7.hbas,
      • and put a makefile with “include ../../../../common.mk” in adv7280m folder.
      • The complier will use CCFLAGS “-DVARIANT_adv7280m -DVARIANT_dll –DVARIANT_le –DVARIANT_v7 –DVARAINT_hbas”.

note: Have a file “i2c.c”, stored in the variant directory, the compiler with choose this i2c.c to compile, instead of the one in the main directory.

More on the executable name and install path:

  • The default install directory is “lib/dll”, unless you add “INSTALLDIR=/usr/lib” in common.mk.
  • all the variant names, except dll, le, v7, etc, will be appended to the final name, by default.
    • e.g. in the last example above, the executable would be “adv728xm-adv7280m-hbas.so” (project-variant1-variant2.so)
    • If you have “NAME=$(IMAGE_PREF_SO)capture-decoder” in common.mk, you will have a library named “libcapture-decoder-adv7280m-hbas.so”
    • If you don’t like the atomatic appending, use:

DEC_VARIANTS := adv7280m adv7281m

EXTRA_SILENT_VARIANTS += $(DEC_VARIANTS)

  • You can combine variant names into a compound variant, using a period(.), dash(-) or slash(/) between the variants.
    • If you have a variant name “omap4-5”, the compiler will interpret it as “VARIANT_omap4” and “VARIANT_5”. Therefore, you have to use omap45. If you still want “omap4-5” to be a part of the library name, In common.mk,

 SOC_VARIANTS := j5 imx6 omap45

SOC_VARIANT_NAME = $(filter &(VARIANT_LIST), $(SOC_VARIANTS))

ifeq ($(SOC_VARIANT_NAME), omap45)

SOC_NAME=omap4-5

else

SOC_NAME=$(SOC_VARIANT_NAME)

Endif

 NAME=capture-$(SOC_NAME)

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s