374 lines
10 KiB
Makefile
Raw Normal View History

# Copyright (C) 2011 Red Hat, Inc. All rights reserved.
#
# This file is part of the thin-provisioning-tools source.
#
# thin-provisioning-tools is free software: you can redistribute it
# and/or modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation, either version 3 of
# the License, or (at your option) any later version.
#
# thin-provisioning-tools is distributed in the hope that it will be
# useful, but WITHOUT ANY WARRANTY; without even the implied warranty
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with thin-provisioning-tools. If not, see
# <http://www.gnu.org/licenses/>.
2013-03-22 12:19:31 +00:00
V=@
2011-12-06 15:47:24 +00:00
PROGRAMS=\
bin/pdata_tools
ifeq ("@TESTING@", "yes")
TESTLIBS=\
lib/libft.so
endif
.PHONY: all
all: $(PROGRAMS) $(TESTLIBS)
2011-08-31 14:01:48 +01:00
include contrib/Makefile
SOURCE=\
base/output_file_requirements.cc \
2014-08-27 14:01:31 +01:00
base/application.cc \
base/base64.cc \
base/disk_units.cc \
2013-11-19 10:23:35 +00:00
base/endian_utils.cc \
base/error_state.cc \
base/error_string.cc \
2016-01-20 06:58:59 +00:00
base/grid_layout.cc \
2020-06-12 18:33:49 +08:00
base/io_generator.cc \
base/file_utils.cc \
2014-08-05 11:47:57 +01:00
base/progress_monitor.cc \
2015-09-03 13:02:29 +01:00
base/rolling_hash.cc \
base/xml_utils.cc \
2014-08-27 14:01:31 +01:00
block-cache/block_cache.cc \
2016-04-14 08:54:32 +01:00
block-cache/copier.cc \
block-cache/io_engine.cc \
block-cache/mem_pool.cc \
2014-08-27 14:01:31 +01:00
caching/cache_check.cc \
caching/cache_dump.cc \
caching/cache_metadata_size.cc \
caching/cache_repair.cc \
caching/cache_restore.cc \
2016-03-08 15:27:22 +00:00
caching/cache_writeback.cc \
caching/commands.cc \
2013-09-24 12:00:09 +01:00
caching/hint_array.cc \
2013-09-12 14:21:25 +01:00
caching/mapping_array.cc \
2013-09-11 11:40:46 +01:00
caching/metadata.cc \
caching/metadata_dump.cc \
2013-09-12 12:33:32 +01:00
caching/restore_emitter.cc \
2014-08-27 14:01:31 +01:00
caching/superblock.cc \
2013-09-11 11:40:46 +01:00
caching/xml_format.cc \
era/commands.cc \
2014-01-23 00:46:03 +00:00
era/era_array.cc \
2014-08-27 14:01:31 +01:00
era/era_check.cc \
2013-11-19 10:23:35 +00:00
era/era_detail.cc \
2014-08-27 14:01:31 +01:00
era/era_dump.cc \
era/era_invalidate.cc \
era/era_restore.cc \
2014-01-23 00:46:03 +00:00
era/metadata.cc \
era/metadata_dump.cc \
2014-08-07 15:43:01 +01:00
era/restore_emitter.cc \
2014-08-27 14:01:31 +01:00
era/superblock.cc \
era/writeset_tree.cc \
2014-01-23 00:46:03 +00:00
era/xml_format.cc \
2014-08-27 14:01:31 +01:00
main.cc \
persistent-data/block.cc \
persistent-data/checksum.cc \
persistent-data/data-structures/bitset.cc \
persistent-data/data-structures/bloom_filter.cc \
persistent-data/data-structures/btree.cc \
persistent-data/data-structures/btree_damage_visitor.cc \
persistent-data/data-structures/btree_node_checker.cc \
2014-08-27 14:01:31 +01:00
persistent-data/error_set.cc \
persistent-data/file_utils.cc \
persistent-data/hex_dump.cc \
persistent-data/space-maps/careful_alloc.cc \
persistent-data/space-maps/core.cc \
persistent-data/space-maps/disk.cc \
persistent-data/space-maps/recursive.cc \
2014-08-27 14:01:31 +01:00
persistent-data/space_map.cc \
persistent-data/transaction_manager.cc \
persistent-data/validators.cc \
thin-provisioning/commands.cc \
thin-provisioning/cache_stream.cc \
2015-09-03 13:02:29 +01:00
thin-provisioning/chunk_stream.cc \
2013-05-20 16:09:13 +01:00
thin-provisioning/device_tree.cc \
thin-provisioning/fixed_chunk_stream.cc \
thin-provisioning/human_readable_format.cc \
2013-05-21 11:46:37 +01:00
thin-provisioning/mapping_tree.cc \
thin-provisioning/metadata.cc \
thin-provisioning/metadata_checker.cc \
2016-02-27 15:23:06 +08:00
thin-provisioning/metadata_counter.cc \
thin-provisioning/metadata_dumper.cc \
thin-provisioning/override_emitter.cc \
thin-provisioning/pool_stream.cc \
thin-provisioning/restore_emitter.cc \
2013-05-24 13:30:17 +01:00
thin-provisioning/rmap_visitor.cc \
thin-provisioning/superblock.cc \
thin-provisioning/thin_check.cc \
2014-06-09 10:37:46 +01:00
thin-provisioning/thin_delta.cc \
thin-provisioning/thin_dump.cc \
thin-provisioning/thin_ls.cc \
2014-08-27 14:01:31 +01:00
thin-provisioning/thin_metadata_size.cc \
thin-provisioning/thin_pool.cc \
2013-06-19 12:39:28 +01:00
thin-provisioning/thin_repair.cc \
2014-08-27 14:01:31 +01:00
thin-provisioning/thin_restore.cc \
thin-provisioning/thin_rmap.cc \
2017-09-18 16:10:56 +01:00
thin-provisioning/thin_trim.cc \
2014-08-27 14:01:31 +01:00
thin-provisioning/xml_format.cc
DEVTOOLS_SOURCE=\
2018-08-28 13:12:20 +01:00
thin-provisioning/thin_journal.cc \
thin-provisioning/thin_journal_check.cc \
thin-provisioning/thin_ll_dump.cc \
thin-provisioning/thin_ll_restore.cc \
thin-provisioning/thin_show_duplicates.cc \
thin-provisioning/thin_generate_metadata.cc \
thin-provisioning/thin_generate_mappings.cc \
thin-provisioning/variable_chunk_stream.cc \
2016-02-26 12:50:17 +00:00
thin-provisioning/thin_show_metadata.cc \
thin-provisioning/thin_scan.cc \
2016-02-26 12:50:17 +00:00
ui/ui.cc
ifeq ("@DEVTOOLS@", "yes")
SOURCE+=$(DEVTOOLS_SOURCE)
endif
ifeq ("@STATIC@", "yes")
SOURCE += thin-provisioning/static_library_emitter.cc
else
SOURCE += thin-provisioning/shared_library_emitter.cc
endif
CC:=@CC@
CXX:=@CXX@
2015-11-26 15:00:00 +08:00
STRIP:=@STRIP@
OBJECTS:=$(subst .cc,.o,$(SOURCE))
ifeq ("@STATIC@", "yes")
EMITTERS += $(PLUGIN_LIBS)
endif
2011-12-09 12:54:51 +00:00
TOP_DIR:=@top_srcdir@
TOP_BUILDDIR:=@top_builddir@
CFLAGS+=-g -Wall -O3 -fPIC
CFLAGS+=@LFS_FLAGS@
CXXFLAGS+=-g -Wall -fPIC -fno-strict-aliasing -std=c++11
ifeq ("@DEVTOOLS@", "yes")
CXXFLAGS+=-DDEV_TOOLS
endif
2011-12-09 12:54:51 +00:00
CXXFLAGS+=@CXXOPTIMISE_FLAG@
CXXFLAGS+=@CXXDEBUG_FLAG@
CXXFLAGS+=@CXX_STRERROR_FLAG@
CXXFLAGS+=@LFS_FLAGS@
INCLUDES+=-I$(TOP_BUILDDIR) -I$(TOP_DIR) -I$(TOP_DIR)/thin-provisioning
LIBS:=-laio -lexpat -lboost_iostreams -ldl
2016-02-26 12:50:17 +00:00
ifeq ("@DEVTOOLS@", "yes")
LIBS+=-lncurses
endif
ifeq ("@STATIC_CXX@", "yes")
2016-02-09 10:57:39 +00:00
CXXLIB+=-Wl,-Bstatic -lstdc++ -Wl,-Bdynamic -Wl,--as-needed
else
2016-02-09 10:57:39 +00:00
CXXLIB+=-lstdc++
endif
ifeq ("@STATIC@", "yes")
LDFLAGS+=-static
endif
INSTALL:=@INSTALL@
PREFIX:=@prefix@
BINDIR:=$(DESTDIR)$(PREFIX)/sbin
DATADIR:=$(DESTDIR)$(PREFIX)/share
MANPATH:=$(DATADIR)/man
vpath %.cc $(TOP_DIR)
INSTALL_DIR = $(INSTALL) -m 755 -d
2015-11-26 15:00:00 +08:00
INSTALL_PROGRAM = $(INSTALL) -m 755
INSTALL_DATA = $(INSTALL) -p -m 644
2011-06-16 08:16:10 +01:00
2013-03-25 12:56:03 +00:00
ifeq ("@TESTING@", "yes")
TEST_INCLUDES=\
-I$(TOP_DIR) \
-Igoogletest/googlemock/include \
-Igoogletest/googletest/include
2013-03-25 12:56:03 +00:00
else
TEST_INCLUDES=
endif
2011-07-22 16:09:56 +01:00
.SUFFIXES: .d .txt .8
2011-06-16 08:16:10 +01:00
%.o: %.cc
2013-03-22 15:41:13 +00:00
@echo " [CXX] $<"
@mkdir -p $(dir $@)
2013-03-22 12:19:31 +00:00
$(V) $(CXX) -c $(INCLUDES) $(CXXFLAGS) -o $@ $<
$(V) $(CXX) -MM -MT $(subst .cc,.o,$<) $(INCLUDES) $(TEST_INCLUDES) $(CXXFLAGS) $< > $*.$$$$; \
sed 's,\([^ :]*\)\.o[ :]*,\1.o \1.gmo $* : Makefile ,g' < $*.$$$$ > $*.d; \
$(RM) $*.$$$$
2011-06-16 08:16:10 +01:00
2018-04-25 14:05:28 +01:00
%.o: %.c
2018-06-13 12:49:57 +01:00
@echo " [CC] $<"
@mkdir -p $(dir $@)
2018-04-25 14:05:28 +01:00
$(V) $(CC) -c $(INCLUDES) $(CFLAGS) -o $@ $<
$(V) $(CC) -MM -MT $(subst .cc,.o,$<) $(INCLUDES) $(TEST_INCLUDES) $(CFLAGS) $< > $*.$$$$; \
sed 's,\([^ :]*\)\.o[ :]*,\1.o \1.gmo $* : Makefile ,g' < $*.$$$$ > $*.d; \
$(RM) $*.$$$$
%.8: %.txt bin/txt2man
@echo " [txt2man] $<"
@mkdir -p $(dir $@)
$(V) bin/txt2man -p -t $(basename $(notdir $<)) $< > $@
2013-03-22 13:42:20 +00:00
#----------------------------------------------------------------
lib/libpdata.a: $(OBJECTS) $(EMITTERS)
2013-03-22 15:48:43 +00:00
@echo " [AR] $<"
@mkdir -p $(dir $@)
$(V)ar -rv $@ $(OBJECTS) $(EMITTERS) > /dev/null 2>&1
bin/pdata_tools: $(OBJECTS) $(EMITTERS)
2013-03-22 15:48:43 +00:00
@echo " [LD] $@"
@mkdir -p $(dir $@)
2016-02-09 10:57:39 +00:00
$(V) $(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $+ $(LIBS) $(CXXLIB)
2011-08-23 11:55:37 +01:00
2014-01-09 22:40:34 +00:00
#----------------------------------------------------------------
2013-03-25 12:56:03 +00:00
DEPEND_FILES=\
$(subst .cc,.d,$(SOURCE)) \
$(subst .cc,.d,$(TEST_SOURCE)) \
2013-07-16 15:33:38 +02:00
$(subst .cc,.d,$(CXX_PROGRAM_SOURCE)) \
$(subst .c,.d,$(C_PROGRAM_SOURCE))
2013-03-25 12:56:03 +00:00
2013-03-22 13:42:20 +00:00
.PHONY: clean distclean
2011-12-06 15:47:24 +00:00
clean:
find . -name \*.o -delete
find . -name \*.gmo -delete
find . -name \*.d -delete
$(RM) $(TEST_PROGRAMS) $(PROGRAMS) $(GMOCK_OBJECTS) lib/*.a lib/*.so
2013-03-22 13:42:20 +00:00
distclean: clean
$(RM) config.cache config.log config.status configure.h version.h Makefile unit-tests/Makefile
2011-12-06 15:47:24 +00:00
TOOLS:=\
cache_check \
cache_dump \
cache_metadata_size \
cache_repair \
cache_restore \
cache_writeback \
thin_check \
thin_delta \
thin_dump \
thin_ls \
thin_repair \
thin_restore \
thin_rmap \
thin_metadata_size \
thin_trim \
era_check \
era_dump \
era_invalidate \
era_restore
MANPAGES:=$(patsubst %,man8/%.8,$(TOOLS))
install: bin/pdata_tools $(MANPAGES)
$(INSTALL_DIR) $(BINDIR)
2014-08-27 14:01:31 +01:00
$(INSTALL_PROGRAM) bin/pdata_tools $(BINDIR)
2015-11-26 15:00:00 +08:00
$(STRIP) $(BINDIR)/pdata_tools
ln -s -f pdata_tools $(BINDIR)/cache_check
ln -s -f pdata_tools $(BINDIR)/cache_dump
ln -s -f pdata_tools $(BINDIR)/cache_metadata_size
ln -s -f pdata_tools $(BINDIR)/cache_repair
ln -s -f pdata_tools $(BINDIR)/cache_restore
2016-03-08 15:27:22 +00:00
ln -s -f pdata_tools $(BINDIR)/cache_writeback
ln -s -f pdata_tools $(BINDIR)/thin_check
2015-03-24 14:09:36 +00:00
ln -s -f pdata_tools $(BINDIR)/thin_delta
ln -s -f pdata_tools $(BINDIR)/thin_dump
ln -s -f pdata_tools $(BINDIR)/thin_ls
ln -s -f pdata_tools $(BINDIR)/thin_repair
ln -s -f pdata_tools $(BINDIR)/thin_restore
ln -s -f pdata_tools $(BINDIR)/thin_rmap
ln -s -f pdata_tools $(BINDIR)/thin_metadata_size
2017-09-18 16:10:56 +01:00
ln -s -f pdata_tools $(BINDIR)/thin_trim
ln -s -f pdata_tools $(BINDIR)/era_check
ln -s -f pdata_tools $(BINDIR)/era_dump
ln -s -f pdata_tools $(BINDIR)/era_invalidate
ln -s -f pdata_tools $(BINDIR)/era_restore
$(INSTALL_DIR) $(MANPATH)/man8
$(INSTALL_DATA) man8/cache_check.8 $(MANPATH)/man8
$(INSTALL_DATA) man8/cache_dump.8 $(MANPATH)/man8
2017-09-18 16:10:56 +01:00
$(INSTALL_DATA) man8/cache_metadata_size.8 $(MANPATH)/man8
$(INSTALL_DATA) man8/cache_repair.8 $(MANPATH)/man8
$(INSTALL_DATA) man8/cache_restore.8 $(MANPATH)/man8
2016-03-08 15:27:22 +00:00
$(INSTALL_DATA) man8/cache_writeback.8 $(MANPATH)/man8
2013-07-10 17:16:56 +02:00
$(INSTALL_DATA) man8/thin_check.8 $(MANPATH)/man8
2015-03-24 14:09:36 +00:00
$(INSTALL_DATA) man8/thin_delta.8 $(MANPATH)/man8
2013-07-10 17:16:56 +02:00
$(INSTALL_DATA) man8/thin_dump.8 $(MANPATH)/man8
$(INSTALL_DATA) man8/thin_ls.8 $(MANPATH)/man8
2013-07-18 15:54:15 +02:00
$(INSTALL_DATA) man8/thin_repair.8 $(MANPATH)/man8
2013-07-10 17:16:56 +02:00
$(INSTALL_DATA) man8/thin_restore.8 $(MANPATH)/man8
2013-07-18 15:54:15 +02:00
$(INSTALL_DATA) man8/thin_rmap.8 $(MANPATH)/man8
$(INSTALL_DATA) man8/thin_metadata_size.8 $(MANPATH)/man8
2014-08-06 11:10:22 +01:00
$(INSTALL_DATA) man8/era_check.8 $(MANPATH)/man8
$(INSTALL_DATA) man8/era_dump.8 $(MANPATH)/man8
2017-09-18 16:10:56 +01:00
$(INSTALL_DATA) man8/era_restore.8 $(MANPATH)/man8
2014-08-06 11:10:22 +01:00
$(INSTALL_DATA) man8/era_invalidate.8 $(MANPATH)/man8
2017-09-18 16:10:56 +01:00
$(INSTALL_DATA) man8/thin_trim.8 $(MANPATH)/man8
ifeq ("@DEVTOOLS@", "yes")
ln -s -f pdata_tools $(BINDIR)/thin_show_duplicates
ln -s -f pdata_tools $(BINDIR)/thin_ll_dump
ln -s -f pdata_tools $(BINDIR)/thin_show_duplicates
ln -s -f pdata_tools $(BINDIR)/thin_generate_metadata
ln -s -f pdata_tools $(BINDIR)/thin_scan
endif
.PHONY: install install-rust-tools rust-tools
rust-tools:
cargo build --release
2014-08-27 14:01:31 +01:00
install-rust-tools: man8/thin_metadata_pack.8 man8/thin_metadata_unpack.8 rust-tools
$(INSTALL_PROGRAM) target/release/thin_metadata_pack $(BINDIR)
$(INSTALL_PROGRAM) target/release/thin_metadata_unpack $(BINDIR)
$(STRIP) $(BINDIR)/thin_metadata_pack
$(STRIP) $(BINDIR)/thin_metadata_unpack
$(INSTALL_DATA) man8/thin_metadata_pack.8 $(MANPATH)/man8
$(INSTALL_DATA) man8/thin_metadata_unpack.8 $(MANPATH)/man8
ifeq ("@TESTING@", "yes")
include unit-tests/Makefile
LIBFT_SOURCE=\
ft-lib/bcache.c \
ft-lib/crc32c.c \
ft-lib/dm-ioctl.c
2013-03-25 11:53:55 +00:00
LIBFT_OBJECTS=$(subst .c,.o,$(LIBFT_SOURCE))
2013-03-25 11:53:55 +00:00
lib/libft.so: $(LIBFT_OBJECTS)
2018-04-25 14:05:28 +01:00
@echo " [LD]" $@
$(V) gcc -shared -o $@ $+ -laio
.PHONEY: functional-test unit-test
functional-test: bin/pdata_tools lib/libft.so
cd functional-tests && ./run-tests run
test: functional-test unit-test
2013-03-25 12:56:03 +00:00
endif
-include $(DEPEND_FILES)