I am planning to add support for menuconfig in my project. The project is not associated with Linux kernel so, I have to write everything from scratch in menuconfig and Makefile.
How do I add support for menuconfig and create Kconfig and make the makefile read the defines in .config?
Any good tutorial to begin with?
If you are interested on using KBuild/KConfig for your custom applications, you may try the following Github projects. They aim to provide an initial template for projects using KBuild/KConfig and, therefore, supporting menuconfig.
Kbuild skeleton: https://github.com/masahir0y/kbuild_skeleton
Kbuild template: https://github.com/embedded-it/kbuild-template
First you need to copy the folders and files below from linux folder 'scripts' into your own project
basic
kconfig
Kbuild.include
Makefile.build
Makefile.host
Makefile.lib
Sources in folders basic and kconfig need to be built for your processor architecture. How to do it is written in the linux Makefile. You can change some names using next variables
KCONFIG_CONFIG = .config
KCONFIG_AUTOHEADER = application/autoconf.h
KCONFIG_AUTOCONFIG = build/include/config/auto.conf
KCONFIG_TRISTATE = build/include/config/tristate.conf
The following project initially created for ARM MCUs can help you to understand kconfig
https://github.com/mcu/kconfig
I'll assume you are making a driver that is outside of the kernel directory. Information for that can be found here: https://www.kernel.org/doc/Documentation/kbuild/modules.txt.
Outside of that, if you want a userspace file to see the .config variables, you can have it depend on the kernel build, and then include autoconf.h, which is in the include/generated folder for recent versions of the kernel. Userspace does not use kbuild directly.
Related
I'm going through the u-boot source code and it has many arch and vendor's code.
Also it has the source code with pre-processor directive as "#ifdef" etc.
I want to filter/extract the code based on my u-boot configuration.
There should be some way to tell the compiler so it can copy only the source code (to a new folder) which will be the part of my executable.
If it's possible then it will be easy to go through the source code and understand the code flow.
Is there any tool or compiler option available for this?
Thanks,
Hardik
I just looked into the Yocto WORKDIR so it's having only required files
in this directory so now it would be easy to go through the code.
These are object files but based on file names I can refer the c files.
Greetings, what I'm trying to do is to port an existing Windows application to Linux using CMake with CMakeLists, which I generated with the vcproj2cmake Script (https://github.com/sixman9/vcproj2cmake).
With the CMakeLists.txt and CMake I was able to successfully port a VS 2005 project to VS 2010. Now I try to port the same VS 2005 project to Linux, so that I can edit it with KDevelope.
The project itself is small and I think it would be easier to just create a new project and copy all relevant files (if that would work), the problem is, that it's not only one project but many, hence I was looking for a way to port a project in an as simple as possible way.
In Linux I was able to create a CMakeLists.txt using the vcproj2cmake script. The next step would be creating a KDevelope project using CMake. And this is where I'm stuck.
Everytime I try to run CMake I get the following error:
CMake Error at CMakeLists.txt: 196 (set_property) :
set_property could not find TARGET Test_Project. Perhaps it has not yet been
created.
Test_Project: installing /root/Desktop/Test_Project/vs8/CMakeLists. txt rebuilder (watching /root/Desktop/Test_Project/vs8/Test_Project. vcproj)
Configuring incomplete, errors occurred!
See also “/root/Desktop/Test_Project/vs8/CMakeFiles/CMakeOutput.log”.
I searched for a solution or an approach for quite a time now, but the only results that I get are project-specific, or at least I think they are.
Content of the CMakeLists.txt from line 196:
set_property(TARGET Test_Project PROPERTY PROJECT_LABEL "Test_Project")
v2c_rebuild_on_update(Test_Project "${CMAKE_CURRENT_SOURCE_DIR}/Test_Project.vcproj" ${CMAKE_CURRENT_LIST_FILE} "vcproj2cmake.rb" ".")
include(${V2C_HOOK_POST} OPTIONAL)
Perhaps there are more efficient ways to port many projects form Windows to Linux, I'm open for any suggestion.
It is a bit difficult to help without having your project - since you are using a third party tool to convert a VC project you should ask the author of that tool. :D
If you have many projects which you are going to maintain, I suggest that you select one where you can create a cross platform (Windows/Linux) CMake config for which you can reuse for other projects.
Most of the config should be the same for all platforms you are building for - the difference should be which generator is used and what libraries to link in the final executable (if you are building one that is). The generator is specified when running cmake.
In my opinion you should try an out of source build with the following structure:
/$COMMON_DIR/CMakeLists.txt
/CMakeLists.txt
/src/
/build/
/build/vcX
/build/generate_vcX.bat
/build/linux
/build/generate_linux.sh
$COMMON_DIR should contain the CMake code you expect to be common for all you projects - like a function to create a static library for a module which searches for files in /src and another function which can be used to add an executable for certain platform.
The CMakeLists.txt in the root of your project (repository, I assume) should call the functions defined in $COMMON_DIR and possibly add some project specific defines or link flags.
I've written a Tcl script that uses the TclMagick extension together with GraphicsMagick.
For GraphicsMagick, I've both the Windows DLLs and the Linux SO files. I want to be able to make two Starkit/Starpack applications bundled with those libraries: one for Windows (with the DLLs) and one for Linux (with the SO files).
Is this reasonable? Can it be done?
EDIT
I cannot seem to use DLLs with dependencies under Windows. In my case, I want to use the TclMagick extension, but it needs the GraphicsMagick's DLLs and the starkit cannot find those. What should I do in this situation?
Yes. In the lib/tclmagick subdirectory of $starkit::topdir, you'll place the dynamic library and an appropriate pkgIndex.tcl file that loads the library. Use a Makefile or some other build script to use the correct dynamic library file, and generate the pkgIndex, depending the target platform.
The directory hierarchy:
appname.vfs/
main.tcl
lib/
app-appname/
appname.tcl
pkgIndex.tcl
tclmagick/
pkgIndex.tcl
tclMagick.so
package require tclmagick will work as you expect, for some capitalization of "tclmagick"
You can do it, but you might need some extra windows trickery to get things to work properly.
Windows has quite a few options to load dependent libraries, this page explains the basics:
http://msdn.microsoft.com/en-us/library/windows/desktop/ms682586%28v=vs.85%29.aspx
There are is one part that can help you:
If a DLL with the same module name is already loaded in memory, the system checks only for redirection and a manifest before resolving to the loaded DLL, no matter which directory it is in. The system does not search for the DLL.
So, to get the dependencies right, you could get the dependent libraries loaded into memory first (sadly you cannot use load for this, but could use something from twapi, e.g. twapi::load_libary (see http://wiki.tcl.tk/9886) to get the library loaded from some temporary location).
Sadly most OS's do not provide an easy or portable way to load a dynamic library directly from memory, so you need to copy the dependent libs to a temporary location first (you can do it with appropriate hacks or by using something like an installable filesystem on windows/FUSE on Linux).
In most cases the easiest route is to just link all dependencies statically into the extension instead.
i require to convert a linux driver to android.
can anyone help me with the kernel twiking ?
is there a change to the driver makefile ?
where to get the source files of the kernel ?
can i use insmod/mknod in adb shell to load the driver dynamically ?
any hint will be welcomed...
noam
Lots of questions...
Yes, you need to change the makefiles in the kernel. For example, if your driver source is in drivers/net, you'll need to change the Makefile there so that it builds your sources.
You will also need to add a new configuration option in the Kconfig file so that the build process knows if it needs to build your sources, if it needs to be built as a module, etc. You'll need to run 'make oldconfig' or similar to include your new option in the kernel .config.
Kernel sources are available in the same way as the Android sources (see http://source.android.com); you have to add a .repo/local_manifest.xml file such as:
<?xml version="1.0" encoding="UTF-8"?>
<manifest>
<project path="kernel" name="kernel/omap"
revision="refs/heads/android-omap-2.6.29"/>
</manifest>
And yes, if you build your driver as a module then you can use insmod/rmmod to insert/remove it from a running kernel.
HTH!
I'm trying to compile a piece of software which has the standard build process e.g.
configure
make
make install
The software requires a library e.g. libreq.so which is installed in /usr/local/lib. However, my problem is I'd like to build the software and link it with a different version of the same library (i have the source for the library as well) that I've installed in /home/user/mylibs.
My question is, how do I compile and link the software against the library in /home/user/mylibs rather than the one in /usr/local/lib
I tried setting "LD_LIBRARY_PATH" to include /home/user/mylibs but that didn't work.
Thanks!
When you have an autoconf configure script, use:
CPPFLAGS=-I/home/user/include LDFLAGS=-L/home/user/mylibs ./configure ...
This adds the nominated directory to the list of directories searched for headers (usually necessary when you're using a library), and adds the other nominated directory to the list searched for actual libraries.
I use this all the time - on my work machine, /usr/local is 'maintained' by MIS and contains obsolete code 99.9% of the time (and is NFS-mounted, read-only), so I struggle to avoid using it at all and maintain my own, more nearly current, versions of the software under /usr/gnu. It works for me.
Try using LD_PRELOAD set to your actual file.
LD_LIBRARY_PATH is for finding the dynamic link libraries at runtime. At compiling you should add -L parameters to gcc/g++ to specify in which directory the *.so files are. You also need to add the library name with -l<NAME> (where the library is libNAME.so).
Important! For linking you not only need the libNAME.so file but a libNAME.a is needed too.
When you run the application, don't forget to add the dir to the LD_LIBRARY_PATH.
When you added the /home/user/mylibs to the LD_LIBRARY_PATH did you add it to the front or end of the existing paths? The tokens are searched in-order so you will want yours to appear first in the list.
Also, many standard build environments that use configure will allow you to specify an exact library for each required piece. You will have to run ./configure --help but you should see something like --using-BLAH-lib=/path/to/your/library or similar.