PostgreSQL Configure Make and Make install Explained

What does the below code snippet really mean in PostgreSQL while installing software?

./configure
make
make install

We will understand it in this post.

PostgreSQL is written in C, so installing PostgreSQL software is nothing but compiling and running all the C-Programs in your source code.

We will do that with an example.,

How to compile and run a C program in Linux?

  1. Create a program called first.c

2. To compile this program, enter:

The above command will compile first.c program and creates an executable file called first.o.

3. To run the first.o just do ./first.o

We can also execute the same program using make and makefile and make install.

How to use Make and Make install to run a C Program

Make is a general-purpose workflow program, usually used for compilation. But it can be used for anything.

When you do something like “make”, the make program executes a rule named “all“, by default from a file in the current directory named “Makefile”. This rule usually calls the compiler to compile some source code into binaries.

Makefile syntax

all:

{your compile code goes here}

install:

{your install code goes here}

make will open Makefile file and executes all part in it., i.e., it does exactly what “gcc first.c -o first.o” does above.

When you do “make install”, the make program takes the binaries from the previous step and copies them into some appropriate locations so that they can be accessed.

make install will open Makefile file and executes install part in it i.e., it does exactly what “./first.o” does above.

Let’s see how to use makefile with an example

  1. Create a Makefile with “all” and “install” fields.

I just created a Makefile in vi editor with all: and install: fields and added the commands that I used earlier.

Now, do make and make install.

2. when you run make, it will look into Makefile file and run “all” section of the file.

3. In the above step make created first.o and to run that, do make install.

Want to add a display message to your Makefile?

You can do that with @echo.

Let me modify the Makefile

Now run make.

Now that we understood how to run a program in Linux. We can do that with “./ProgramName”

Make and Makefile is really helpful if you have a bunch of C programs and quite a few rules to make.

write and run a simple shell script called configure.

So what does the below snipped do in PostgreSQL?

Bringing up all the above three things together,

./configure
make
make install

configure: All the dependency check is written in configure, so look at the configure file with vi editor and try to read it if possible.

make: You will be having a makefile in the software directory which redirects you to src directory where you have all the programs, your make will compile all of them in the location specified in the location chosen in configure option.

make install: will run them.

And, that is the reason why you need GNU Make 3.80 or above and GCC installed on your Linux machine to install PostgreSQL.

Learnt something new?  Please rate the post [ratings]

Words from postgreshelp

Thank you for giving your valuable time to read the above information. I hope the content served your purpose in reaching out the blog.
Suggestions for improvement of the blog are highly appreciable. Please contact us for any information/suggestions/feedback.

If you want to be updated with all our articles

please follow us on Facebook Twitter
Please subscribe to our newsletter.

 

 

Leave a Reply