Friday, 27 January 2017

How to install curl from source on Ubuntu


NOTE: curl has already been installed on a system via package manager:


$ which curl

/usr/bin/curl


/usr/bin directory contains user applications installed via package (distribution) manager.

Instructions


Go to curl download page and download the latest source code. At the time of writing, it was curl-7.52.1.tar.gz.


$ wget https://curl.haxx.se/download/curl-7.52.1.tar.gz

--2017-01-26 00:00:29-- https://curl.haxx.se/download/curl-7.52.1.tar.gz
Resolving curl.haxx.se (curl.haxx.se)... 2a00:1a28:1200:9::2, 80.67.6.50
Connecting to curl.haxx.se (curl.haxx.se)|2a00:1a28:1200:9::2|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 3504621 (3.3M) [application/x-gzip]
Saving to: ‘curl-7.52.1.tar.gz’

curl-7.52.1.tar.gz 100%[===================>] 3.34M 265KB/s in 13s

2017-01-26 00:00:43 (260 KB/s) - ‘curl-7.52.1.tar.gz’ saved [3504621/3504621]



Unpack compressed file with tar:


$ tar -xvf curl-7.52.1.tar.gz

curl-7.52.1/
curl-7.52.1/projects/
curl-7.52.1/projects/README
curl-7.52.1/projects/checksrc.bat
(...)
curl-7.52.1/Makefile.am
curl-7.52.1/Makefile.in
curl-7.52.1/buildconf.bat



Meaning of used tar parameters:
-x = extract
-v = verbose
-f <archive_file>

Now perform standard Unix-style build & install steps (configure - make - make install).

configure verifies that compiler and all dependencies for build are present at the system and adjusts build configuration if necessary. It uses Makefile template file (Makefile.in) in order to create Makefile file which contains instructions for building and installation:


$ ./configure

checking whether to enable maintainer-specific portions of Makefiles... no
checking whether make supports nested variables... yes
(...)
configure: amending tests/server/Makefile
configure: amending tests/libtest/Makefile
configure: amending docs/examples/Makefile
configure: Configured to build curl/libcurl:

curl version: 7.52.1
Host setup: x86_64-pc-linux-gnu
Install prefix: /usr/local
Compiler: gcc
SSL support: no (--with-{ssl,gnutls,nss,polarssl,mbedtls,cyassl,axtls,winssl,darwinssl} )
SSH support: no (--with-libssh2)
zlib support: enabled
GSS-API support: no (--with-gssapi)
TLS-SRP support: no (--enable-tls-srp)
resolver: default (--enable-ares / --enable-threaded-resolver)
IPv6 support: enabled
Unix sockets support: enabled
IDN support: no (--with-{libidn2,winidn})
Build libcurl: Shared=yes, Static=yes
Built-in manual: enabled
--libcurl option: enabled (--disable-libcurl-option)
Verbose errors: enabled (--disable-verbose)
SSPI support: no (--enable-sspi)
ca cert bundle: /etc/ssl/certs/ca-certificates.crt
ca cert path: no
ca fallback: no
LDAP support: no (--enable-ldap / --with-ldap-lib / --with-lber-lib)
LDAPS support: no (--enable-ldaps)
RTSP support: enabled
RTMP support: no (--with-librtmp)
metalink support: no (--with-libmetalink)
PSL support: no (libpsl not found)
HTTP2 support: disabled (--with-nghttp2)
Protocols: DICT FILE FTP GOPHER HTTP IMAP POP3 RTSP SMTP TELNET TFTP



make executes build commands from Makefile and builds the application:


$ make

Making all in lib
make[1]: Entering directory '/home/bojan/Downloads/curl-7.52.1/lib'
make all-am
make[2]: Entering directory '/home/bojan/Downloads/curl-7.52.1/lib'
CC libcurl_la-file.lo
CC libcurl_la-timeval.lo
(...)
make[1]: Entering directory '/home/bojan/Downloads/curl-7.52.1'
make[1]: Nothing to be done for 'all-am'.
make[1]: Leaving directory '/home/bojan/Downloads/curl-7.52.1'



make install executes installation commands from Makefile. It copies binaries to a /usr/local/bin - a directory which contains locally built user applications (not those installed via package manager):


$ sudo make install

Making install in lib
make[1]: Entering directory '/home/bojan/Downloads/curl-7.52.1/lib'
make[2]: Entering directory '/home/bojan/Downloads/curl-7.52.1/lib'
/bin/mkdir -p '/usr/local/lib'
/bin/bash ../libtool --mode=install /usr/bin/install -c libcurl.la '/usr/local/lib'
(...)
make[1]: Entering directory '/home/bojan/Downloads/curl-7.52.1'
make[2]: Entering directory '/home/bojan/Downloads/curl-7.52.1'
/bin/mkdir -p '/usr/local/bin'
/usr/bin/install -c curl-config '/usr/local/bin'
/bin/mkdir -p '/usr/local/lib/pkgconfig'
/usr/bin/install -c -m 644 libcurl.pc '/usr/local/lib/pkgconfig'
(...)
/bin/mkdir -p '/usr/local/share/man/man1'
/usr/bin/install -c -m 644 curl.1 curl-config.1 '/usr/local/share/man/man1'
make[6]: Leaving directory '/home/bojan/Downloads/curl-7.52.1/docs'
make[5]: Leaving directory '/home/bojan/Downloads/curl-7.52.1/docs'
make[4]: Leaving directory '/home/bojan/Downloads/curl-7.52.1/docs'
make[3]: Leaving directory '/home/bojan/Downloads/curl-7.52.1'
make[2]: Leaving directory '/home/bojan/Downloads/curl-7.52.1'
make[1]: Leaving directory '/home/bojan/Downloads/curl-7.52.1'



We can verify that curl is indeed installed:


$ which curl

/usr/local/bin/curl



We can also verify its version, protocols and features this (custom) build supports:


$ curl --version
curl 7.52.1 (x86_64-pc-linux-gnu) libcurl/7.52.1 zlib/1.2.8
Protocols: dict file ftp gopher http imap pop3 rtsp smtp telnet tftp
Features: IPv6 Largefile libz UnixSockets



References:


The magic behind configure, make, make install
/usr/bin vs /usr/local/bin on Linux

2 comments:

Alia parker said...

Localization and Interpretation Organization. To get a Professional story localization agency service in all major dialects sandvox will be the best choice for you. Visit the website or call then to get the service.

micheal pan said...

BE SMART AND BECOME RICH IN LESS THAN 3DAYS....It all depends on how fast 
you can be to get the new PROGRAMMED blank ATM card that is capable of
hacking into any ATM machine,anywhere in the world. I got to know about 
this BLANK ATM CARD when I was searching for job online about a month 
ago..It has really changed my life for good and now I can say I'm rich and 
I can never be poor again. The least money I get in a day with it is about 
$50,000.(fifty thousand USD) Every now and then I keeping pumping money 
into my account. Though is illegal,there is no risk of being caught 
,because it has been programmed in such a way that it is not traceable,it 
also has a technique that makes it impossible for the CCTVs to detect 
you..For details on how to get yours today, email the hackers on : (
atmmachinehackers1@gmail.com ). Tell your 
loved once too, and start to live large. That's the simple testimony of how 
my life changed for good...Love you all ...the email address again is ;
atmmachinehackers1@gmail.com