Here is an attempt to explain the components of the extension:
Makefile:
Makefile provides a way to compile your C code. Postgres provides an infrastructure called PGXS for building the extensions against installed Postgres server. More of this can be found in official documentation[1].
Control file:
It specifies some properties/metadata about the extension, like version, comments, directory etc. Official documentation[2]
SQL Script:
This file should be of format extension—version.sql which will have the functions that are either pure SQL functions, or interfaces for your C functions and other SQL objects to assist your functions etc. This will be executed internally by “CREATE EXTENSION” command.
C code:
Your C code is real implementation of your extension. Here you can have C implementations of SQL interface functions your declared in your .sql script file, register callbacks e.g. things you want to do post parse, before execution of a query etc. The filename can be anything but you should have PG_MODULE_MAGIC included in your C file.
Using this infrastructure one can simply do make, make install and then “CREATE EXTENSION” command to create objects. This helps keeping track of all the extension objects together, create them at once, and drop once with “DROP EXTENSION” command. Here[3] is complete documentation for extension.
Regards,
Jeevan Ladhe