Skip to content

Commit

Permalink
Docs: add how to add static library
Browse files Browse the repository at this point in the history
When we want to include static (built) library, there are two methods.
This document shows them.
  • Loading branch information
sunghan-chang committed Nov 9, 2017
1 parent 82f6edf commit 0f1e723
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 1 deletion.
55 changes: 55 additions & 0 deletions docs/HowToAddStaticLibrary.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# How to add Static Library

There are two methods to include static library, [adding it into arch library](#adding-it-into-arch-library) and [adding it as a new library](#adding-it-as-a-new-library).

## Adding it into arch library

Makefile or Make.defs in arch can include it for architecture specific library as mentioned below.
Libarch.a includes new static library inside.
```
VPATH += <LIB_PATH>
EXTRA_LIBS += <LIB_PATH>/<LIB_NAME>.a
```
The *LIB_PATH* should be a relative path from *os/arch/arm/src*.

For example,
```
VPATH += chip/abc
EXTRA_LIBS += chip/abc/libnew.a
```

This change makes it add to Tizen RT binary by Makefile which is at *os/arch/arm/src* folder.
```
$(BIN_DIR)/tinyara$(EXEEXT): $(HEAD_OBJ) board/libboard$(LIBEXT)
$(Q) echo "LD: tinyara"
$(Q) $(LD) --entry=__start $(LDFLAGS) $(LIBPATHS) $(EXTRA_LIBPATHS) \
-o $(TINYARA) $(HEAD_OBJ) $(EXTRA_OBJS) \
--start-group $(LDLIBS) $(EXTRA_LIBS) $(LIBGCC) --end-group -Map $(TOPDIR)/../build/output/bin/tinyara.map
```

## Adding it as a new library

Tizen RT includes it as separated library, not merge it to existed library.

1. Add it in *Libtargets.mk*.
```
$(LIBRARIES_DIR)$(DELIM)<LIB_NAME>$(LIBEXT): <LIB_PATH>$(DELIM)<LIB_NAME>$(LIBEXT)
$(Q) install <LIB_PATH>$(DELIM)<LIB_NAME>$(LIBEXT) $(LIBRARIES_DIR)$(DELIM)<LIB_NAME>$(LIBEXT)
```
2. Add it in *FlatLibs.mk*, *ProtectedLibs.mk* and *KernelLibs.mk*.
For kernel library,
```
TINYARALIBS += $(LIBRARIES_DIR)$(DELIM)<LIB_NAME>$(LIBEXT)
```
For user library,
```
USERLIBS += $(LIBRARIES_DIR)$(DELIM)<LIB_NAME>$(LIBEXT)
```
In flat build, there is no difference between TINYARALIBS and USERLIBS.
But in protected build and kernel build, Tizen RT splits kernel space and user space. So, new static library should be included at appropriate space.
The *LIB_PATH* should be a relative path from *os*.
2 changes: 1 addition & 1 deletion docs/Porting_Guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Don't call architecture codes from application directly. When protected build en
## Kernel & System
1. [How to add new board](HowToAddnewBoard.md)
2. How to use peripheral (will be updated)
3. How to add static library (will be updated)
3. [How to add static library](HowToAddStaticLibrary.md)

## File System
Will be updated
Expand Down

0 comments on commit 0f1e723

Please sign in to comment.