Skip to content

Commit

Permalink
Clean up and document Makefile.
Browse files Browse the repository at this point in the history
  • Loading branch information
dwsteele committed Feb 18, 2018
1 parent 3eed4bb commit 27678f6
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 63 deletions.
155 changes: 93 additions & 62 deletions src/Makefile
@@ -1,67 +1,98 @@
####################################################################################################################################
# pgBackRest Makefile
####################################################################################################################################

####################################################################################################################################
# Compile options
####################################################################################################################################
CC=gcc
CFLAGS=-I. -Wfatal-errors -Wall -Wextra -Wwrite-strings -Wno-clobbered -std=c99 -O2 -funroll-loops -ftree-vectorize \
`perl -MExtUtils::Embed -e ccopts`
LDFLAGS=`perl -MExtUtils::Embed -e ldopts`
DESTDIR=

pgbackrest: \
command/archive/push/push.o \
command/help/help.o \
command/command.o \
common/error.o \
common/exit.o \
common/ini.o \
common/log.o \
common/memContext.o \
common/regExp.o \
common/time.o \
common/type/buffer.o \
common/type/keyValue.o \
common/type/list.o \
common/type/string.o \
common/type/stringList.o \
common/type/variant.o \
common/type/variantList.o \
common/wait.o \
config/config.o \
config/define.o \
config/load.o \
config/parse.o \
perl/config.o \
perl/exec.o \
storage/helper.o \
storage/storage.o \
main.o
$(CC) $(CFLAGS) -o pgbackrest \
command/archive/push/push.o \
command/help/help.o \
command/command.o \
common/error.o \
common/exit.o \
common/ini.o \
common/log.o \
common/memContext.o \
common/regExp.o \
common/time.o \
common/type/buffer.o \
common/type/keyValue.o \
common/type/list.o \
common/type/string.o \
common/type/stringList.o \
common/type/variant.o \
common/type/variantList.o \
common/wait.o \
config/config.o \
config/define.o \
config/load.o \
config/parse.o \
perl/config.o \
perl/exec.o \
storage/helper.o \
storage/storage.o \
main.o \
$(LDFLAGS)

# Compile using C99 standard
CSTD = -std=c99

# Compile optimizations
COPT = -O2

# Locations of header files
CINCLUDE = -I.

# Compile warnings
CWARN = -Wfatal-errors -Wall -Wextra -Wwrite-strings -Wno-clobbered

# Automatically generate Perl compile options for the local system
CPERL = `perl -MExtUtils::Embed -e ccopts`

# Extra compile options to be set by caller
CEXTRA =

# Concatenate options for easy usage
CFLAGS = $(CINCLUDE) $(CSTD) $(COPT) $(CWARN) $(CPERL) $(CEXTRA)

####################################################################################################################################
# Link options
####################################################################################################################################
# Automatically generate Perl linker options for the local system
LDPERL = `perl -MExtUtils::Embed -e ldopts`

# Extra linker options to be set by caller
LDEXTRA =

# Concatenate options for easy usage
LDFLAGS = $(LDPERL) $(LDEXTRA)

####################################################################################################################################
# Install options
####################################################################################################################################
# Modify destination install directory
DESTDIR =

####################################################################################################################################
# List of required source files. main.c should always be listed last and the rest in alpha order.
####################################################################################################################################
SRCS = \
command/archive/push/push.c \
command/help/help.c \
command/command.c \
common/error.c \
common/exit.c \
common/ini.c \
common/log.c \
common/memContext.c \
common/regExp.c \
common/time.c \
common/type/buffer.c \
common/type/keyValue.c \
common/type/list.c \
common/type/string.c \
common/type/stringList.c \
common/type/variant.c \
common/type/variantList.c \
common/wait.c \
config/config.c \
config/define.c \
config/load.c \
config/parse.c \
perl/config.c \
perl/exec.c \
storage/helper.c \
storage/storage.c \
main.c

# Create obj list from source list
OBJS=$(SRCS:.c=.o)

####################################################################################################################################
# Compile and link
####################################################################################################################################
pgbackrest: $(OBJS)
$(CC) -o pgbackrest $(OBJS) $(LDFLAGS)

.c.o:
$(CC) $(CFLAGS) -c $< -o $@

####################################################################################################################################
# Installation. DESTDIR can be used to modify the install location.
####################################################################################################################################
install: pgbackrest
sudo install -d $(DESTDIR)/usr/bin
sudo install -m 755 pgbackrest $(DESTDIR)/usr/bin
2 changes: 1 addition & 1 deletion test/test.pl
Expand Up @@ -522,7 +522,7 @@ =head1 SYNOPSIS
}

executeTest(
"docker exec -i test-build make --silent --directory ${strBuildPath}",
"docker exec -i test-build make --silent --directory ${strBuildPath} CEXTRA=-g",
{bShowOutputAsync => $bLogDetail});

executeTest(
Expand Down

0 comments on commit 27678f6

Please sign in to comment.