Writing `configure` file for an r package - autoconf

I am writing an r package which provides a wrapper around the libSBML C library.
I am using the rcppgsl package as a reference, which looks for the location of header files and the library files for GNU Scientific Library GSL and uses that information to write the configure script and Makevars and Makevars.in. I am not building for Windows currently. On my machine (macOS), libsbml (SBML C library) is installed in usual locations, i.e.
header files are at - /usr/local/include/sbml
and library files at - /usr/local/lib. Indeed, if in my package Makevars file I use the following, I can build my package.
CXX=clang++
PKG_CPPFLAGS= -I/usr/local/include
PKG_LIBS= $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS) /usr/local/lib/libsbml-static.a
However, I want to learn how to use the configure script to find the library and use that information to build the package. The relevant portion of configure.ac from rcppgsl is
## Check for non-standard programs: gsl-config(1)
AC_PATH_PROG([GSL_CONFIG], [gsl-config])
## If gsl-config was found, let's use it
if test "${GSL_CONFIG}" != ""; then
# Use gsl-config for header and linker arguments
GSL_CFLAGS=`${GSL_CONFIG} --cflags`
GSL_LIBS=`${GSL_CONFIG} --libs`
else
AC_MSG_ERROR([gsl-config not found, is GSL installed?])
fi
I replaced GSL_CONFIG with LIB_SBML at relevant places, i.e., the entire configure.ac file I am using is pasted below (at the end).
However, I don't see configure, Makevars and Makevars.in being generated (which I see in rcppgsl). Any help here would be highly appreciated!
For the sake of completion, the output of
ls -l | grep sbml (in usr/local/include) is
drwxrwxr-x 58 root admin 1856 Aug 1 2016 sbml
and ls -l | grep sbml (in usr/local/lib) is
-rw-r--r-- 1 root wheel 7970584 Aug 2 2016 libsbml-static.a
-rwxr-xr-x 1 arcadmin staff 10453624 Nov 25 2014 libsbml.5.11.0.dylib
-rwxr-xr-x 1 root wheel 3813572 Aug 2 2016 libsbml.5.13.0.dylib
lrwxr-xr-x 1 root wheel 20 Aug 1 2016 libsbml.5.dylib -> libsbml.5.13.0.dylib
-rw-r--r-- 1 root wheel 13907656 Feb 26 2015 libsbml.a
lrwxr-xr-x 1 arcadmin staff 15 Mar 27 2015 libsbml.dylib -> libsbml.5.dylib
-rwxr-xr-x 1 root wheel 828 Feb 26 2015 libsbml.la
-rwxrwxr-x 1 root admin 13362732 Nov 25 2014 libsbmlj.jnilib
My configure.ac file --
## Process this file with autoconf to produce a configure script.
##
## Configure.ac for RcppSBML
##
## Copyright (C) 2010 Romain Francois and Dirk Eddelbuettel
## Copyright (C) 2014 - 2015 Dirk Eddelbuettel
##
## Licensed under GNU GPL 2 or later
# The version set here will propagate to other files from here
AC_INIT([Rcppsbml], 0.1.0)
# Checks for common programs using default macros
AC_PROG_CC
## Use gsl-config to find arguments for compiler and linker flags
##
## Check for non-standard programs: gsl-config(1)
AC_PATH_PROG([LIB_SBML], [libsbml])
## If gsl-config was found, let's use it
if test "${LIB_SBML}" != ""; then
# Use gsl-config for header and linker arguments
SBML_CFLAGS=`${LIB_SBML} --cflags`
SBML_LIBS=`${LIB_SBML} --libs`
else
AC_MSG_ERROR([libsbml not found, is SBML installed?])
fi
# Now substitute these variables in src/Makevars.in to create src/Makevars
AC_SUBST(LIB_SBML)
AC_SUBST(LIB_SBML)
AC_OUTPUT(src/Makevars)

Here a minimal setup:
Remove src/Makevars and create src/Makevars.in with content
PKG_CPPFLAGS= #SBML_INCLUDE#
PKG_LIBS= $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS) #SBML_LIBS#
I am not setting CXX since you cannot change that in src/Makevars, c.f. Package build ignores Makevars flags.
Create a minimal configure.ac file:
AC_INIT([Rcppsbml], 0.1.0)
AC_LANG(C++)
AC_REQUIRE_CPP
AC_PROG_CXX
# default values
AC_SUBST([SMBL_INCLUDE], "-I/usr/local/include")
AC_SUBST([SMBL_LIBS], "/usr/local/lib/libsbml-static.a")
# allow for override
AC_ARG_WITH([smbl],
AC_HELP_STRING([--with-smbl=PREFIX],
[path to where smbl is installed]),
[
SMBL_INCLUDE="-I${with_smbl}/include"
SMBL_LIBS="${with_smbl}/lib/libsbml-static.a"
],
[])
# create and report output
AC_CONFIG_FILES([src/Makevars])
AC_OUTPUT
echo
echo "Final src/Makevars"
cat src/Makevars
Call autoconf to create a configure file from your configure.ac template. You might want to check the script with ./configure and ./configure --with-smbl=/some/path.
Call
R CMD build ...
R CMD check [--install-args=--configure-args=--with-smbl=/some/path] ...
R CMD INSTALL [--configure-args=--with-smbl=/some/path]...
to build, check and install the package.
Possible extensions:
Allow for switching between static and dynamic linking.
Check that SMBL can be found in a usable state at the specified location.
I see three issues here:
The generation of configure from configure.ac is not automatic. You have to call autoconf.
Similarly, Makevars.in is not generated by the system. You have to provide it as template from which Makevars is generated by configure.
The GSL ships with gsl-config, other libraries make use of the general pkg-config. If your library does not support this, you can use the more traditional way to use default locations or those provided with --with-... arguments. For example in RcppArrayFire I use:
AC_SUBST([AF_INCLUDE], "")
AC_SUBST([AF_LIBS], "-laf")
AS_IF([test -e "${with_arrayfire}"],
[
AF_INCLUDE="-I${with_arrayfire}/include ${AF_INCLUDE}"
AF_LIBS="-L${with_arrayfire}/lib ${AF_LIBS} -Wl,-rpath,${with_arrayfire}/lib"
])
If a directory is supplied as --with-arrayfire=/relevant/path, then appropriate sub directories are searched for headers and dynamic libraries.

Related

Haskell stack installs package, but module can't be imported

I seem to be able to install a package using stack, but then it's not available in ghci. I didn't set up a project directory; I'm just loading files from the directory I start ghci in. (I'll get to packages, this is for my early learning experiments.)
With stack Version 2.5.1, Git revision d6ab861544918185236cf826cb2028abb266d6d5 x86_64 hpack-0.33.0, I am able to install package pretty-tree:
~$ stack install pretty-tree
split > using precompiled package
boxes > using precompiled package
pretty-tree> configure
pretty-tree> Configuring pretty-tree-0.1.0.0...
pretty-tree> build
pretty-tree> Preprocessing library for pretty-tree-0.1.0.0..
pretty-tree> Building library for pretty-tree-0.1.0.0..
pretty-tree> [1 of 1] Compiling Data.Tree.Pretty
pretty-tree> copy/register
pretty-tree> Installing library in /Users/marshall/.stack/snapshots/x86_64-osx/7f23217891aaded25d36ce049bc36fa5daea730080286c2d93877f934c894bb2/8.8.4/lib/x86_64-osx-ghc-8.8.4/pretty-tree-0.1.0.0-KTaQApPwVahHd2AQwQQQSA
pretty-tree> Registering library for pretty-tree-0.1.0.0..
Completed 3 action(s).
But I can't load the module that pretty-tree provides:
$ stack ghci
...
Prelude> import Data.Tree.Pretty
<no location info>: error:
Could not find module ‘Data.Tree.Pretty’
It is not a module in the current program, or in any known package
I have a similar problem when I put the import statement into a file that normally would load:
myfile.hs:9:1: error:
Could not find module ‘Data.Tree.Pretty’
Use -v (or `:set -v` in ghci) to see a list of the files searched for.
|
9 | import Data.Tree.Pretty
| ^^^^^^^^^^^^^^^^^^^^^^^
Failed, no modules loaded.
I can see a .conf file for the package:
~/.stack/snapshots/x86_64-osx$ ll 7f23217891aaded25d36ce049bc36fa5daea730080286c2d93877f934c894bb2/8.8.4/pkgdb
total 48
-rw------- 1 marshall staff 1817 Dec 3 12:28 boxes-0.1.5-Q9SvFlNJmuH845NHEKHN9.conf
-rw------- 1 marshall staff 10015 Dec 3 12:28 package.cache
-rw------- 1 marshall staff 0 Dec 3 12:28 package.cache.lock
-rw------- 1 marshall staff 1894 Dec 3 12:28 pretty-tree-0.1.0.0-KTaQApPwVahHd2AQwQQQSA.conf
-rw------- 1 marshall staff 2763 Dec 3 12:28 split-0.2.3.4-KyPtAwfJzED2zEIheQpqQL.conf
and there are other packages I've installed with stack that I can import (but they are in different snapshot directories).
I don't know much about stack or cabal. Up to this point, installing new packages with stack just worked, and I didn't have to think about it. I've looked at the half a dozen similar SO questions that I can find. Some of them report similar problems but don't use stack. The ones that do involve stack haven't helped. I've gone through the parts of the online stack documentation that seemed relevant, but haven't found anything.
What am I missing?

How to install a package built with cygport on Cygwin (so I can uninstall it later)?

I have built a package from https://github.com/fd00/yacp using cygport; however I just noticed that cygport [packagename.cygport] install command does NOT install in the cygwin filesystem, but in a subdirectory of the source build directory; as such, executables are not in the cygwin path, and you cannot call them by name.
I have seen:
http://cygwin.1069669.n5.nabble.com/Manual-installation-of-cygport-packages-td132812.html
So for most cases, it works just fine just to unpack the archive into the
root file system in order to test it.
https://cygwin-ports-general.narkive.com/RrfmRgr6/how-to-install-a-package-build-with-cygport
you could install yourself or by descending to the build directory and doing 'make
install' or simply run it from the build directory :-)
So, now I have packagename.tar.xz and packaganame.hint - can't I use these with the Cygwin setup-x86_64.exe program (so that I'd have a marked entry, when I look up the package name in setup)?
If I "install" by just unpacking packagename.tar.xz into the Cygwin root filesystem, how do I "uninstall" then?
Does cygport change installation paths in respect to make install of the package? If not, then I guess make install is an option, because then I should have make uninstall too ...
cygport is the tool to build packages that can be installed with Cygwin setup-$ARCH.exe installation.
You can create a local setup structure, and use the calm package to create
the needed setup.ini file.
$ cygcheck -f /usr/bin/mksetupini
calm-20200220-1
Create a website directory similar to the cache you have from downloading, make a ARCH/release directory and copy the content of dist for the packages you are interested.
I am using a script like this to prepare the directory for setup
#!/bin/bash
cd /pub/altervista/
rm x86/setup.ini x86_64/setup.ini
for i in x86 x86_64
do
mksetupini --arch ${i} --inifile=${i}/setup.ini --releasearea=. --disable-check=missing-required-package,missing-depended-package
bzip2 <${i}/setup.ini >${i}/setup.bz2
xz -6e <${i}/setup.ini >${i}/setup.xz
done
In this moment its structure is like this:
$ cd http%3a%2f%2fmatzeri.altervista.org%2f
$ find x86_64/ -type f
x86_64/release/perl-Cairo/perl-Cairo-1.107-1-src.tar.xz
x86_64/release/perl-Cairo/perl-Cairo-1.107-1.hint
x86_64/release/perl-Cairo/perl-Cairo-1.107-1.tar.xz
x86_64/release/perl-Cairo/perl-Cairo-debuginfo/perl-Cairo-debuginfo-1.107-1.hint
x86_64/release/perl-Cairo/perl-Cairo-debuginfo/perl-Cairo-debuginfo-1.107-1.tar.xz
x86_64/release/perl-Glib/perl-Glib-1.3292-1-src.tar.xz
x86_64/release/perl-Glib/perl-Glib-1.3292-1.hint
x86_64/release/perl-Glib/perl-Glib-1.3292-1.tar.xz
x86_64/release/perl-Glib/perl-Glib-debuginfo
x86_64/release/perl-Glib/perl-Glib-debuginfo/perl-Glib-debuginfo-1.3292-1.hint
x86_64/release/perl-Glib/perl-Glib-debuginfo/perl-Glib-debuginfo-1.3292-1.tar.xz
x86_64/setup.bz2
x86_64/setup.ini
x86_64/setup.xz
than you can just install from that Website local directory. A fake Website works fine.
Ok, found and followed the instructions here: https://cygwin.com/package-server.html
First install calm via Cygwin's setup.exe (for me, setup-x86_64.exe):
Install calm 20200220-1
Install python36-setuptools 41.2.0-1 (automatically added)
Then, I have:
$ which mksetupini
/usr/bin/mksetupini
Note, I have already: /cygdrive/d/Downloads/cygwin_packages/http%3a%2f%2fcygwin.mirror.constant.com%2f/x86_64 where Cygwin stores downloaded packages; that directory has release subdir and setup.ini file.
So, now I can create a directory for my custom packages:
$ mkdir /cygdrive/d/Downloads/cygwin_packages/cygwin-custom
$ mkdir -p /cygdrive/d/Downloads/cygwin_packages/cygwin-custom/x86_64/release
Note that in my source build folder, I have a dist subfolder, which contains the packaging:
$ ls -la [packagename]-[version]-1bl1.x86_64/dist/[packagename]/
total 2557
drwxr-xr-x 1 user None 0 Mar 21 18:26 .
drwxr-xr-x 1 user None 0 Mar 21 18:26 ..
-rw-r--r-- 1 user None 373 Mar 21 18:26 [packagename]-[version]-1bl1.hint
-rw-r--r-- 1 user None 177772 Mar 21 18:26 [packagename]-[version]-1bl1.tar.xz
-rw-r--r-- 1 user None 2430900 Mar 21 18:26 [packagename]-[version]-1bl1-src.tar.xz
drwxr-xr-x 1 user None 0 Mar 21 18:26 [packagename]-debuginfo
drwxr-xr-x 1 user None 0 Mar 21 18:26 lib[packagename]0
drwxr-xr-x 1 user None 0 Mar 21 18:26 lib[packagename]-devel
I can just copy this to the arch/release child dir of cygwin-custom, and then change directory to cygwin-custom:
$ cp -a [packagename]-[version]-1bl1.x86_64/dist/[packagename] /cygdrive/d/Downloads/cygwin_packages/cygwin-custom/x86_64/release/
$ pushd /cygdrive/d/Downloads/cygwin_packages/cygwin-custom
Now, note that if I just call mksetupini as in the above webpage, it will fail:
$ mksetupini --arch x86_64 --inifile=x86_64/setup.ini --releasearea=.
mksetupini: package '[packagename]' version '[version]-1bl1' requires nonexistent or errored package 'cygwin'
mksetupini: package '[packagename]' version '[version]-1bl1' requires nonexistent or errored package 'libgcc1'
mksetupini: package '[packagename]' version '[version]-1bl1' requires nonexistent or errored package 'libreadline7'
...
... and the file setup.ini does not get created!
Then I thought I should symlink as in the above webpage:
$ for ARCH in x86_64 noarch ; do
mkdir -p ${ARCH}/release
cd ${ARCH}/release
ln -s /cygdrive/d/Downloads/cygwin_packages/http%3a%2f%2fcygwin.mirror.constant.com%2f/${ARCH}/release/* .
cd ../..
done
$ mksetupini --arch x86_64 --inifile=x86_64/setup.ini --releasearea=.
mksetupini: no .hint files in ./noarch/release/adwaita-icon-theme but has files: adwaita-icon-theme-3.26.1-1.tar.xz
mksetupini: no .hint files in ./noarch/release/base-cygwin but has files: base-cygwin-3.8-1.tar.xz
mksetupini: no .hint files in ./noarch/release/base-files but has files: base-files-4.3-2.tar.xz
...
mksetupini: package '[packagename]' version '[version]-1bl1' requires nonexistent or errored package 'cygwin'
mksetupini: package '[packagename]' version '[version]-1bl1' requires nonexistent or errored package 'libgcc1'
mksetupini: package '[packagename]' version '[version]-1bl1' requires nonexistent or errored package 'libreadline7'
mksetupini: package '[packagename]' version '[version]-1bl1' depends nonexistent or errored package 'cygwin'
...
... and this does not create setup.ini either.
Finally I found https://github.com/cascent/neovim-cygwin/issues/7 that mentioned the switch --okmissing required-package - so, finally this command:
$ mksetupini --arch x86_64 --inifile=x86_64/setup.ini --releasearea=. --okmissing required-package
... will finally create setup.ini - which will only contain our custom built packages, as they are the only ones that have a .hint file ( I don't have any .hint files in the http%3a%2f%2fcygwin.mirror.constant.com%2f directory, where cygwin usually downloads packages ):
$ cat x86_64/setup.ini
# This file was automatically generated at 2020-03-21 19:42:00 CET.
#
# If you edit it, your edits will be discarded next time the file is
# generated.
#
# See https://sourceware.org/cygwin-apps/setup.ini.html for a description
# of the format.
release: cygwin
arch: x86_64
setup-timestamp: 1584816120
# [packagename]
sdesc: "Blah blah ..."
...
Now, start Cygwin setup.exe, and when the choice screen is: "Cygwin Setup - Choose Installation Type"; here switch from "Install from Internet (...)" to "Install from Local Directory"; on Next > keep Root directory the same; on Next > Select Local Package Directory: I chose D:\Downloads\cygwin_packages\cygwin-custom - on Next > : Select Packages: View Full, then [packagename] is listed there ... and can be installed - and dependencies are resolved, too:
Install [packagename] [version]-1bl1
Install lib[packagename]0 [version]-1bl1 (automatically added)
And finally, after installation, I can call [packagename].exe by name directly in the Cygwin bash shell!
Not too bad of a process, but can get a bit involved if you cannot find the right documentation ...

How correctly to link program against library

I run ./myprogram and it gives me a warning:
Warning: Your program was compiled with SimGrid version 3.13.90, and then linked against SimGrid 3.13.0. Proceeding anyway.
Tryldd myprogram and it gives following:
libsimgrid.so.3.13.90 => /usr/lib/libsimgrid.so.3.13.90 (0x00007f338ef47000)
Then I go to usr/lib and type ll *sim* in terminal:
lrwxrwxrwx 1 ken ken 21 июл 28 19:29 libsimgrid.so -> libsimgrid.so.3.13.90*
-rwxrwxr-x 1 ken ken 12307480 июл 28 19:29 libsimgrid.so.3.13.90*
In CMakeLists.txt I link library simgrid in such way:
target_link_libraries(CSim2Sim simgrid)
Why myprogram still links against SimGrid 3.13.0 (it doesn't exist in /usr/lib while SimGrid 3.13.90 does)?
UPDATE:
Command locate libsimgrid.so in ternimal gives:
/home/ken/Downloads/simgrid-master/lib/libsimgrid.so
/home/ken/Downloads/simgrid-master/lib/libsimgrid.so.3.13.90
/home/ken/SimGrid/lib/libsimgrid.so
/home/ken/SimGrid/lib/libsimgrid.so.3.13.90
/usr/lib/libsimgrid.so
/usr/lib/libsimgrid.so.3.13.90
The message seems buggy, it looks like your application was actually compiled with 3.13.0, and linked to libsimgrid 3.13.90. The order was inverted in the message, I will fix that.
It could be a problem with your includes when you compile your code, I think. Please check that you don't use old versions of msg.h/simgrid_config.h files when you compile your app (maybe there are still one in /usr/include ?).
To check, you can look for SIMGRID_VERSION_PATCH in simgrid_config.h. it should be 90 in a recent one, not 0.

How to enable ccache on Linux

There is very little documentation on enabling ccache on GNU/Linux. Here is a response from launchpad.net:
At the moment, I think the best way to enable ccache is to add
"/usr/lib/ccache" to the front of your path. If you want to enable it
for all users by default, change the PATH variable in
/etc/environment.
Can someone give me more information on enabling ccache?
Download latest version of ccache for better performance.
After Downloading, Follow the steps as mentioned below:
A) Tar the file using the following command :
$tar -xvf ccache-3.2.4.tar.bz2
Note : I'm using ccache 3.2.4 Version.You can download the latest one.
B) Go inside ccache-3.2.4 folder and run the following commands:
$./configure
$./make
$ sudo make install
C) Go to your .bashrc and insert the following :
export CCACHE_DIR=/home/user_name/.ccache
export CCACHE_TEMPDIR=/home/user_name/.ccache
Note : Fill user_name with your User Name
D) Save your Bashrc and source it
$ source ~/.bashrc
E) To check ccache is working or not type :
ccache -M 10G : To Set the ccache Size to 10GB
F) To check ccache is working or not type :
ccache -s : To check ccache statistics
There are at least two methods:
i) Override the CC, CXX, ... flags in a Makefile. Within the R framework, a system and optional user configuration file is read, and I simply set
VER=4.7
CC=ccache gcc-$(VER)
CXX=ccache g++-$(VER)
SHLIB_CXXLD=g++-$(VER)
FC=ccache gfortran
F77=ccache gfortran
which also allows me to switch back and forth between gcc versions. Now all compilations involving R use ccache.
ii) For other uses, I have deployed the fact that /usr/local/bin/ is checked prior to /usr/bin. So one can do
root#max:/usr/local/bin# ls -l gcc
lrwxrwxrwx 1 root root 15 Jan 27 11:04 gcc -> /usr/bin/ccache
root#max:/usr/local/bin# ./gcc --version
gcc (Ubuntu/Linaro 4.7.2-2ubuntu1) 4.7.2
Copyright (C) 2012 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
root#max:/usr/local/bin#
and now gcc is invoked via ccache:
edd#max:/tmp$ cp -vax ~/src/progs/C/benfordsLaw.c .
`/home/edd/src/progs/C/benfordsLaw.c' -> `./benfordsLaw.c'
edd#max:/tmp$ time /usr/local/bin/gcc -c benfordsLaw.c
real 0m0.292s
user 0m0.052s
sys 0m0.012s
edd#max:/tmp$ time /usr/local/bin/gcc -c benfordsLaw.c
real 0m0.026s
user 0m0.004s
sys 0m0.000s
edd#max:/tmp$
The ccache manual has a section called Run modes which describes the official ways of activating ccache, so I suggest reading the manual.
Also, as you already noted, Linux distributions often set up a /usr/lib/ccache directory which is designed to be prepended to PATH.
Another possibility (instead of export CC=ccache commented by Keltar), if $HOME/bin/ is listed in your $PATH before /usr/bin/, would be to make a symlink
ln -s /usr/bin/ccache $HOME/bin/gcc
Then every execvp(3) of gcc would find that symlink
Ubuntu install ccache
sudo apt-get install ccache
Confirm installation execution after installation "which ccache"
$ which ccache
/usr/bin/ccache
Add the following contents to the "~/.bashrc" or "~/.zshrc==" file
# ccache
export USE_CCACHE=1
export CCACHE_SLOPPINESS=file_macro,include_file_mtime,time_macros
export CCACHE_UMASK=002
source "~/.bashrc" or "~/.zshrc"
4. The 5 GB disk space set by default for ccache is normally enough. If you are worried about it, you can increase it, ccache -M 30G
5. Confirm successful installation through version
$ ccache --version
ccache version 3.4.1
Copyright (C) 2002-2007 Andrew Tridgell
Copyright (C) 2009-2018 Joel Rosdahl
You can view the current configuration through ccache - s
cache directory /home/username/.ccache
primary config /home/username/.ccache/ccache.conf
secondary config (readonly) /etc/ccache.conf
stats zero time Fri Jul 22 16:15:40 2022
cache hit (direct) 4186
cache hit (preprocessed) 875
cache miss 1069
cache hit rate 82.56 %
called for link 653
cleanups performed 0
files in cache 3209
cache size 159.3 MB
max cache size 30.0 GB
Use libzmq to test ccache
Through github download the source code of libzmq
$ git clone https://github.com/zeromq/libzmq.git
Cloning into 'libzmq'...
remote: Enumerating objects: 43791, done.
remote: Counting objects: 100% (36/36), done.
remote: Compressing objects: 100% (28/28), done.
remote: Total 43791 (delta 11), reused 24 (delta 8), pack-reused 43755
Receiving objects: 100% (43791/43791), 21.91 MiB | 1.03 MiB/s, done.
Resolving deltas: 100% (31951/31951), done.
Create the build directory in the libzmq directory
Modify CMakeLists. txt , '+' to add
──────┬───────────────────────────────────────────────────────────────────────────────────────
│ File: CMakeLists.txt
───────┼──────────────────────────────────────────────────────────────────────────────────────
1 │ # CMake build script for ZeroMQ
2 │ project(ZeroMQ)
3 │
4 │ if(${CMAKE_SYSTEM_NAME} STREQUAL Darwin)
5 │ cmake_minimum_required(VERSION 3.0.2)
6 │ else()
7 │ cmake_minimum_required(VERSION 2.8.12)
8 │ endif()
9 │
10 + │ find_program(CCACHE_FOUND ccache)
11 + │ if(CCACHE_FOUND)
12 + │ set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
13 + │ set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
14 + │ message(STATUS "use ccache")
15 + │ endif(CCACHE_FOUND)
16 + │
17 │ include(CheckIncludeFiles)
Execute "cmake .." In the build directory
Print and display **"-- use ccache" **means enable ccache, but note that when each project is enabled ccache for the first time, it will not speed up the compilation speed, but save the compilation cache to the "/home/username/. cache" directory for later compilation
$ cmake ..
-- The C compiler identification is GNU 7.5.0
-- The CXX compiler identification is GNU 7.5.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- use ccache
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE
...
Use the "/usr/bin/time" command to record the compilation time
/usr/bin/time make -j3
result:
48.79user 14.25system 0:21.60elapsed 291%CPU (0avgtext+0avgdata 176036maxresident)k
0inputs+282248outputs (0major+2406923minor)pagefaults 0swaps
"rm - rf *" delete build all files in the directory
cmake ..
Use the "/usr/bin/time" command to record the compilation time
/usr/bin/time make -j3
result:
2.78user 2.42system 0:02.15elapsed 241%CPU (0avgtext+0avgdata 23736maxresident)k
0inputs+21744outputs (0major+232849minor)pagefaults 0swaps
https://www.cnblogs.com/jiangyibo/p/16516932.html

How to build this project?

I've been a visual studio developer for long and just trying to understand how things are in linux/unix worl. I found an open source project (Gcomandos) in source forge and tried to build it. when I download the source, I get these files:
16/02/2007 05:16 PM 25,987 aclocal.m4
16/02/2007 05:17 PM 127,445 configure
16/02/2007 05:16 PM 1,925 configure.ac
17/03/2010 03:48 PM <DIR> gComandos
16/02/2007 05:16 PM 332 gcomandos.pc.in
25/11/2006 10:03 PM 9,233 install-sh
16/02/2007 05:16 PM 353 Makefile.am
16/02/2007 05:17 PM 20,662 Makefile.in
16/02/2007 05:16 PM 1,019 Makefile.include
25/11/2006 10:03 PM 11,014 missing
I am now lost. I tried making the .am or the .in files, but GnuMake says there is nothing to make. I tried running the shell scripts, but I got errors. Any guidance appreciated.
Normally it's supposed to come with an INSTALL file to read. Since it doesn't, here's the basic routine:
./configure
make
sudo make install
Note that configure has a number of options it can take; pass --help to see them.
If you simply want to build and install it:
./configure
make
sudo make install
If you make some changes to this project and rebuild it later do:
aclocal - adds aclocal.m4 to directory. Defines some m4 macros used by the auto tools.
'autoconf '- creates configure from configure.ac
'automake' - Creates Makefile.in from Makefile.am
'./configure' - creates Makefile from Makefile.in
'make'
sudo make install
One recommendation to make on top of the various correct answers is to see what build options are available. The first command I like to run is:
./configure --help
This will list various build options. Some are standard (such as --prefix= for changing where the package is intalled) and others are project specific (often in the form --with-FOO to build with extra features based on the FOO package).

Resources