Installing make ubuntu. Ubuntu Make - to help the developer. Downloading the kernel sources

💖 Like it? Share the link with your friends

The bottom line is that this command in the form of " make install' or 'sudo make install' cannot be used on modern distributions.

But after all, the authors of the programs in the installation manuals write that you need to use this command, you might say. Yes, they write. But this only means that they do not know what distribution kit you have, and whether it is a distribution kit at all, maybe you joined a sect and smoked reading LFS and now decided to compile their creation under your chthonic system. And make install is a universal, if often wrong, way to do it.

Lyrical digression

As you know, for normal operation, most software must not only be compiled, but also correctly installed on the system. Programs expect to find the files they need in certain places, and these places in most *nix systems are hardcoded into the code at compile time. In addition to this aspect, the main difference between the installation process in linux/freebsd/whatever and that in Windows and MacOS is that the program does not just put a bunch of files in a separate directory in Program Files or /Applications, but “spreads” itself over the entire file system. Libraries go to lib, executable files to bin, configs to etc, various data to var and so on. If you suddenly need to update it, then all this must first be cleaned somehow, because. using new version remnants of files from the old one can lead to completely unpredictable consequences, often bad. The probability of this event is not so great, but do you need it on a combat server?

So what?

So, if you did the installation directly via make install, then it’s normal to remove or update the software, you most likely you can't. Moreover, installing a new version over the old one is likely to will overwrite your changes in configs. make install does exactly what it's told - it installs the files in the right places, ignoring the fact that something is already there. After this process, it is impossible to obtain absolutely no information about what was put and where in a digestible form. Sometimes, of course, the Makefile supports the uninstall action, but this is not so common, and it's not a fact that it works correctly. In addition, storing the unpacked tree of sources and assembly rules for uninstallation is somehow strange.

How to fight?

Since packages in distributions tend to be updated sometimes, to solve this problem, they came up with such a thing as a package manager. When using it, the installation goes something like this:
  1. a specially formed archive is taken
  2. information is extracted from it about what it is, what version it is, what it depends on, what it conflicts with, whether it is necessary to run some scripts to install / remove / configure, etc
  3. Performing direct installation steps
  4. All data about where and what was delivered is added to the database of the package manager.

In this case, when updating, you can painlessly remove the excess, and at the same time see if the files marked as configuration have changed in the system and ask what to do if their contents are different in the new version. In addition, the package manager will not overwrite the files of one package when installing another. In general, a lot useful pieces he can do.

If you unknowingly / lazily copied make install from the instructions, then files appear in the system that the package manager does not know about. With all the consequences, if what was listed earlier is not enough for you.

What to do?

You can, of course, configure the source tree so that the installation of everything and everything goes somewhere in /opt/mycoolapp/, and then manually delete it if necessary, but a lot of unpleasant things can come out here, starting with the fact that the program expects that it can load your libraries, and the loader knows nothing about the directory where they are, ending with the fact that the author of the program can expect that, for example, if he puts a file, say in $prefix/share/xsessions/, then the display manager will pick it up. Not to mention the paths for pkgconfig and stuff.

So you need to collect the package.

I don't have time to *** deal with this, I'd better make install again, everything is simple and clear!

Calm down, calm down. He is tied to our feet. Everything is not so scary and difficult as it seems at first glance.
checkinstall
This wonderful utility, when run instead of make install, will ask a few questions, after which it will build and install the package itself. Everything, when updating, you will not have any problems with cleaning out old trash.
Building a deb package manually
If you are not inclined to trust such automation (which sometimes still messes up) or if you want to make a couple of changes, but it’s still lazy to deal with the normal process of building packages, then you can build the package manually. I'm giving a way to build it for Debian-based systems, as I'm most familiar with them. It is not ideologically correct, but the output is a completely correct package without involving additional entities. This is done in the following way.
To begin with, we build the software with the --prefix=/usr and --exec-prefix=/usr parameters previously specified for configure or autogen.sh.
Next, we install in a temporary directory. We write:

Fakeroot make install DESTDIR=`pwd`/tempinstall
After that, we get the entire set of files in the newly created directory. By the way, we are now in a fakeroot environment, i.e. you can freely change the owner and access rights of files, but physically you yourself will remain the owner in the system. The software inside the fakeroot session will receive changed information, which will allow you to pack files with the correct rights into the archive.
Next, create the DEBIAN directory in the "package root" and put in DEBIAN/conffiles a list of all files that should get into /etc:

Cd tempinstall mkdir DEBIAN find etc | sed "s/^/\//" > DEBIAN/conffiles
Then we create a DEBIAN/control file with the following content:

If necessary, you can also create preinst, postinst, prerm and postrm scripts there.

That's it, we do dpkg -b tempinstall and we get tempinstall.deb at the output, on which you can set dpkg -i and which will be correctly installed, updated or deleted.

The "correct" pre-packaging process source code is outside the scope of this note, and therefore will not be described, but for your purposes it is usually not necessary.

Conclusion

As you can see, there is absolutely nothing complicated here, but following these steps will save you a huge number of problems in the future.

Hi all!

This is a small note for Linux beginners about what these three great commands mean and what they are for. Let's start, as they say, from the beginning. Most programs must be compiled before use, that is, converted from human-readable text into a set of ones and zeros that a computer can understand. The process is conditionally divided into three stages: configuration (configure), assembly (make) and installation (make install). Details under the cut 🙂

./configure

This command searches for libraries and header files necessary for compilation (this is for programs partially or completely written in C / C ++ and similar languages), as well as setting special parameters or connecting special libraries, if ./configure will find everything he needs, he will create Makefiles- the file needed to build the program

You can configure the configurator parameters using the keys and arguments of these same keys, for example:

./configure --prefix=/opt/my_program

With a key --prefix= You can specify a directory that will later act as a prefix for your program (that is, the root directory). This is due to the fact that in the world of Linux and not only, there is a special Hierarchy of the File System (HFS) according to which any program must be compiled and installed in order to work without errors.

There are three main prefixes in the file system that most programs are configured against, namely:

  • / - the root directory of the operating system, the so-called ROOT
  • /usr - directory where user environment applications are located
  • /usr/local - additional directory for custom programs, collected manually, specifically so that the operating system does not turn into a dump

If you open any of these directories, you can see a very similar structure, at least there will be folders: bin, etc, include, libs, sbin.

If run ./configure without keys, then the default prefix (the directory where the compiled program will be installed) will be /usr/local, remember this if you cannot run your program, you may not have a path in PATH.

Except the key --prefix in the configurator, as a rule, there are many other keys, you can see them all if you run:

./configure --help

make

The most important and simple command/program that starts the application compilation procedure from the source code. For your work this program uses special files Makefiles, which describe in detail the process of building the application with all the parameters that we specified to the configurator. The result of successful execution of the make command will be the compiled program in the current directory.

make install

This command performs a direct installation of the application to the directory specified at the configuration stage, after executing the make install command, you can run the newly installed program.

Afterword

In order not to write three commands in turn, you can write them in one line:

./configure && make && make install

&& is an AND operator that came from the C/C++ language, however, from the point of view of the shell, it means that the next command should be executed only if the previous command was successful, this is very convenient if one of the stages ends with an error.

In fact, make install can also build, because the install task depends on the all task (that is, directly building the application), which means that the make step can be skipped and only two commands can be executed if written on one line:

./configure && make install

Good luck to you! And thanks for reading!

And also other systems have to be installed additional programs. IN operating systems Windows is very simple, as a rule there is a setup.exe installer that helps to install the software. But in Linux, things are a little different. How to install programs in Linux? Now let's consider this question.

Linux has several types of installation packages, and each distribution has its own package format. Fedora, Mandriva, Red Hat, and Suse distributions use standard installation Linux RPM developed by Red Hat. The RPM package file is usually named program_name-version.rpm.

Another very popular format is DEB. Used by Debian, Ubuntu, Knoppix and Mepis. Has a name program_name-version.deb.

And we came to the archives. Usually these are .tar , .tar.gz , .tgz extensions. They should be unpacked, and then installed / compiled.

You need to run the program installation procedure on behalf of the superuser.

Quick navigation

Installing programs on Debian, Ubuntu

There are many tools for working with DEB packages, but the most commonly used is apt-get , which is included in the standard toolset. To install the application, enter the command:

apt-get install packagename

For removing:

apt-get remove packagename

APT keeps a local database of all packages available for installation and links to where to get them. This database needs to be updated from time to time, with the command:

apt-get update

To update obsolete packages (programs) on the computer, type the following commands:

apt-get update ; apt-get upgrade

Installing software on Fedora, Red Hat

A utility similar to APT is yum. Download and install the package from the configured repository, write the command:

yum install packagename

yum remove packagename

The local yum base is not preserved, so there is no need to update. To install updates, use the command:

yum update

Choose something specific to update:

yum update packagename

Installing programs in Mandriva

Mandriva has its own set of package management tools called urpmi. For installation:

urpmi packagename

To delete:

urpme packagename

Update local database with package list:

urpmi. update -a

To install updates:

urpmi --auto-select

Installing programs from archives (tarballs)

For archives compressed with GZIP (gz, gz2, etc.) do this:

tar -xvz f filename

For archives compressed with BZIP (bz, bz2, etc.) a little differently:

tar -xvjf filename

Tar Commands:

  • x - extract files from the archive;
  • v - detailed display of information on the screen;
  • f - Required option. If not specified, Tar will try to use the tape instead of the file;
  • z - process archive compressed with gzip;
  • j - process archive compressed with bzip.

After executing the command, a folder with a name similar to the package name will be created. Then you need to open this created folder with the command:

cd foldername

Further, in the unpacked archive, we read the instructions in the README file, if any. In any case, if the program is compiled as an executable file, then the package will contain a .sh file, usually called install.sh

Material from Bryansk Linux Users Group and www.rm.pp.ru

Each distribution has its own kernel build specifics, and this article focuses on exactly how to do this in Debian Etch. It also reveals the question of how to apply this or that patch to the kernel when it is necessary to support certain functionality or new hardware in your system. The article is intended primarily for more advanced users and there are no guarantees that this method will work as it should and all the described actions and responsibility fall on you.

  1. Note
  2. Applying patches
  3. Kernel configuration
  4. Compiling the kernel
  5. Installing a new kernel
  6. Problems
  7. Links

Note

Two methods for building the kernel will be described. The build variant of the .deb packages that may be installed on your or another system will be described first. The second method is the so-called "traditional" way.

Method one. Building the kernel into .deb packages

Installing the required packages for compiling the kernel

First, let's update the package lists:

# apt-get update

Install the packages we need:

# apt-get install kernel-package libncurses5-dev fakeroot wget bzip2 build-essential

Downloading the kernel sources

Go to the /usr/src directory, go to www.kernel.org and select the desired kernel version. In this case, the version linux-2.6.23.1.tar.bz2 will be considered. Downloading:

# cd /usr/src # wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.23.1.tar.bz2

Unpack the sources and create a symbolic link:

# tar xjf linux-2.6.23.1.tar.bz2 # rm linux (remove previous symlink) # ln -s linux-2.6.23.1 linux # cd /usr/src/linux

Applying patches

Optional and unnecessarily do not do this!

Sometimes drivers or features are required that are not supported in the current kernel, such as virtualization technology or other specifics that are not in the current release. In any case, this is corrected by applying so-called patches (if any).

So let's say you've downloaded the required patch (let's call it patch.bz2 for example) to /usr/src. Apply the downloaded patch to our sources (You should still be in the /usr/src/linux directory):

# bzip2 -dc /usr/src/patch.bz2 | patch -p1 --dry-run # bzip2 -dc /usr/src/patch.bz2 | patch-p1

The first command is just a test and no changes will be applied to the sources. If no errors were returned after the first command, you can run the second command to apply the patch. In no case do not execute the second command if errors were issued after the first one!

This way you can apply patches to kernel sources. For example, there are some features that are only available in the 2.6.23.8 kernel, and the sources did not contain the necessary functionality, but patch-2.6.23.8.bz2 was released. You can apply this patch to 2.6.23 kernel sources, but not 2.6.23.1 or 2.6.23.3, etc. You can read more about this at:

Prefixes (prepatches) - equivalent to alpha releases; patches must be applied to sources of a full previous release with a 3-digit version (for example, patch 2.6.12-rc4 can be applied to sources of version 2.6.11, but not to version 2.6.11.10.)

This means that if we want to build the 2.6.23.8 kernel, we need to download the sources for version 2.6.23 (http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.23.tar.gz) applied in the second way "traditonal" way!

Apply patch-2.6.23.8.bz2 to kernel 2.6.23:

# cd /usr/src # wget http://www.kernel.org/pub/linux/kernel/v2.6/patch-2.6.22.8.bz2 # cd /usr/src/linux # bzip2 -dc /usr/ src/patch-2.6.23.8.bz2 | patch -p1 --dry-run # bzip2 -dc /usr/src/patch-2.6.23.8.bz2 | patch-p1

Kernel Configuration

It's a good idea to use the existing configuration file running kernel and for the new one. Therefore, we copy the existing configuration to /usr/src/linux:

# make clean && make mrproper # cp /boot/config-`uname -r` ./.config # make menuconfig

after which it will load graphic menu kernel configuration. Select "Load an Alternate Configuration File" in the configurator menu and click "OK". Then (if required) make the necessary changes to the kernel configuration by navigating through the menus (kernel configuration details can be found at www.google.com ). When you are done and press "Exit", the question "Do you wish to save your new kernel configuration?" will be asked, we answer in the affirmative "Yes".

Compiling the kernel

Building the kernel is done in just two commands:

# make-kpkg clean # fakeroot make-kpkg --initrd --append-to-version=-cybermind kernel_image kernel_headers

After --append-to-version=, you can write whatever name you want, but it must start with a minus sign (-) and not have spaces.

The process of compiling and building .deb packages can take quite a long time. Everything will depend on the configuration of the kernel and the capabilities of your processor.

Solving the problem with creating initrd.img

Recently, a bug appeared in Debian, consisting in the fact that after installing packages with kernels built in the way described here, the /boot/initrd.img file corresponding to them is not created. To fix an already installed kernel, you will have to create initrd.img manually:

update-initramfs -c -k<полная-версия-ядра>

To solve the problem "for the future" - comment out, as shown, the second of the lines quoted below in the /etc/kernel/postinst.d/initramfs-tools file:

# kernel-package passes an extra arg; hack to not run under kernel-package #[ -z "$2" ] || exit 0

Installing a new kernel

When the kernel build completes successfully, two .deb packages will be created in the /usr/src directory:

# cd /usr/src # ls -l

linux-image-2.6.23.1-cybermind_2.6.23.1-cybermind-10.00.Custom_i386.deb - actual kernel itself and linux-headers-2.6.23.1-cybermind_2.6.23.1-cybermind-10.00.Custom_i386.deb - headers kernels needed to build other modules (for example, when building modules nVidia drivers). Installing them:

# dpkg -i linux-image-2.6.23.1-cybermind_2.6.23.1-cybermind-10.00.Custom_i386.deb # dpkg -i linux-headers-2.6.23.1-cybermind_2.6.23.1-cybermind-10.00.Custom_i386.deb

(These packages can now be installed on another system without the need to build them again.)

Everything, the installation is complete, the bootloader menu, the installation of a new RAM disk and the kernel will be done automatically. It remains only to reboot:

# reboot

Method two. "traditional" way

We carry out all the points described above BEFORE the point "Compiling the kernel".

# make all # make modules_install # make install

As usual, the build may take a long time, depending on the configuration of the kernel and the capabilities of the processor.

The main disadvantage of this method is that if you frequently update kernels, then after a while a large number of them will accumulate and you will want to remove unused ones. To make it easier, you can build the kernel and other files that are installed into the system using the "make modules_install" and "make install" commands into a deb package (or rather, two starting from kernel 2.6.27) like the first method, but we will use here with kernel scripts:

# make all # make deb-pkg

Two .deb files will appear in the directory one level above the source directory. I compiled the kernel in the /usr/src/linux-2.6.27.10 directory and I got files in the /usr/src/ directory

# linux-2.6.27.10_2.6.27.10-1_amd64.deb # linux-firmware-image_2.6.27.10-1_all.deb

The kernel is installed with the command

# dpkg -i linux-2.6.27.10_2.6.27.10-1_amd64.deb

Old kernels can be removed, for example, from synaptic "a

Next steps

The kernel is built and installed, but now you need to create a RAM disk (without which the kernel simply won't boot) and you need to update the GRUB bootloader. To do this, do the following:

# depmod 2.6.23.1 # apt-get install yaird

Install the RAM disk:

# mkinitrd.yaird -o /boot/initrd.img-2.6.23.1 2.6.23.1

Let's update the bootloader easily and painlessly:

# update grub

Everything, the bootloader and the new kernel are ready, it remains only to reboot:

# reboot

Problems

If after a reboot your chosen new kernel does not boot, reboot and select your previous kernel and you can try to do the whole process again to build a working kernel. In this case, do not forget to delete the lines of the non-working kernel in /boot/grub/menu.lst.

It is not uncommon for required packages to be found only in source form, this article describes how to install a package from source.

Unboxing

Programs are usually distributed in packaged archives, these are files with extensions

.tar.gz (sometimes .tgz) .tar.bz2

You need to understand the difference between an archiver and a packer.

The program is used to archive directories and files. tar; the result of its work is a file with the extension .tar. Roughly speaking, this is a copy file system- directories and files with their attributes and access rights, placed in one file.

This file will be slightly larger in size than the total size of the files that were archived. Therefore (and maybe for another reason) packers are used - programs that allow you to reduce the file size without losing data.

Program tar can unpack, so no need to call gunzip, or you can just tell the program tar that the file needs to be unpacked first. For example, the command

tar-xvf< some_app_name>.tar.gz

immediately unpack and unzip. The difference between files with extensions

.tar.gz

.tar.bz2

only that different packers were used, the program tar determines the compression method automatically and no additional options are required in this case.

After unpacking, you need to go to the resulting directory, all the commands described below are executed in the directory with the source texts of the package.

cd< имя_пакета>*

Building a package

To build programs in GNU/Linux, one uses (mostly) the program make, which runs instructions from Makefile, but since there are many GNU / Linux distributions, and they are all different, in order to compile the program, you need to separately write the paths for each distribution, where libraries and header files lie. Programmers cannot study each distribution and for each separately create Makefile. Therefore, they came up with configurators who “study” the system, and in accordance with the knowledge gained, create Makefile. But they did not stop at the configurator and came up with configurators of configurators ... they stopped there

To build, we need compilers: they are written in the dependencies of the package build-essential, so it's enough to install it with all dependencies. Still needed autoconf And automake.

So, in order to build something from the source, you must first build the configurator; how to build the configurator is described in the configure.in file. To assemble the configurator, you must run

./bootstrap ./autogen.sh

If there are no such scripts in the archive, then you can execute the following commands in sequence:

aclocal autoheader automake --gnu --add-missing --copy --foreign autoconf -f -Wall

All these commands use the file configure.in. After executing these commands, a file will be created configure. After that, you need to run the configurator to check the availability of all dependencies, as well as install additional build options (if possible) and view the installation result (optional - may not be)

./ configure

The configurator will build a Makefile based on the knowledge gained and the file makefile.am. You can pass to the configurator the options provided in the program sources, which allow you to enable / disable certain features of the program, usually you can find out about them with the command

./ configure --help

There is also a set of standard options, like

Prefix=

Which specifies which directory to use for installation. For Ubuntu usually

--prefix=/usr --prefix=/usr/local

WITHOUT slash at the end! Now you can start the process of building the program itself with the command

make

Enough privileges to assemble ordinary user. The end of the assembly can be considered the moment when the commands in the console cease to be "chaotically" executed and there will be no word error. Now everything is compiled and ready for installation.

Installation

The effort spent on Correct installation later, they will more than pay off in case of removal or updating of the installed software.

Correct installation (Option No. 1)

Installation using the utility checkinstall. To install, run

sudo apt-get install checkinstall

Minus this method: checkinstall understands not all sources, since the author of the program can write special installation scripts and checkinstall will not understand them.

To create and install a deb package, you need to run

sudo checkinstall

Correct installation (Option No. 2)

Quick creation of a deb-package "manually".

The main difference from previous method is that in this case you create the package manually and keep track of all the changes you make. This method is also suitable for you if the sources do not support building the package with checkinstall.

    We install to a temporary directory, where we get the entire set of installed files:

fakeroot make install DESTDIR =`pwd`/tempinstall

    Let's create the DEBIAN directory in the "package root" and put in DEBIAN/conffiles a list of all files that should get into /etc:

cd tempinstall mkdir DEBIAN find etc | sed "s/^/\//" > DEBIAN/ conffiles

    Then we create a DEBIAN/control file with the following content:

Package: package_name Version: 1.2.3 Architecture: amd64/i386/armel/all Maintainer: You can enter your name, you can rubbish, but if left empty, then dpkg will swear Depends: Here you can enter a list of packages separated by commas. Priority: optional Description: You also need to enter something so that no warning is thrown

    If necessary, you can also create preinst, postinst, prerm and postrm scripts there.

    We create a deb package, for which we execute:

dpkg -b tempinstall

    We get the output tempinstall.deb, which we install

sudo dpkg -i tempinstall.deb

Installation (option No. 3)

Wrong installation

The disadvantage of this method is that if you install directly via make install, then you most likely will not be able to remove or update the package normally. Moreover, installing a new version over the old one will most likely overwrite your changes in the configs. make install does exactly what it's told - it installs the files in the right places, ignoring the fact that something is already there. After this process, it is impossible to obtain absolutely no information about what was put and where in a digestible form. Sometimes, of course, the Makefile supports the uninstall action, but this is not so common, and it's not a fact that it works correctly. In addition, you will need to keep the unpacked tree of sources and build rules for uninstallation.

To install, you need to run

sudo make install

To remove a package installed in this way, you need to execute it in the root directory of the program sources (where you ran make install).

sudo make uninstall

Mistakes

Often at the configuration stage, the configurator reports that this or that library is missing. The name of the library it reports does not always match the name of the package in Ubuntu. From my own experience, I can advise you to search Synaptic for the desired package, excluding the lib prefix, if there are several packages that differ in the -dev prefix in the name, then you need to install the -dev package (usually it pulls a non-dev package). You can also search using http://packages.ubuntu.com/ by entering the name of the library in the package content search, similarly, if dev and non-dev are found, both are needed. Or just search on Google.

Required Software

Packages with the letters mm at the end of the description are packages for C++ programs. The list is for bmpx, but will work for almost any GTK2/Gnome program. So if you can’t compile, then look at this list and check with what you have installed.

Compile:runtime:
Xlibx11-devlibx11-6
GlibMMlibglibmm-2.4-devlibglibmm-2.4-1c2a
GTK+libgtk2.0-dev,gtk-doc-toolslibgtk2.0-0
GTKMMlibgtkmm-2.4-devlibgtkmm-2.4-1c2a
Gladelibglade2-devlibglade2-0
GladeMMlibglademm-2.4-devlibglademm-2.4-1c2a
XMLlibxml2-devlibxml2
XML++libxml++2.6-devlibxml++2.6c2a
DBuslibdbus-1-dev,libdbus-glib-1-devlibdbus-1-2,libdbus-glib-1-2
Alsalibasound2-devlibasound2
HALlibhal-dev,libhal-storage-devlibhal1,libhal-storage1
Gaminlibgamin-devlibgamin0
neonlibneon25-devlibneon25
TagLiblibtagc0-devlibtagc0
Startup Notifylibstartup-notification0-devlibstartup-notification0
boostlibboost-dev,libboost-filesystem-devlibboost-filesystem1.33.1
MusicBrainzlibmusicbrainz4-devlibmusicbrainz4c2a
Gstreamerlibgstreamer0.10-dev,libgstreamer-plugins-base0.10-devlibgstreamer0.10-0,libgstreamer-plugins-base0.10-0


tell friends