0

I have a library with few source code files (.c) and header files and the output is shared library (.so).

Currently, i am using Makefile for generating .so

C    = gcc
FLAGS        = # -std=gnu99 -Iinclude
CFLAGS       = -fPIC -g #-pedantic -Wall -Wextra -ggdb3
LDFLAGS      = -shared

DEBUGFLAGS   = -O0 -D _DEBUG
RELEASEFLAGS = -O2 -D NDEBUG -combine -fwhole-program

TARGET  = libesys.so
SOURCES = $(wildcard *.c)
HEADERS = $(wildcard *.h)
OBJECTS = $(SOURCES:.c=.o)


all: $(TARGET)

$(TARGET): $(OBJECTS)
            $(CC) $(FLAGS) $(CFLAGS) $(LDFLAGS) $(DEBUGFLAGS) -o $(TARGET) $(OBJECTS)
clean:
    rm *.o libesys.so

I want to create a recipe in my meta layer to perform the above operation and generate .so when I do bitbake core-image-minimal. Can you please provide an example recipe which does similar operation.

md.jamal
  • 4,067
  • 8
  • 45
  • 108
  • I'm not aware of any (usually recipes are reusing known build systems like autotools, cmake, waf, etc). But this manual extensively describes how to write a recipe: https://www.yoctoproject.org/docs/current/dev-manual/dev-manual.html#new-recipe-writing-a-new-recipe – Kuchara Sep 25 '18 at 09:15

1 Answers1

0

First, have a look at simple recipe for a single source file from the dev-manual and try to first get a simple recipe building. You are correct in placing this recipe in your own meta layer.

Also have a look at this section that covers recipes with a Makefile.

Here is something to get you started

DESCRIPTION = "My test recipe"
LICENSE = "CLOSED"
PR = "r1"
S = "${WORKDIR}
FILES_${PN} = "libesys.so"


# Better to use a git repo for large projects
SRC_URI="file://xxxxxx \
         file://yyyyyy \
         "
do_install(){
      oe_runmake install DESTDIR=${D} INCLUDEDIR=${includedir}
      install -d ${D}${libdir}
      install -m 0644 libesys.so ${D}${libdir}
}

BBCLASSEXTEND = "native"

You will also need to modify the core-image-minimal recipe to add a depends to your recipe so that it pulls in your lib.

DEPENDS+="your_recipe_name_here"

You can add this directly into the recipe itself, or add it via a .bbappends file that can reside in your layer.

User3219
  • 88
  • 1
  • 8
  • What is the use of BBCLASSEXTEND.. Does it mean native compilation. I want libesys.so to be generated for my target board. – md.jamal Sep 27 '18 at 11:03
  • Yes, it is for native compilation. You can omit this line if you only want your library to be cross-compiled. – User3219 Sep 27 '18 at 20:30