RefLib

Reference library for AI

Back

postgresql_16:4.2.3.4 configure Environment Variables

PostgreSQL 16 > Server Administration > Installation from Source Code > Building and Installation with Autoconf and Make > configure Environment Variables

In addition to the ordinary command-line options described above, configure responds to a number of environment variables. You can specify environment variables on the configure command line, for example: ./configure CC=/opt/bin/gcc CFLAGS='-O2 -pipe' In this usage an environment variable is little different from a command-line option. You can also set such variables beforehand: export CC=/opt/bin/gcc export CFLAGS='-O2 -pipe' ./configure This usage can be convenient because many programs' configuration scripts respond to these variables in similar ways.

The most commonly used of these environment variables are CC and CFLAGS. If you prefer a C compiler different from the one configure picks, you can set the variable CC to the program of your choice. By default, configure will pick gcc if available, else the platform's default (usually cc). Similarly, you can override the default compiler flags if needed with the CFLAGS variable.

Here is a list of the significant variables that can be set in this manner: BISON Bison program CC C compiler CFLAGS options to pass to the C compiler CLANG path to clang program used to process source code for inlining when compiling with --with-llvm CPP C preprocessor CPPFLAGS options to pass to the C preprocessor CXX C++ compiler CXXFLAGS options to pass to the C++ compiler DTRACE location of the dtrace program DTRACEFLAGS options to pass to the dtrace program FLEX Flex program LDFLAGS options to use when linking either executables or shared libraries LDFLAGS_EX additional options for linking executables only LDFLAGS_SL additional options for linking shared libraries only LLVM_CONFIG llvm-config program used to locate the LLVM installation MSGFMT msgfmt program for native language support PERL Perl interpreter program. This will be used to determine the dependencies for building PL/Perl. The default is perl. PYTHON Python interpreter program. This will be used to determine the dependencies for building PL/Python. If this is not set, the following are probed in this order: python3 python. TCLSH Tcl interpreter program. This will be used to determine the dependencies for building PL/Tcl. If this is not set, the following are probed in this order: tclsh tcl tclsh8.6 tclsh86 tclsh8.5 tclsh85 tclsh8.4 tclsh84. XML2_CONFIG xml2-config program used to locate the libxml2 installation

Sometimes it is useful to add compiler flags after-the-fact to the set that were chosen by configure. An important example is that gcc's -Werror option cannot be included in the CFLAGS passed to configure, because it will break many of configure's built-in tests. To add such flags, include them in the COPT environment variable while running make. The contents of COPT are added to both the CFLAGS and LDFLAGS options set up by configure. For example, you could do make COPT='-Werror' or export COPT='-Werror' make

Note

If using GCC, it is best to build with an optimization level of at least -O1, because using no optimization (-O0) disables some important compiler warnings (such as the use of uninitialized variables). However, non-zero optimization levels can complicate debugging because stepping through compiled code will usually not match up one-to-one with source code lines. If you get confused while trying to debug optimized code, recompile the specific files of interest with -O0. An easy way to do this is by passing an option to make: make PROFILE=-O0 file.o.

>

The COPT and PROFILE environment variables are actually handled identically by the PostgreSQL makefiles. Which to use is a matter of preference, but a common habit among developers is to use PROFILE for one-time flag adjustments, while COPT might be kept set all the time.

Back