How to build git with static linking? - linux

I downloaded git source from https://github.com/git/git as a zip file.
I extracted it into /home/Desktop/denis/git (using Ubuntu).
Now the tutorial here says that I should run
./configure --prefix=/home/denis/git-static CFLAGS="${CFLAGS} -static"
from the above mentioned folder as a step for building git.
But the git source does not appear to have a configure file in it's root folder which I can run (only configure.ac, which I suspect is not what I'm looking for).
What am I missing here? How to build git manually?
I'm doing this because I'm trying to get git working on a shared hosting server where I'm not able to install git.

The other answers did not work for me. Perhaps they will for others. What did work for me was:
Get the source code
Make a target directory
Enter the source directory
Configure
Build
Install
Use the following commands:
git clone git#github.com:git/git.git
mkdir git-static
cd git
./configure prefix=/path/to/git-static/ CFLAGS="${CFLAGS} -static"
make
make install
This will leave you with a few folders in the git-static directory, but the executable is statically linked. It is also substantially bigger than usual (maybe 1.5 MB bigger).

Read the INSTALL file in the root folder of the unzipped file, it seems there is some useful instruction in it, what I suspect:
Alternatively you can use autoconf generated ./configure script to
set up install paths (via config.mak.autogen), so you can write instead
$ make configure ;# as yourself
$ ./configure --prefix=/usr ;# as yourself
$ make all doc ;# as yourself
# make install install-doc install-html;# as root
or just simply:
$ make prefix=/usr all doc info ;# as yourself
# make prefix=/usr install install-doc install-html install-info ;# as root

Related

Is it possible to generate linux .rpm packages from flutter linux app?

As far as I know, Flutter for linux app only targets snap packaging format.
Is it possible to generate .rpm and .deb (cross-linux platform) software packages from the flutter build?
Kindly post any help on how to package a flutter-linux app as RPM package
Building RPMs and DEBs is doable, but a pretty involved process. I will try to outline the basic process for RPM's as best as I can. The process of making a DEB is mostly the same with a few differences. I will stick to RPM's for now.
The main thing which is a pain is that to build packages you need specific tools which are only available on the distros. So if you want to do this cross platform (generate a RPM on a ubuntu machine for example) we need to use Docker.
Create a Dockerfile which in which we will install the rpm-build package which contains all tools to build RPMs.
FROM centos:7
RUN yum install -y -q rpm-build
Build this dockerfile and remember the docker image, we will need it later.
Execute the following command mkdir -p build/{BUILD,RPMS,SOURCES,SPECS,SRPMS}. This will create the directory structure required for rpmbuild
Create a .spec file, this file is a config file for the rpmbuild command and place it in the build/SPECS directory. The contents of this file are very specific to the what the package has to do. RPMs are very flexible and can do lots of stuff ranging from just copying files to running complex bash scripts on the target machine to perform compilation on the target machine and perform complex installations. Here are some guides which I found useful: package guide, fedora guide, and redhat guide.
Download the files you want to package, often they are distributed as tarballs and place it in the build/SOURCES directory.
Now we can execute the following command docker run --rm -v $(pwd)/build:/rpmbuild {name of image} /bin/bash -c "cd /rpmbuild && rpmbuild --define '_topdir /rpmbuild' -ba SPECS/flutter.spec"
I will break the command down.
docker run --rm -v $(pwd)/build:/rpmbuild {name of image} - we start a container from the image we created earlier, and mount the build dir in which our .spec and .tar.gz are located so the container can see them. --rm cleans up the container after we are done since we don't need it after the first command.
/bin/bash -c - this is a trick since we need to execute 2 command inside the docker container, if we don't do this our shell will thing the && is meant after the docker command and not passed to the container.
"cd /rpmbuild && rpmbuild --define '_topdir /rpmbuild' -ba SPECS/flutter.spec" - move to the mounted build directory and build the RPM package. the -ba option tells rpmbuild to build both the binary and source packages in case you want the source package as well.
If all went well your should now have an .rpm file in the build/RPMS and a source package in the build/SRPMS directory.
For DEB the process is almost the same, except you need a debian or ubuntu docker image, you use the dpkg-deb command to build and you need a control file instead of a .spec file(same purpose different format)
I will also go over some of the key parts of building rpm packages for flutter applications in case the previous answer was ambiguous.
I have already written an article going into details but here I will only highlight the key parts. You can find the article here
Also for simplicity of explanation, I will be using cool-app as an example throughout this post.
1- Run flutter build linux to get the Linux build inside the build folder in your project root directory.
2- Copy your bundle folder someplace else and there, rename it according to app-name-version semantic. e.g. cool-app-1.0.0
3- Create a .desktop file. e.g. cool-app.desktop will look like the following :
[Desktop Entry]
Name=My Cool App
Comment=A cool app that does everything
Exec=/usr/bin/cool-app/cool-app
Icon=/usr/bin/cool-app/data/flutter_assets/assets/icon.svg
Terminal=false
Type=Application
Categories=Utility;
change the properties accordingly and place the .desktop file inside cool-app-1.0.0 directory
4- run mkdir -p rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS} in your home directory.
5- copy the cool-app-1.0.0 directory to ~/rpmbuild/SOURCES.
Due to a problem that as the time of writing this still persists, the rpath for lib*_plugin.so files point to user's build tree path which results in rpmbuild failure.
6- Run patchelf --print-rpath * inside cool-app-1.0.0/lib and check the output. If the output contains a path from your home directory, run patchelf --set-rpath '$ORIGIN' * to fix the rpaths, then check again. now all paths must be $ORIGIN. (This was the way I was able to fix it, not sure if it's the best solution)
You can check this github issue for further information.
7- cd into ~/rpmbuild/SOURCES and run tar --create --file cool-app-1.0.0.tar.gz cool-app-1.0.0 to create a tar.gz file.
8- Create a file named cool-app.spec inside ~/rpmbuild/SPECS directory.
Sample cool-app.spec file :
Name: cool-app
Version: 1.0.0
Release: 1%{?dist}
Summary: Very cool app
BuildArch: x86_64
URL: https://github.com/CoolDev/cool-app
License: GPLv3
Source0: %{name}-%{version}.tar.gz
Requires: bash
%description
A very cool app that does everything
%prep
%setup -q
%install
rm -rf $RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT/%{_bindir}/%{name}
cp %{name} $RPM_BUILD_ROOT/%{_bindir}/%{name}
cp -R lib $RPM_BUILD_ROOT/%{_bindir}/%{name}
cp -R data $RPM_BUILD_ROOT/%{_bindir}/%{name}
desktop-file-install %{name}.desktop
%clean
rm -rf $RPM_BUILD_ROOT
%files
%{_bindir}/%{name}
/usr/share/applications/
You could use the same template and only change Name,Version,Summery,Release,BuildArch,URL,License,%description and you will most likely be fine.
I went over the spec file in more detail in my article mentioned in the beginning of this post.
9- run rpmbuild --bb cool-app.spec to get your rpm file inside ~/rpmbuild/RPMS directory.

How do I "install" a program once I compile it, so I can run it from the command line?

Archlinux.
I downloaded mtools, which includes mcopy, which is what I'm after. The instructions in the INSTALL file say do this:
# ./configure
# make
These worked fine, now I have a bunch of .o files and of course executables.
What do I need to do, so I can just type
# mcopy
and have it run? Since I don't have it "installed" right now, doing that just says
-bash: mcopy: command not found
The usual linux build sequence is
./configure
make
make check
sudo make install
make check attempts to validate if the build took place correctly; not all Makefiles have it but many do. Note you will need sudo make install to do the install in the usual system directories if you are not root.
You can determine which of these options is available for your particular Makefile by
cat Makefile
and reading the labels on the left of the file.
You could create a symbolic link to the application in your /usr/bin folder like
ln -s /fullpath/to/app /usr/bin/aliasnameforapp
Then you can simple call aliasnameforapp from anywhere.

How to create a "configure" file?

Recently I downloaded a file using the following link
git clone git://github.com/mapserver/mapcache.git
Inside the downloaded mapcache folder I can not find a configure file to do "./configure". But the installation help file tell:
Unix compilation instructions
If you are using a git clone rather than a tarball distribution, you
must first run autoconf in the root directory, to create the configure
file from configure.in:
$ autoconf
For unix users, the compilation process should resume to:
$ ./configure
$ make
(as root)
make install-module
The installation script takes care of putting the built module in the
apache module directory.
To do ./configure there should be a configure file isn't it? Please show me how to make one to get rid of this problem.
maintainer speaking ...
mapcache and mapserver are switching to cmake for the next release and the docs for the master branch need updating. You can either use the branch-1-0 branch to continue using autoconf builds, or use cmake with master:
$ mkdir build
$ cd build
$ cmake ..
$ make
$ sudo make install
The help file tells you exactly what you need to do
If you are using a git clone rather than a tarball distribution, you must first run autoconf in the root directory, to create the configure file from configure.in
If you don't already have autoconf installed you'll need to install it in the normal way for your distribution.
The repository seems out of sync with the documentation
there is no configure.in as mentioned in the INSTALL file (nowhere not only in the root directory)
there is just a Makefile.vc file for MSVC++
You should contact the maintainer

How to recompile asterisk in CentOS 5.8?

I already installed asteriskNow 2.0 ISO, thus after system installation, i've already have built-in asterisk within CentOS. I do not need to download source package and compile the source files. But right now, i have an situation that requires to recompile asterisk again.
I checked it out the installation tutorial which needs to go to the asterisk source directory to execute following commands:
# make clean
# ./configure
# make menuselect
# make install
# make samples
My questions : Is it the asterisk source directory means the directory which has asterisk installation files? But in my case, i do not download and compile the asterisk source ever.What should i do?
I asked myself: It needs to download source from and execute the following commands:
wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-1.8.17.0.tar.gz
tar xzf asterisk-1.8.17.0.tar.gz
cd asterisk-1.8.17.0
./configure
make
make install

how to use "make mrproper " command? i am working on Linux From Scratch

I am trying to build Linux From Scratch and I have reached till this part : linux headers
Make sure there are no stale files and dependencies lying around from previous activity:
make mrproper
I don't understand: in which directory should I run this command? In one of these?
$LFS/sources/gcc-build
$LFS/sources/gcc-4.4.3
Please Help!
No, you should run that (an the following) in the directory where you unpacked the kernel source tarball.
That comes after gcc use
cd $LFS/sources
tar xvjf linux*
cd linux*
make mproper
make headers_check
make INSTALL_HDR_PATH=dest headers_install
cp -rv dest/include/* /tools/include
cd $LFS/sources tells it to change to the sources directory.
tar xvjf linux* tells it to untar the lunix api headers directory (the j in xvjf might be a capital)
cd linux* tells it to go to the untared directory
make mproper is a special use of the make command to specially make this directory
make headers_check
make INSTALL_HDR_PATH=dest headers_install
cp -rv dest/include/* /tools/include tells it to install and test the package
Running make mrproper or make distclean returns the kernel source tree to its unconfigured state. This means you loose your .config file. You will need to create a new .config file before compiling the kernel.

Resources