Partial compilation of openwrt project - build-process

I would like to get an idea or reference to compile only subset on the openwrt project.
i am aware of the menuconfig utility but this is not enough for my goal.
i would like to compile only the tool-chain (binutils + gcc + glibc) for a specific target (ar71xx) and also the kernel.
now, after looking in the makefiles etc, i have noticed that most of the work in actually patching the toolchain and the kernel and then compile it. is there any option to stop build process after the patching so i can have only the source code patched and i can write my own make file to compile it?

To prepare (patch) toolchain independently:
make toolchain/{clean,prepare} V=99

To extract the kernel source and patch it:
make target/linux/{clean,prepare} V=99
The patched kernel source will be in build_dir/linux-$(target)/linux-$(version)

Related

Compiling SQLite RTREE in MSVC?

I need to compile the rtree extension for SQLite from source code. The readme includes these instructions:
The easiest way to compile and use the RTREE extension is to build
and use it as a dynamically loadable SQLite extension. To do this
using gcc on *nix:
gcc -shared rtree.c -o libSqliteRtree.so
You may need to add "-I" flags so that gcc can find sqlite3ext.h
and sqlite3.h. The resulting shared lib, libSqliteRtree.so, may be
loaded into sqlite in the same way as any other dynamicly loadable
extension.
Problem I'm having is that I'm on Windows, not Linux, and so need to use MSVC. I tried:
cl rtree.c -link -out:libSqliteRtree.so
This gave cannot open include file errors until I found the various .h files it was complaining about and moved them into the same directory. Now, however, it's gotten to:
/out:rtree.exe
-out:libSqliteRtree.so
rtree.obj
Creating library libSqliteRtree.lib and object libSqliteRtree.exp
LINK : fatal error LNK1561: entry point must be defined
I admit I have pretty much zero clue what I'm doing in a compiler, and I'm not sure where to go from here to resolve its problem. Am I "translating" the compiler flags correctly from GCC to MSVC? What else can I tweak to try to get the SQLite extension out of the source code? Should I beg a favor from a developer on ateam with a Linux server and ask them to do it for me?
Thanks to Shawn for commenting to look at the SQLite Run-Time Loadable Extensions documentation, which had more information in it:
To compile on Windows using MSVC, a command similar to the following will usually work:
cl YourCode.c -link -dll -out:YourCode.dll
So for my situation: cl rtree.c -link -dll -out:libSqliteRtree.dll worked.

Compiling C++ code for R (CRAN) packages on Solaris

I am a little bit confused on how to efficiently prepare the R package, so that it will be compatible across all needed system platforms. This is needed so that the new version of package will be accepted by CRAN. The main difficulty comes from compiling external C++ shared library, and optionally CUDA version if the compiler is available. To support this flow I've created specific Makefile, unfortunately using GNU-extensions. It works fine on Linux, OSX and when executed manually via gmake on Solaris. Relevant part is here:
# Checking whether nvcc compiler is available
NVCC_TEST = $(shell basename $(shell which nvcc 2> /dev/null)"")
ifeq ($(NVCC_TEST),nvcc)
ALL_LIBS += libcucubes_gpu.so
ALL_OBJS += $(GPU_OBJS)
ALL_FLAGS += $(GPU_FLAGS)
else
ALL_OBJS += gpu_fallback.o
endif
Turns out that, when running R CMD INSTALL (...) on Solaris, the installation fails on something like this:
make: Fatal error in reader: Makefile, line 39: Unexpected end of line seen
ERROR: compilation failed for package 'libcucubes'
As it turns out, it is caused by the fact that Solaris' version of make is executed instead of GNU-compatible gmake (I've tested it works fine), even though it is available. My question is whether there is any simple way to force usage of gmake here, for the R package build. In general I know I could use autotools to solve compatibility issues during installation, but it seems to bring too much complexity for that simple case. Any advices will be really appreciated, thanks!
If you can't get your build process to use gmake instead of Solaris's pure POSIX make, you can use this hack:
Make a dedicated directory for this hack: mkdir $HOME/make_hack
Softlink gmake asmakein that directory: ln -s /path/to/gmake $HOME/make_hack/make
Set your PATH: PATH=$HOME/make_hack:$PATH
Now, run your build process using that PATH, and it should use gmake. Hopefully it just uses make from its PATH envval and not some hardcoded full path.
Yeah, it's a hack. But it's probably a lot easier than modifying the build process to use gmake instead of make.
From Writing R Extensions:
If you really must require GNU make, declare it in the DESCRIPTION
file by
SystemRequirements: GNU make
and ensure that you use the value of environment variable MAKE (and
not just make) in your scripts.
configure scripts are the preferred solution though. BTW, in general a Makevars file is also preferred over a full Makefile.

Compiling haskell module Network on win32/cygwin

I am trying to compile Network.HTTP (http://hackage.haskell.org/package/network) on win32/cygwin. However, it does fail with following message:
Setup.hs: Missing dependency on a foreign library:
* Missing (or bad) header file: HsNet.h
This problem can usually be solved by installing the system package that
provides this library (you may need the "-dev" version). If the library is
already installed but in a non-standard location then you can use the flags
--extra-include-dirs= and --extra-lib-dirs= to specify where it is.
If the header file does exist, it may contain errors that are caught by the C
compiler at the preprocessing stage. In this case you can re-run configure
with the verbosity flag -v3 to see the error messages.
Unfortuntely it does not give more clues. The HsNet.h includes sys/uio.h which, actually should not be included, and should be configurered correctly.
Don't use cygwin, instead follow Johan Tibells way
Installing MSYS
Install the latest Haskell Platform. Use the default settings.
Download version 1.0.11 of MSYS. You'll need the following files:
MSYS-1.0.11.exe
msysDTK-1.0.1.exe
msysCORE-1.0.11-bin.tar.gz
The files are all hosted on haskell.org as they're quite hard to find in the official MinGW/MSYS repo.
Run MSYS-1.0.11.exe followed by msysDTK-1.0.1.exe. The former asks you if you want to run a normalization step. You can skip that.
Unpack msysCORE-1.0.11-bin.tar.gz into C:\msys\1.0. Note that you can't do that using an MSYS shell, because you can't overwrite the files in use, so make a copy of C:\msys\1.0, unpack it there, and then rename the copy back to C:\msys\1.0.
Add C:\Program Files\Haskell Platform\VERSION\mingw\bin to your PATH. This is neccesary if you ever want to build packages that use a configure script, like network, as configure scripts need access to a C compiler.
These steps are what Tibell uses to compile the Network package for win and I have used this myself successfully several times on most of the haskell platform releases.
It is possible to build network on win32/cygwin. And the above steps, though useful (by Jonke) may not be necessary.
While doing the configuration step, specify
runghc Setup.hs configure --configure-option="--build=mingw32"
So that the library is configured for mingw32, else you will get link or "undefined references" if you try to link or use network library.
This combined with #Yogesh Sajanikar's answer made it work for me (on win64/cygwin):
Make sure the gcc on your path is NOT the Mingw/Cygwin one, but the
C:\ghc\ghc-6.12.1\mingw\bin\gcc.exe
(Run
export PATH="/cygdrive/.../ghc-7.8.2/mingw/bin:$PATH"
before running cabal install network in the Cygwin shell)

Cross Compiling Qt for Embedded Arm: libpthread.so.0 not found

I am trying to cross compile Qt with WebKit for an embedded arm device (freescale processor). I have a arm-none-linux-gnueabi toolchain.
Qt actually compiled, but I have run into problems when trying to compile the demos, in particular the WebKit ones, which is really what I am after.
The first problem I was having was that libjscore was not found, which was an error due to the way Qt handles static builds. Turns out you can copy the library and it works, see here.
Now compilation breaks again saying it can not find libpthread.so.0, which would seem to be a toolchain problem rather than a Qt problem.
Searching the directory tree in my toolchain, there are several libpthreads. A copy of the find | grep libpthread command's output is below for reference.
./arm-none-linux-gnueabi/sysroot/vfp/lib/libpthread-2.5.so
./arm-none-linux-gnueabi/sysroot/vfp/usr/lib/libpthread_nonshared.a
./arm-none-linux-gnueabi/sysroot/vfp/usr/lib/libpthread.a
./arm-none-linux-gnueabi/sysroot/vfp/usr/lib/libpthread.so_orig
./arm-none-linux-gnueabi/sysroot/vfp/usr/lib/libpthread.so
./arm-none-linux-gnueabi/sysroot/lib/libpthread-2.5.so
./arm-none-linux-gnueabi/sysroot/usr/lib/libpthread_nonshared.a
./arm-none-linux-gnueabi/sysroot/usr/lib/libpthread.a
./arm-none-linux-gnueabi/sysroot/usr/lib/libpthread.so_orig
./arm-none-linux-gnueabi/sysroot/usr/lib/libpthread.so
So it seems that there is something weird with the linker? Also, what needs to be symlinked to create the libpthread.so.0?
Note: the _libpthread.so_orig_ and libpthread.so follow this fix.
Any help or suggestions are much appreciated. I've been banging my head against a wall for two days now.
Thanks
In general, you should make sure that the toolchain you built (or has been built for you) is in the same exact path it was built at. The libraries (*.so *.a) should also be in the same original path. It should look like this:
<path>/bin
<path>/usr/lib
<path>/lib
Those folders should not be moved. The toolchain executables are in "bin" and the libraries it looks for are in "../usr/lib and ../lib". Also, <path> may be hard-coded into your gcc binaries in some fashion. Moving it around seems to break things.
Target is a raspberry PI
I copy target lib directory to myuserdirectory
target /usr/lib to my crosscompiler /usr/lib/ directorie
target /lib my crosscompiler /lib/ directorie
I create two symbolic link:
ln -s /yourcrosscompilerusrlibdirectory /usr/lib/arm-linux-gnueabihf
ln -s /yourcrosscompilerusrdirectory /lib/arm-linux-gnueabihf
and it's work for me
libpthread are in /yourcrosscompilerusrlibdirectory

Setting up "configure" for openMP in R

I have an R package which is easily sped up by using OpenMP. If your compiler supports it then you get the win, if it doesn't then the pragmas are ignored and you get one core.
My problem is how to get the package build system to use the right compiler options and libraries. Currently I have:
PKG_CPPFLAGS=-fopenmp
PKG_LIBS=-fopenmp
hardcoded into src/Makevars on my machine, and this builds it with OpenMP support. But it produces a warning about non-standard compiler flags on check, and will probably fail hard on a machine with no openMP capabilities.
The solution seems to be to use configure and autoconf. There's some information around here:
http://cran.r-project.org/doc/manuals/R-exts.html#Using-Makevars
including a complex example to compile in odbc functionality. But I can't see how to begin tweaking that to check for openmp and libgomp.
None of the R packages I've looked at that talk about using openMP seem to have this set up either.
So does anyone have a walkthrough for setting up an R package with OpenMP?
[EDIT]
I may have cracked this now. I have a configure.ac script and a Makevars.in with #FOO# substitutions for the compiler options. But now I'm not sure of the workflow. Is it:
Run "autoconf configure.in > configure; chmod 755 configure" if I change the configure.in file.
Do a package build.
On package install, the system runs ./configure for me and creates Makevars from Makevars.in
But just to be clear, "autoconf configure.in > configure" doesn't run on package install - its purely a developer process to create the configure script that is distributed - amirite?
Methinks you have the library option wrong, please try
## -- compiling for OpenMP
PKG_CXXFLAGS=-fopenmp
##
## -- linking for OpenMP
PKG_LIBS= -fopenmp -lgomp
In other words, -lgomp gets you the OpenMP library linked. And I presume you know that this library is not part of the popular Rtools kit for Windows. On a modern Linux you should be fine.
In an unrelease testpackage I have here I also add the following to PKG_LIBS, but that is mostly due to my use of Rcpp:
$(shell $(R_HOME)/bin/Rscript -e "Rcpp:::LdFlags()") \
$(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS)
Lastly, I think the autoconf business is not really needed unless you feel you need to test for OpenMP via configure.
Edit: SpacedMan is correct. Per the beginning of the libgomp-4.4 manual:
1 Enabling OpenMP
To activate the OpenMP extensions for
C/C++ and Fortran, the compile-time
flag `-fopenmp' must be specified.
This enables the OpenMP directive
[...] The flag also
arranges for automatic linking of the
OpenMP runtime library.
So I stand corrected. Seems that it doesn't hurt to manually add what would get added anyway, just for clarity...
Just addressing your question regarding the usage of autoconf--no, you do not want to run autoconf with any arguments, nor should you redirect its output. You are correct that running autoconf to build the configure script is something that the package maintainer does, and the resulting configure script is distributed. Normally, to generate the configure script from configure.ac (older packages use the name configure.in, but that name has been discouraged for several years), the developer simply runs autoconf with no arguments. Before running autoconf, it is necessary to run aclocal, autoheader, libtoolize, etc... There is also a tool (autoreconf) which simplifies the process and invokes all the required programs in the correct order. It is now more typical to run autoreconf instead of autoconf.

Resources