How to check a makefile for dependencies? - makefile

I'm trying to install something with the following command:
make world
It takes a long time, and usually it ends up with an error saying that I'm missing some kind of package. I found out what the package is, install it, and run the thing again, only to find out after a long time that I'm missing another package. Is there a way to find out all the packages I need to install without having to go through this process?

This is generally what the configure script does. If the project you're building doesn't have one, you should write one.

The best way to deal with dependencies is with a package manager such as:
On Ubuntu: apt-get
On Red Hat / Fedora: yum
On Mac OS X: port
On Windows: cygwin
If you install software with a package manager, it will automatically fetch, download, and install any dependencies as necessary. These package managers support a huge number of popular open source projects, but not all projects are supported. Some of these package managers support creating custom package repositories, which allows them to be used for dependency management in-house, as well.
Unfortunately, there is no general way to get all the library dependencies of a Makefile (short of grepping for "lib", ".so", and "-l" which may give you spurious results); however, if you are installing an open source project, chances are that it is supported by a package manager on your system.

Related

Is there any package management system for MinGW+MSYS?

I am trying to compile some open source libraries in MinGW+MSYS. During the configure phase, I kept seeing some 3rd party libraries are missing.
For now, my solution is to download the source of the missing libraries and follow the GNU build process to compile and install them into my MinGW environment.
Is there any package management system for MinGW+MSYS to install packages easily? Just like apt-get.
I tried the mingw-get for the missing package. But it reports the error below.
mingw-get is the (closest equivalent to apt-get) package manager for MinGW and MSYS. However, it can only manage packages which are actually available for MinGW and/or MSYS, (either because a MinGW developer has built and packaged them, or a member of the MinGW user community has contributed them).
Arbitrarily guessing what packages may be available, and even what their correct package names may be, is unlikely to be productive. Run mingw-get in its GUI mode, (if it's properly installed, just running mingw-get without arguments should start it in this mode), to see a list of packages which are actually available; if you don't see any likely candidates for what you are looking for, then it doesn't (yet) exist. In that case, you will need to either find a non-MinGW alternative build, or build it yourself, from source. (If you choose the latter option, and your build is successful, then you may wish to consider contributing it to MinGW.org).
This works for me as a "package manager".
Install MSYS2. It comes with a package manager called pacman.

using stackage on windows

I am trying to use stackage on windows. I cloned the git repo, ran cabal install --only-dependencies, cabal configure, cabal build. Everything works
then dist\build\Stackage\stackage.exe select
Loading Haskell Platform
Loading package database
Narrowing package database
Printing build plan to build-plan.log
Checking for bad versions
authenticate-oauth-1.4.0.8 (FP Complete <michael#fpcomplete.com> #yesodweb) cannot use:
- RSA-2.0 -- ==1.2.*
threepenny-gui-0.4.1.0 (FP Complete <michael#fpcomplete.com>) cannot use:
- aeson-0.7.0.2 -- ==0.6.*
stackage.exe: Conflicting build plan, exiting
the readme mention *.sh scripts like ./patching/scripts/create-tarballs.sh. I tried but failed to run them with cygwin. Are they important?
How can I use stackage on windows?
edit I was able to run the ./patching/scripts/create-tarballs.sh script using msys. But now the error message is:
Loading Haskell Platform
Loading package database
stackage.exe: Missing cabal file "MFlow-0.3.3/MFlow.cabal" in tarball: "patching/tarballs\\MFlow-0.3.3.tar.gz"
I checked the archive: the cabal file is inside.
Windows users are not recommended to install stackage by Haskell Platform installer due to some limitation:
On Windows, it does not provide a complete environment (missing MSYS).
By placing a large number of packages in the global package database, Haskell Platform installations are more easily corrupted.
The choice of package versions conflicts with the needs of many commonly used packages.
Some of the package versions included with the platform have known and severe bugs, and cannot be reliably upgraded.
As for solution to overcome, uninstall the Haskell platform first, then install minghc for windows by the following link: https://github.com/fpco/minghc#readme
Open command prompt run cabal update and cabal install alex happy.
Finally, install stackage.
Update 2015
A new tool has been developed by Commercial Haskell group for project development -- Stack, it can be install along with the latest Haskell Platform (7.10.2).
Features include:
Installing GHC automatically, in an isolated location.
Installing packages needed for your project.
Building your project.
Testing your project.
Benchmarking your project.
I have tried it for haskell web project, it works smoothly.

How to make cabal to list necessary libraries, and provide me the choose of their versions without automatical installation?

I encountered some inconvenience when builded some package: the gtk.
When I wrote cabal install gtk-0.12.4 it was trying to build it upon the MODERN dependence libraries. And it was failed. So I had to track install necessary versions of dependence libraries.
Is there convenient way to make cabal tell me, what dependencies should be installed, and I installed them myself, by choosing necessary version?
P. S.: The installation I talking about is described here: https://stackoverflow.com/a/22283107/2815429
You can start with
cabal install --dry-run --only-dependencies gtk-0.12.4
and look at what it would do. Then either install them manually, as you said, or add --constraint some-dependency==1.2.3.4 or similar parameters until you are satisfied with the version selection, and have cabal install it all in one go.

rpmbuild - How to mark some package as conflicting at build time

I have to use different compiler (gcc) from one packaged with centos. It is also gcc, just repacked newer version which has been installed with different path.
I am using mock for build, which has in its basic setup
config_opts['chroot_setup_cmd'] = 'groupinstall build'
Group build in my case contains CentOS stock gcc. I cannot change anything in mock environment.
Is there a way how to delete gcc package before build actually proceed?
The problem is that some programs compiled by my repacked gcc tends to use system /usr/include/ instead of correct include's from repacked gcc, so I am looking for a way how to localize problem.
You can try to use the instructions provided by Fedora to complete this task, they talk about doing a build when the rpm you need to install isn't part of a repo.
If that doesn't work I would look at setting up a custom environment, or asking your admin to do so if you cannot change it as you state in your question. The configuration files are stored under /etc/mock/*.cfg. I would suggest copying one of these that matches your needs and naming it something unique. Then you need to add an additional repo line (either local or remote depending on where your custom copy of GCC lives).
This will configure the environment to pick up that version of GCC if it really is just marked as a newer release. In the event there is some unique naming convention or it's not being picked up for some reason you should look at modifying the chroot_setup_cmd to simply install all the build packages. When I review a
yum groupinstall buildsys-build
I see a list of all the associated packages. You'll obviously want to check 'build'. You can then modify your config_opts['chroot_setup_cmd'] to use 'install', instead of 'groupinstall', where you can then install all the associated build packages, as well as your custom GCC.
If that still doesn't work, you can always copy the build packages to your own personal repo where GCC lives, ensure that's the only one available to pull from, configure the repo so it supports the 'build' group, and then build the package. While not extremely helpful due to age, the Mock docs have some useful information for configuring your environment with local repos.

Creating an installer file, linux

I currently have an installation bash script (INSTALL) and a bunch of files that are the program itself. I would like to pack the files and the script in one file, maybe tar (?) and make it executable so that when it is called INSTALL will run.
Any ideas of how I can do it? What's the common method, if there is one, to do to?
Thanks
You can use a shar archive. shar archives are self-contained executable shell scripts that are self-unpacking, and you can execute whatever code you want after the script unpacks.
In the Linux world, the expectation is that programs come in the form of packages. The most common package formats are rpm (used by Red Hat, CentOS, Fedora, SuSE, …) and deb (used by Debian, Ubuntu, …). You'll often need to make separate versions of your package (linking to different libraries) for different releases of these distributions.
Compared with the Windows world (pre-Market), you have more work to do, because the programmer or distributor is expected to do the bulk of the work of tracking program dependencies. The end user experience is simpler: all package installation and subsequent maintenance (including tracking new versions, upgrading, uninstalling, etc.) is done through a single tool (APT on Debian/Ubuntu, Yum on Red Hat/Fedora, etc.). As a programmer, you can gain the benefit of standard tools to build packages, to track dependencies (no need to package libraries: the build tool will add the necessary dependencies). Many distributions provide a standard channel to install packages, such as PPAs for Ubuntu.
You can package it to rpm.
Rpm packages allow you to use scripts before and after unpacking process.

Resources