How can I change these variables? - c

I have in my C code, which I based on GNU hello, this
printf (_("%s home page: <%s>\n"), PACKAGE_NAME, PACKAGE_URL);
Now I want to change the package variables but I can't find where they are set. Do you know where I can change them? If I serach for the variables in my project I only find auto-generated files such as config.h etc.
The variables must come from somewhere, where is it?
The way I build my project is ./configure && make && sudo make install

They come from the configure script:
# Identity of this package.
PACKAGE_NAME='GNU Hello'
PACKAGE_TARNAME='hello'
PACKAGE_VERSION='2.7'
PACKAGE_STRING='GNU Hello 2.7'
PACKAGE_BUGREPORT='bug-hello#gnu.org'
PACKAGE_URL='http://www.gnu.org/software/hello/'
Makefile.in contains:
PACKAGE_NAME = #PACKAGE_NAME#
PACKAGE_STRING = #PACKAGE_STRING#
PACKAGE_TARNAME = #PACKAGE_TARNAME#
PACKAGE_URL = #PACKAGE_URL#
PACKAGE_VERSION = #PACKAGE_VERSION#
and there's presumably something in the configure script that replaces all the #VARNAME# placeholders with the values of the variables.
I found these with:
grep -R PACKAGE_NAME .
while in the hello-2.7 directory.

Related

Custom u-boot environment variables using buildroot

How do you add a new set of custom environment variables to u-boot using buildroot as the os build system?
I attempted to patch the include/configs/rpi.h using an external tree patch to add a new variable but kconfig got grumpy (patch shown after complaining):
The following new ad-hoc CONFIG options were detected:
CONFIG_XXXXXX_ENV_SETTINGS
Please add these via Kconfig instead. Find a suitable Kconfig
file and add a 'config' or 'menuconfig' option.
Makefile:871: recipe for target 'all' failed
--- a/include/configs/rpi.h 2018-03-13 12:02:19.000000000 +0000
+++ b/include/configs/rpi.h 2018-11-19 12:32:15.728000000 +0000
## -140,0 +141,7 ##
+#define CONFIG_XXXXXX_ENV_SETTINGS \
+ "newboard=true" \
+ "hasFailedBoot=false" \
+ "hasFailedBootCount=0" \
+ "maximumFailedBootCount=3"
+
+
## -145 +152,2 ##
- BOOTENV
+ BOOTENV \
+ CONFIG_XXXXXX_ENV_SETTINGS
I can use uboot-menuconfig to set up u-boot specific stuff but am not sure how to create environment variables
You can set CONFIG_USE_DEFAULT_ENV_FILE in uboot-menuconfig and point that to a file that contains the complete default environment.
Since you use Buildroot, don't forget to save the modified U-Boot configuration by changing its location (Buildroot option BR2_TARGET_UBOOT_CUSTOM_CONFIG_FILE) and running make uboot-update-defconfig.

How to compile a basic c file in yocto

I am working on yocto, I want to compile some C files in yocto and install the resulting binary to external filesystem.
Before doing that I tried creating a separate reciepe and compile c code from it.
I am unable to compile it.
I am not sure to understand the question since it is not precise enough.
Including C files in recipe tree
If you want to have the C files in your recipe, having a file tree like this:
recipe-example/example/example_0.1.bb
recipe-example/example/example-0.1/helloworld.c
You can generate this example when you create a new layer using
yocto-layer <your-layer-name>
Your bb file will look like this:
#
# This file was derived from the 'Hello World!' example recipe in the
# Yocto Project Development Manual.
#
SUMMARY = "Simple helloworld application"
SECTION = "examples"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
SRC_URI = "file://helloworld.c"
S = "${WORKDIR}"
do_compile() {
${CC} helloworld.c -o helloworld
}
do_install() {
install -d ${D}${bindir}
install -m 0755 helloworld ${D}${bindir}
}
It will compile the hello world file and install it into /usr/bin on your image.
From a Git repo
You also can compile from a git repository, I advise you to read the manual and examples in your yocto folder. Here is an example here of wiringPi:
DESCRIPTION = "A library to control Raspberry Pi GPIO channels"
HOMEPAGE = "https://projects.drogon.net/raspberry-pi/wiringpi/"
SECTION = "devel/libs"
LICENSE = "LGPLv3+"
LIC_FILES_CHKSUM = "file://COPYING.LESSER;md5=e6a600fd5e1d9cbde2d983680233ad02"
# tag 2.29
SRCREV = "d79506694d7ba1c3da865d095238289d6175057d"
S = "${WORKDIR}/git"
SRC_URI = "git://git.drogon.net/wiringPi \
file://0001-Add-initial-cross-compile-support.patch \
file://0001-include-asm-ioctl.h-directly-for-_IOC_SIZEBITS.patch \
"
COMPATIBLE_MACHINE = "raspberrypi"
CFLAGS_prepend = "-I${S}/wiringPi -I${S}/devLib"
EXTRA_OEMAKE += "'INCLUDE_DIR=${D}${includedir}' 'LIB_DIR=${D}${libdir}'"
EXTRA_OEMAKE += "'DESTDIR=${D}/usr' 'PREFIX=""'"
do_compile() {
oe_runmake -C devLib
oe_runmake -C wiringPi
oe_runmake -C gpio 'LDFLAGS=${LDFLAGS} -L${S}/wiringPi -L${S}/devLib'
}
do_install() {
oe_runmake -C devLib install
oe_runmake -C wiringPi install
oe_runmake -C gpio install
}
It is fetching from a git repository, applying patches generated by git, using oe_runmake to compile with the makefiles.
With devtool
It has been asked in a comment on how to add a recipe with devtool.
We will still use wiringPi as an example again. Download it doing
https://github.com/WiringPi/WiringPi
The Makefile is is the folder wiringPi.
You can then do
devtool add <name_of_recipe> <path_to_Makefile_folder>
Take care of the warning from devtool
NOTE: Creating workspace layer in /home/dbensoussan/new_poky/poky/build/workspace
NOTE: Enabling workspace layer in bblayers.conf
NOTE: Using source tree as build directory since that would be the default for this recipe
NOTE: Recipe /home/dbensoussan/new_poky/poky/build/workspace/recipes/project/project.bb has been automatically created; further editing may be required to make it fully functional
This is generating the recipe as follow:
# Recipe created by recipetool
# This is the basis of a recipe and may need further editing in order to be fully functional.
# (Feel free to remove these comments when editing.)
#
# WARNING: the following LICENSE and LIC_FILES_CHKSUM values are best guesses - it is
# your responsibility to verify that the values are complete and correct.
LICENSE = "Unknown"
LIC_FILES_CHKSUM = "file://COPYING.LESSER;md5=e6a600fd5e1d9cbde2d983680233ad02"
# No information for SRC_URI yet (only an external source tree was specified)
SRC_URI = ""
# NOTE: this is a Makefile-only piece of software, so we cannot generate much of the
# recipe automatically - you will need to examine the Makefile yourself and ensure
# that the appropriate arguments are passed in.
do_configure () {
# Specify any needed configure commands here
:
}
do_compile () {
# You will almost certainly need to add additional arguments here
oe_runmake
}
do_install () {
# This is a guess; additional arguments may be required
oe_runmake install 'DESTDIR=${D}'
}
You can then edit your recipe to suit your configuration
With externalsrc
It is possible to use a directory present on the filesystem by using externalsrc.
I did not try it myself, nor have I the workspace ready to do, but #71GA in the comment tested the tutorial from the Koan software company https://wiki.koansoftware.com/index.php/Building_Software_from_an_External_Source and it worked. I will copy the content here:
in this case use the externalsrc class - you can inherit this in the original bb recipe or a bbappend:
inherit externalsrc
EXTERNALSRC = "/path/to/sources"
Depending on the type of build (eg, 'inherit module' for out of tree Linux kernel modules) you may or may not need to set EXTERNALSRC_BUILD.
inherit externalsrc
EXTERNALSRC = "/some/path"
EXTERNALSRC_BUILD = "/some/path"
If you're going to use it across a number of recipes you can inherit it globally at the configuration level (perhaps via an inc file that you include/require there):
INHERIT += "externalsrc"
EXTERNALSRC_pn-<recipename> = "/path/to/sources"
Recipe example using an external source for nInvaders package
#
# Recipe example with externalsrc
#
# (C)2019 Marco Cavallini - KOAN - <https://koansoftware.com>
#
LICENSE = "CLOSED"
LIC_FILES_CHKSUM = ""
inherit externalsrc
EXTERNALSRC = "/home/koan/yocto-qemuarm-sumo/ninvaders-0.1.1"
EXTERNALSRC_BUILD = "${EXTERNALSRC}"
DEPENDS = "ncurses"
EXTRA_OEMAKE = "-e"
do_install() {
install -d ${D}${bindir}
install -m 0755 nInvaders ${D}${bindir}
}
FILES_${PN} = "${bindir}/*"
You can just go to the official documentation to find your answer.
In the chapter 7.3 Writting a New Recipe of the yocto mega-manual, the very first example is exactly is what you need (Single .c File Package (Hello World!)).

How to use Axis2c to generate C files from WSDL file

I want to use a webservice in C code. I am trying to make a client. I need something to do what Axis2java does and generates the classes from a wsdl files.
I found that Axis2c makes (.c) files generated from wsdl file.
I downloaded it from here . unzipped it. I created the environment variable for AXIS2C_HOME and I created AXIS2C_CLASSPATH.
but I can't make it work.
when I type this command :
WSDL2C -uri -ss -sd -d none -u -f -o
I get this error :
echo off
Error: Could not find or load main class org.apache.axis2.wsdl.WSDL2C
how can I solve this problem. and please tell me how to use this Axis2c tool properly.
Thank you in advance.
#loentar : I installed Axis2/Java and I set the environment variable for it. now I run the wsdl2c.bat I get this :
E:\dev\Tools\axis2c-bin-1.6.0-win32\bin\tools\wsdl2c>WSDL2C.bat
E:\dev\Tools\axis2c-bin-1.6.0-win32\bin\tools\wsdl2c>echo off
Usage: java [-options] class [args...]
(to execute a class)
or java [-options] -jar jarfile [args...]
(to execute a jar file)
where options include:
-d32 use a 32-bit data model if available
-d64 use a 64-bit data model if available
-server to select the "server" VM
The default VM is server.
-cp
-classpath
A ; separated list of directories, JAR archives,
and ZIP archives to search for class files.
-D=
set a system property
-verbose:[class|gc|jni]
enable verbose output
-version print product version and exit
-version:
require the specified version to run
-showversion print product version and continue
-jre-restrict-search | -no-jre-restrict-search
include/exclude user private JREs in the version search
-? -help print this help message
-X print help on non-standard options
-ea[:...|:]
-enableassertions[:...|:]
enable assertions with specified granularity
-da[:...|:]
-disableassertions[:...|:]
disable assertions with specified granularity
-esa | -enablesystemassertions
enable system assertions
-dsa | -disablesystemassertions
disable system assertions
-agentlib:[=]
load native agent library , e.g. -agentlib:hprof
see also, -agentlib:jdwp=help and -agentlib:hprof=help
-agentpath:[=]
load native agent library by full pathname
-javaagent:[=]
load Java programming language agent, see java.lang.instrument
-splash:
show splash screen with specified image
See http://www.oracle.com/technetwork/java/javase/documentation/index.html for m
ore details.
after that I run this command :
E:\dev\Tools\axis2c-bin-1.6.0-win32\bin\tools\wsdl2c>WSDL2C.bat -uri hello.wsdl
-u -uw
E:\dev\Tools\axis2c-bin-1.6.0-win32\bin\tools\wsdl2c>echo off
Unrecognized option: -uri
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
what can I do ?
I'm using windows 8 by the way.
In addition to Axis2/C you must have Axis2/Java installed.
AXIS2_HOME must point to Axis2/Java installation.
For details please see README of codegen.
The complete list of commands to create and compile client is:
# create stubs
sh $AXIS2C_HOME/bin/tools/wsdl2c/WSDL2C.sh -uri Calculator.wsdl -u -uw
# implement main() in src/your_client.c
# see samples/codegen/client/calculator for example
# compile and link client
gcc -o calculator_client src/*.c -I$AXIS2C_HOME/include/axis2-1.6.0 -L$AXIS2C_HOME/lib -laxutil -laxis2_axiom -laxis2_parser -laxis2_engine -lpthread -laxis2_http_sender -laxis2_http_receiver -ldl -Wl,--rpath -Wl,$AXIS2C_HOME/lib
I set the envinroment variable for JAVA_HOME, AXIS2_HOME, AXIS2C_HOME, and added their lib folder to CLASSPATH. after running this command:
WSDL2C.bat -uri hello.wsdl -u -uw
I got this message:
echo off
Error: Could not find or load main class org.apache.axis2.wsdl.WSDL2C
I found the solution myself. :)
I double checked if I had created the environment variable for AXIS2_HOME and I saw that it is there, correctly.
in spite of it's existence I tried to set it again in command prompt. so I typed:
SET AXIS2_HOME=E:\dev\Tools\axis2-1.6.2
then I typed the command for WSDL2C code generator:
WSDL2C.bat -uri hello.wsdl -u -uw
And BAM ! it worked properly.
Now I can generate C files from WSDL file.

How do I see changes made to a kernel module?

I have a module running on my Linux machine and can see it using lsmod command. Now I made some changes (added some printk) to this module, recompiled it and got the .ko.
Now I did rmmod to remove this module (some other modules also which are using this module), did insmod xxx.ko and rebooted the system.
Now where do I see the statements added using printk? I tried to see using
dmesg grep | "SPI RW"
But I couldn't find anything. What am I doing wrong here?
Try vim /var/log/messages or open messages in a text editor to verify.
For enabling /var/log/messages, edit file /etc/rsyslog.d/50-default.conf
Change the following paragraph:
...
#
# Some "catch-all" log files.
#
#*.=debug;\
# auth,authpriv.none;\
# news.none;mail.none -/var/log/debug
#*.=info;*.=notice;*.=warn;\
# auth,authpriv.none;\
# cron,daemon.none;\
# mail,news.none -/var/log/messages
....
to the following:
...
#
# Some "catch-all" log files.
#
*.=debug;\
auth,authpriv.none;\
news.none;mail.none -/var/log/debug
*.=info;*.=notice;*.=warn;\
auth,authpriv.none;\
cron,daemon.none;\
mail,news.none -/var/log/messages
...
and do restart rsyslog.

ELDK gcc linker error in ld.so.1

I have ELDK-3.1 installed in a Ubuntu box working perfectly.
In another machine, running 64 bits OpenSuse 12.1, I cloned the ELDK installation and, for some time it worked very well.
Now when I try to configure my projects I see:
configure: error: C compiler cannot create executables
See `config.log' for more details
And the log shows:
configure:3411: ppc-linux-gcc conftest.c >&5
/opt/ELDK-3.1/usr/bin/../lib/gcc-lib/ppc-linux/3.3.3/../../../../ppc-linux/bin/ld: warning: ld.so.1, needed by /opt/ELDK-3.1//usr/../ppc_8xx/lib/libc.so.6, not found (try using -rpath or -rpath-link)
/opt/ELDK-3.1//usr/../ppc_8xx/lib/libc.so.6: undefined reference to `_dl_lookup_versioned_symbol_skip#GLIBC_PRIVATE'
...
The file ld.so.1 is in the same directory as libc.so.6.
s -l /opt/ELDK-3.1//usr/../ppc_8xx/lib/ld.so.1
lrwxrwxrwx 1 root root 11 Jan 31 11:43 /opt/ELDK-3.1//usr/../ppc_8xx/lib/ld.so.1 -> ld-2.3.1.so
As far as I can see, I am correctly defining all the needed environment and trying to build using exactly the same build system as in the Ubuntu box (the project is "automaked").
So I wrote a script trying to mimic everything my automaked configure does:
#!/bin/bash
if [ ! -f confdefs.c ]; then
cat > confdefs.c << EOF
/* confdefs.h */
#define PACKAGE_NAME "xyz"
#define PACKAGE_TARNAME "xyz"
#define PACKAGE_VERSION "1.00"
#define PACKAGE_STRING "xyz 1.00"
#define PACKAGE_BUGREPORT "<contact#company>"
#define PACKAGE_URL ""
#define PACKAGE "xyz"
#define VERSION "1.00"
/* end confdefs.h. */
int
main ()
{
;
return 0;
}
EOF
fi
ARCH=powerpc
export CROSS_COMPILE=ppc_8xx
TOOLCHAIN=ppc-linux-
TOOLCHAIN_ROOT=/opt/ELDK
LD=`which ${TOOLCHAIN}ld`
CC=`which ${TOOLCHAIN}gcc`
GCC=$CC
export CFLAGS="-Wall -g -I${TOOLCHAIN_ROOT}/ppc_8xx/usr/include/"
export CPPFLAGS=$CFLAGS
# export LDFLAGS="-shared"
$CC $CFLAGS $LDFLAGS confdefs.c -o confdefs
This gives me exactly the same error as configure.
If I uncomment the line export LDFLAGS="-shared", on the other hand, it builds perfectly!.
> ls -l confdefs
-rwxr-xr-x 1 myself users 16136 Fev 1 09:52 confdefs
> file confdefs
confdefs: ELF 32-bit MSB shared object, PowerPC or cisco 4500, version 1 (SYSV), dynamically linked, not stripped
Could anybody here please give me any clue of what I am missing so that my projects work finely on one box and not in the other?
Thanks!
I'm not 100% sure that it solves all problems, but it works for us.
We discovered that symlink "ld.so.1 -> ../../../ppc_8xx/lib/ld.so.1" to eldk-3.1/usr/ppc-linux/lib solves linking error.
I suspect something changed with environment between F15 and F16. Same for OpenSUSE (11->12).
Also bug was submitted against Fedora https://bugzilla.redhat.com/show_bug.cgi?id=754695 which was terminated as intentional ABI changes.

Resources