Copy scripts in MPC (Makefile, Project, and Workspace Creator) - makefile

In maintaining a project built with MPC (Makefile, Project, and Workspace Creator), I'd like to add a recipe to simply copy some scripts from one location to another.
If I were writing the makefile directly it would be easy: just add another line to the appropriate recipe. But I don't know how to do it with MPC.
I've tried variations of this code, but it creates a skeleton makefile which does nothing.
project(jsonscripts) : ecp {
Define_Custom(PHP) {
command = cp <%input%> scripts/
}
PHP_Files {
*.php
}
Source_Files {
}
}
Deleting the Source_Files or putting the php files into Source_Files creates a Makefile which tries to compile
the *.php files with gcc.
Any suggestions?

I could find no way to elegantly make it work. In the end, I added a postbuild command like this:
project(json) : ecp {
sharedname = someLibname
libpaths += $(LIBDIR)
libs += alib blib
Source_Files {
aa.cpp
bb.cpp
cc.cpp
}
postbuild = \
mkdir -p $(PROJHOME)/bin/util ; \
cp -v scriptA.php scriptB.php $(BIN)/util/ ; \
echo Scripts Copied to $(BIN)/util
}

Related

Where's the location of the app/binary defined in a yocto recipe?

I have a following recipe which runs a said service which in turns runs an app on boot-up, but I am trying to understand where the location of the app defined which ends up in sysfs image.
Currently, the appSource binary (defined in Makefile) gets stored in /usr/bin but I'm not sure where the destination location (/usr/bin) is defined.
The following command results in
$ bitbake -e appSource | grep ^FILES_${PN}
FILES_appSource="/usr/bin/* /usr/sbin/* /usr/libexec/* /usr/lib/lib*.so.* /etc /com /var /bin/* /sbin/* /lib/*.so.* /lib/udev /usr/lib/udev /lib/udev /usr/lib/udev
Here's the recipe
inherit autotools-brokensep pkgconfig
DESCRIPTION = "A sample recipe"
LICENSE = "CLOSED"
DEPENDS = "glib-2.0"
FILESPATH =+ "${THISDIR}:"
SRC_URI = "file://appSource"
S = "${WORKDIR}/appSource""
FILES_${PN} += "${systemd_unitdir}/*"
INIT_MANAGER = "systemd"
do_install_append() {
if ${#bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then
install -d ${D}/etc/initscripts
install -d ${D}${systemd_unitdir}/system
install -m 0644 ${WORKDIR}/appService/appService.service ${D}${systemd_unitdir}/system/appService.service
install -d ${D}${systemd_unitdir}/system/multi-user.target.wants/
ln -sf ${systemd_unitdir}/system/appService.service ${D}${systemd_unitdir}/system/multi-user.target.wants/appService.service
fi
}
Here is what I find out:
You are inheriting autotools-brokensep which has the following content:
# Autotools class for recipes where separate build dir doesn't work
# Ideally we should fix software so it does work. Standard autotools supports
# this.
inherit autotools
B = "${S}"
So, it inherit autotools which has do_install with the content of:
autotools_do_install() {
oe_runmake 'DESTDIR=${D}' install
# Info dir listing isn't interesting at this point so remove it if it exists.
if [ -e "${D}${infodir}/dir" ]; then
rm -f ${D}${infodir}/dir
fi
}
So, it runs the install target of your Makefile into ${D} which is ${WORKDIR}/image.
So, I assume that your Makefile has an install target that copies the binary into /usr/bin.
For the FILES variable content, this is defined in bitbake.conf:
FILES_${PN} = "${bindir}/* ${sbindir}/* ${libexecdir}/* ${libdir}/lib*${SOLIBS} \ ...
Provide your Makefile to confirm my assumption, or I do a further research on the topic.

make: *** No rule to make target '.obj', needed by '.exe'. Stop

I want to recompile an old Fortran 77 code (having a lot of subroutines) via gfortran in MingW bash platform in windows 10. There is a makefile among the old code files which is attached here:
Version = 2.10
FOR = df
FFLAGS = /optimize:5
INSTALL = move
DELETE = del
COPY = copy
# these libraries must already exist somewhere
# where ld can find them
LIBS = \rfem\lib\GAF77.lib \rfem\lib\VFEM.lib DFPORT.lib
# where the final program is to be placed
BINDIR = \rfem\bin
# where the cat man pages are to go
CATDIR = \rfem\doc
# here are the files needed to construct Rslope2D
FILES = mrslope2d.f \
chknxe.f dismsh.f echosd.f fem2det.f fem2rf.f \
fem2sd.f feminit.f mesh.f openin.f opensd.f \
pltfld.f readsd.f rect.f setsd2.f sim2sd.f \
statsd.f szchk.f vecmsh.f
OBJS = mrslope2d.obj \
chknxe.obj dismsh.obj echosd.obj fem2det.obj fem2rf.obj \
fem2sd.obj feminit.obj mesh.obj openin.obj opensd.obj \
pltfld.obj readsd.obj rect.obj setsd2.obj sim2sd.obj \
statsd.obj szchk.obj vecmsh.obj
rslope2d.exe: $(OBJS)
link /out:rslope2d.exe $(OBJS) $(LIBS)
$(DELETE) $(BINDIR)\rslope2d.exe
$(INSTALL) rslope2d.exe $(BINDIR)
$(COPY) rslope2d.1 $(CATDIR)
clean:
$(DELETE) *.obj
After navigating to the directory where this makefile is located and typing make in the MingW window (to recompile the main code),
I encounter the following error:
No rule to make target 'mrslope2d.obj', needed by 'rslope2d.exe'. Stop.
I am a beginner in Fortran, so apologies if the question is simple.
Looking forward to your suggestions and guidance as I do not know how to resolve this.
Thanks

How to build Go + C code in Yocto, fetching the source code from files in the recipe

I'm having issues building Go + C code inside of Yocto.
I'm using Yocto gatesgarth, and the only way I can get it to work is by following the examples where they use git.
I do not want to use git for the fetching, just copy the files and build them. This is to allow me to try out changes, and also avoid dealing with source control revision.
How would you go about doing that?
Thanks!
Edit: I posted a solution bellow, I hope this will be useful.
I could not get it to work without overloading do_compile() and do_install(), but here it is.
DESCRIPTION = "The application code"
LICENSE = "CLOSED"
LIC_FILES_CHKSUM=""
SRC_URI = "file://build/streamerapp.go file://build/gstreamer_pipelines.c file://build/gstreamer_pipelines.h"
GO_IMPORT = "streamerapp"
GO_LINKSHARED = ""
PTEST_ENABLED="0"
export GO111MODULE="auto"
CGO_ENABLED = "1"
inherit go
do_compile() {
cd ${WORKDIR}/build
export TMPDIR="${GOTMPDIR}"
${GO} build ${GO_LINKSHARED} ${GOBUILDFLAGS} -o streamerapp
cd ${OLDPWD}
}
do_install() {
cd ${WORKDIR}/build
#install -m <permisions> SRC DEST
mkdir -p ${D}${bindir}
install -m 0755 ./streamerapp ${D}${bindir}
cd ${OLDPWD}
}

Yocto recipe : how to install in specific folder

I have created a Yocto recipe for my program.
What are the default folders that are building image from recipe ?
At the time of building image, I want to move my files to another folder like "/opt/xyz".
Should I simply do "mv" or is there any other options?
I guess you want to copy your compiled program to a folder such as ${bindir}:
Quote from Yocto ref-manual 1.1:
When specifying paths as part of the CONFFILES variable, it is good practice to use appropriate path variables. For example, ${sysconfdir} rather than /etc or ${bindir} rather than /usr/bin. You can find a list of these variables at the top of the meta/conf/bitbake.conf file in the Source Directory.
You can copy files from your working directory to any directory in the target filesystem. See the hello-world example for instance (note that the example is taken from the 1.1 reference manual, but I haven't found it yet in the newer version):
DESCRIPTION = "Simple helloworld application"
SECTION = "examples"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
PR = "r0"
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}
}
FILES_${PN} = "${bindir}"
In this example, the helloworld binary would be copied to /usr/bin on your image (could be /opt too, see Source Directory for the variable definition).
Adjust FILES_${PN} var for ${sysconfdir} ${bindir} ${datadir} ${libdir} directories.
do_install(){
install -d ${D}{base_prefix}/opt/xyz/
install -m ${WORKDIR}/yourbinary ${D}${base_prefix}/opt/xyz/
}
FILES_${PN} = "${base_prefix}/opt/*"
above
1st line creates the dir in imagedir in that opt/xvz/
2nd line copy your binary to opt/xyz/dir
3rd line use to copy of your opt/xyz/binary to yocto rootfs.

Scons: run a make command as a dependency for a target

I have a library that needs to by built as a dependency for my target. The library is distributed with a Makefile and there's nothing special needed to build it other than to run:
make my_target
How would I run this command as part of my SConstruct file if my file looks something like:
env = Environment()
flags = env.ParseFlags( CCFLAGS + LDFLAGS )
env.MergeFlags( flags )
env.Program( target = 'my_prog', source = SRC )
Create a Command builder with the name of the library as the target:
env.Command("other/lib/libother.a", "", "cd other && make my_target")
Be sure to add this library to your Program line:
env.Program(target="my_prog", source=SRC, LIBS=["other/lib/libother.a"])

Resources