Skip to content

Commit

Permalink
Introducing the concept of DEV_PROGRAMS into generic.mk (e.g. tightdb…
Browse files Browse the repository at this point in the history
…-config). This allows proper separation between 'shared' and 'devel' components when installing.
  • Loading branch information
kspangsege committed Aug 26, 2013
1 parent bb1e23d commit 2635de4
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 38 deletions.
8 changes: 4 additions & 4 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ EOF
"install-shared")
require_config || exit 1
install_prefix="$(get_config_param "install-prefix")" || exit 1
make install DESTDIR="$DESTDIR" prefix="$install_prefix" INSTALL_FILTER=shared-libs || exit 1
make install DESTDIR="$DESTDIR" prefix="$install_prefix" INSTALL_FILTER=shared-libs,progs || exit 1
if [ "$USER" = "root" ] && which ldconfig >/dev/null 2>&1; then
ldconfig || exit 1
fi
Expand All @@ -416,7 +416,7 @@ EOF
"install-devel")
require_config || exit 1
install_prefix="$(get_config_param "install-prefix")" || exit 1
make install DESTDIR="$DESTDIR" prefix="$install_prefix" INSTALL_FILTER=static-libs,progs,headers || exit 1
make install DESTDIR="$DESTDIR" prefix="$install_prefix" INSTALL_FILTER=static-libs,dev-progs,headers || exit 1
echo "Done installing"
exit 0
;;
Expand All @@ -435,7 +435,7 @@ EOF
"uninstall-shared")
require_config || exit 1
install_prefix="$(get_config_param "install-prefix")" || exit 1
make uninstall prefix="$install_prefix" INSTALL_FILTER=shared-libs || exit 1
make uninstall prefix="$install_prefix" INSTALL_FILTER=shared-libs,progs || exit 1
if [ "$USER" = "root" ] && which ldconfig >/dev/null 2>&1; then
ldconfig || exit 1
fi
Expand All @@ -446,7 +446,7 @@ EOF
"uninstall-devel")
require_config || exit 1
install_prefix="$(get_config_param "install-prefix")" || exit 1
make uninstall prefix="$install_prefix" INSTALL_FILTER=static-libs,progs,extra || exit 1
make uninstall prefix="$install_prefix" INSTALL_FILTER=static-libs,dev-progs,extra || exit 1
echo "Done uninstalling"
exit 0
;;
Expand Down
1 change: 0 additions & 1 deletion config.mk
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
SOURCE_ROOT = src
ENABLE_INSTALL_STATIC_LIBS = 1
ENABLE_INSTALL_DEBUG_LIBS = 1
ENABLE_INSTALL_DEBUG_PROGS = 1

# Construct fat binaries on Darwin when using Clang
ifneq ($(TIGHTDB_ENABLE_FAT_BINARIES),)
Expand Down
84 changes: 52 additions & 32 deletions generic.mk
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,14 @@ ENABLE_INSTALL_DEBUG_PROGS =
# Use this if you want to install only a subset of what is usually
# installed. For example, to produce a separate binary and development
# package for a library product, you can run 'make install
# INSTALL_FILTER=shared-libs' for the binary package and 'make install
# INSTALL_FILTER=static-libs,progs,headers' for the development
# package. This filter also affects 'uninstall', but note that
# 'uninstall' makes no attempt to uninstall headers, instead it
# INSTALL_FILTER=shared-libs,progs' for the binary package and 'make
# install INSTALL_FILTER=static-libs,dev-progs,headers' for the
# development package. This filter also affects 'uninstall', but note
# that 'uninstall' makes no attempt to uninstall headers, instead it
# invokes a custom target 'uninstall/extra' if 'extra' is included in
# the filter. It is then up to the apllication to decide what actions
# the filter. It is then up to the application to decide what actions
# to take on 'uninstall/extra'.
INSTALL_FILTER = shared-libs,static-libs,progs,headers,extra
INSTALL_FILTER = shared-libs,static-libs,progs,dev-progs,headers,extra

# Installation (GNU style)
prefix = /usr/local
Expand Down Expand Up @@ -458,11 +458,11 @@ INC_FLAGS += -I$(ROOT)/$(SOURCE_ROOT)
INC_FLAGS_ABS += -I$(ABS_ROOT)/$(SOURCE_ROOT)
endif

INST_LIBRARIES = $(foreach x,lib $(EXTRA_INSTALL_PREFIXES),$($(x)_LIBRARIES))
INST_PROGRAMS = $(foreach x,bin $(EXTRA_INSTALL_PREFIXES),$($(x)_PROGRAMS))
REGULAR_LIBRARIES = $(foreach x,lib $(EXTRA_INSTALL_PREFIXES),$($(x)_LIBRARIES))
REGULAR_PROGRAMS = $(foreach x,bin $(EXTRA_INSTALL_PREFIXES),$($(x)_PROGRAMS))

LIBRARIES = $(INST_LIBRARIES) $(NOINST_LIBRARIES)
PROGRAMS = $(INST_PROGRAMS) $(NOINST_PROGRAMS) $(TEST_PROGRAMS)
LIBRARIES = $(REGULAR_LIBRARIES) $(NOINST_LIBRARIES)
PROGRAMS = $(REGULAR_PROGRAMS) $(DEV_PROGRAMS) $(NOINST_PROGRAMS) $(TEST_PROGRAMS)

OBJECTS_STATIC_OPTIM = $(foreach x,$(LIBRARIES) $(PROGRAMS),$(call GET_OBJECTS_FOR_TARGET,$(x),$(SUFFIX_OBJ_STATIC_OPTIM)))
OBJECTS_SHARED_OPTIM = $(foreach x,$(LIBRARIES),$(call GET_OBJECTS_FOR_TARGET,$(x),$(SUFFIX_OBJ_SHARED_OPTIM)))
Expand All @@ -472,18 +472,20 @@ OBJECTS_STATIC_COVER = $(foreach x,$(LIBRARIES) $(PROGRAMS),$(call GET_OBJECTS_F
OBJECTS_SHARED_COVER = $(foreach x,$(LIBRARIES),$(call GET_OBJECTS_FOR_TARGET,$(x),$(SUFFIX_OBJ_SHARED_COVER)))
OBJECTS = $(sort $(OBJECTS_STATIC_OPTIM) $(OBJECTS_SHARED_OPTIM) $(OBJECTS_STATIC_DEBUG) $(OBJECTS_SHARED_DEBUG) $(OBJECTS_STATIC_COVER) $(OBJECTS_SHARED_COVER))

TARGETS_LIB_STATIC_OPTIM = $(foreach x,$(INST_LIBRARIES),$(call GET_LIBRARY_NAME,$(x))$(SUFFIX_LIB_STATIC_OPTIM))
TARGETS_LIB_SHARED_OPTIM = $(foreach x,$(INST_LIBRARIES),$(call GET_LIBRARY_NAME,$(x))$(SUFFIX_LIB_SHARED_OPTIM))
TARGETS_LIB_STATIC_DEBUG = $(foreach x,$(INST_LIBRARIES),$(call GET_LIBRARY_NAME,$(x))$(SUFFIX_LIB_STATIC_DEBUG))
TARGETS_LIB_SHARED_DEBUG = $(foreach x,$(INST_LIBRARIES),$(call GET_LIBRARY_NAME,$(x))$(SUFFIX_LIB_SHARED_DEBUG))
TARGETS_LIB_STATIC_COVER = $(foreach x,$(INST_LIBRARIES),$(call GET_LIBRARY_NAME,$(x))$(SUFFIX_LIB_STATIC_COVER))
TARGETS_LIB_SHARED_COVER = $(foreach x,$(INST_LIBRARIES),$(call GET_LIBRARY_NAME,$(x))$(SUFFIX_LIB_SHARED_COVER))
TARGETS_LIB_STATIC_OPTIM = $(foreach x,$(REGULAR_LIBRARIES),$(call GET_LIBRARY_NAME,$(x))$(SUFFIX_LIB_STATIC_OPTIM))
TARGETS_LIB_SHARED_OPTIM = $(foreach x,$(REGULAR_LIBRARIES),$(call GET_LIBRARY_NAME,$(x))$(SUFFIX_LIB_SHARED_OPTIM))
TARGETS_LIB_STATIC_DEBUG = $(foreach x,$(REGULAR_LIBRARIES),$(call GET_LIBRARY_NAME,$(x))$(SUFFIX_LIB_STATIC_DEBUG))
TARGETS_LIB_SHARED_DEBUG = $(foreach x,$(REGULAR_LIBRARIES),$(call GET_LIBRARY_NAME,$(x))$(SUFFIX_LIB_SHARED_DEBUG))
TARGETS_LIB_STATIC_COVER = $(foreach x,$(REGULAR_LIBRARIES),$(call GET_LIBRARY_NAME,$(x))$(SUFFIX_LIB_STATIC_COVER))
TARGETS_LIB_SHARED_COVER = $(foreach x,$(REGULAR_LIBRARIES),$(call GET_LIBRARY_NAME,$(x))$(SUFFIX_LIB_SHARED_COVER))
TARGETS_NOINST_LIB_OPTIM = $(foreach x,$(NOINST_LIBRARIES),$(call GET_LIBRARY_NAME,$(x))$(SUFFIX_LIB_STATIC_OPTIM))
TARGETS_NOINST_LIB_DEBUG = $(foreach x,$(NOINST_LIBRARIES),$(call GET_LIBRARY_NAME,$(x))$(SUFFIX_LIB_STATIC_DEBUG))
TARGETS_NOINST_LIB_COVER = $(foreach x,$(NOINST_LIBRARIES),$(call GET_LIBRARY_NAME,$(x))$(SUFFIX_LIB_STATIC_COVER))
TARGETS_PROG_OPTIM = $(foreach x,$(INST_PROGRAMS),$(x)$(SUFFIX_PROG_OPTIM))
TARGETS_PROG_DEBUG = $(foreach x,$(INST_PROGRAMS),$(x)$(SUFFIX_PROG_DEBUG))
TARGETS_PROG_COVER = $(foreach x,$(INST_PROGRAMS),$(x)$(SUFFIX_PROG_COVER))
TARGETS_PROG_OPTIM = $(foreach x,$(REGULAR_PROGRAMS),$(x)$(SUFFIX_PROG_OPTIM))
TARGETS_PROG_DEBUG = $(foreach x,$(REGULAR_PROGRAMS),$(x)$(SUFFIX_PROG_DEBUG))
TARGETS_PROG_COVER = $(foreach x,$(REGULAR_PROGRAMS),$(x)$(SUFFIX_PROG_COVER))
TARGETS_DEV_PROG_OPTIM = $(foreach x,$(DEV_PROGRAMS),$(x)$(SUFFIX_PROG_OPTIM))
TARGETS_DEV_PROG_DEBUG = $(foreach x,$(DEV_PROGRAMS),$(x)$(SUFFIX_PROG_DEBUG))
TARGETS_NOINST_PROG_OPTIM = $(foreach x,$(NOINST_PROGRAMS),$(x)$(SUFFIX_PROG_OPTIM))
TARGETS_NOINST_PROG_DEBUG = $(foreach x,$(NOINST_PROGRAMS),$(x)$(SUFFIX_PROG_DEBUG))
TARGETS_NOINST_PROG_COVER = $(foreach x,$(NOINST_PROGRAMS),$(x)$(SUFFIX_PROG_COVER))
Expand All @@ -507,14 +509,15 @@ TARGETS_DEFAULT += $(TARGETS_PROG_OPTIM)
ifneq ($(ENABLE_INSTALL_DEBUG_PROGS),)
TARGETS_DEFAULT += $(TARGETS_PROG_DEBUG)
endif
TARGETS_DEFAULT += $(TARGETS_NOINST_PROG_OPTIM)
TARGETS_DEFAULT += $(TARGETS_DEV_PROG_OPTIM) $(TARGETS_DEV_PROG_DEBUG) $(TARGETS_NOINST_PROG_OPTIM)

TARGETS_MINIMAL = $(TARGETS_LIB_SHARED_OPTIM) $(TARGETS_NOINST_LIB_OPTIM) $(TARGETS_PROG_OPTIM) $(TARGETS_NOINST_PROG_OPTIM)
TARGETS_NODEBUG = $(TARGETS_LIB_STATIC_OPTIM) $(TARGETS_LIB_SHARED_OPTIM) $(TARGETS_NOINST_LIB_OPTIM) $(TARGETS_PROG_OPTIM) $(TARGETS_NOINST_PROG_OPTIM)
TARGETS_DEBUG = $(TARGETS_LIB_SHARED_DEBUG) $(TARGETS_NOINST_LIB_DEBUG) $(TARGETS_PROG_DEBUG) $(TARGETS_NOINST_PROG_DEBUG)
TARGETS_MINIMAL = $(TARGETS_LIB_SHARED_OPTIM) $(TARGETS_NOINST_LIB_OPTIM) $(TARGETS_PROG_OPTIM) $(TARGETS_DEV_PROG_OPTIM) $(TARGETS_NOINST_PROG_OPTIM)
TARGETS_NODEBUG = $(TARGETS_LIB_STATIC_OPTIM) $(TARGETS_LIB_SHARED_OPTIM) $(TARGETS_NOINST_LIB_OPTIM) $(TARGETS_PROG_OPTIM) $(TARGETS_DEV_PROG_OPTIM) $(TARGETS_NOINST_PROG_OPTIM)
TARGETS_DEBUG = $(TARGETS_LIB_SHARED_DEBUG) $(TARGETS_NOINST_LIB_DEBUG) $(TARGETS_PROG_DEBUG) $(TARGETS_DEV_PROG_DEBUG) $(TARGETS_NOINST_PROG_DEBUG)
TARGETS_COVER = $(TARGETS_LIB_SHARED_COVER) $(TARGETS_NOINST_LIB_COVER) $(TARGETS_PROG_COVER) $(TARGETS_NOINST_PROG_COVER)
TARGETS_EVERYTHING = $(TARGETS_LIB_STATIC_OPTIM) $(TARGETS_LIB_SHARED_OPTIM) $(TARGETS_LIB_SHARED_DEBUG) $(TARGETS_NOINST_LIB_OPTIM) $(TARGETS_NOINST_LIB_DEBUG)
TARGETS_EVERYTHING += $(TARGETS_PROG_OPTIM) $(TARGETS_PROG_DEBUG) $(TARGETS_NOINST_PROG_OPTIM) $(TARGETS_NOINST_PROG_DEBUG) $(TARGETS_TEST_PROG_OPTIM) $(TARGETS_TEST_PROG_DEBUG)
TARGETS_EVERYTHING += $(TARGETS_PROG_OPTIM) $(TARGETS_PROG_DEBUG) $(TARGETS_DEV_PROG_OPTIM) $(TARGETS_DEV_PROG_DEBUG)
TARGETS_EVERYTHING += $(TARGETS_NOINST_PROG_OPTIM) $(TARGETS_NOINST_PROG_DEBUG) $(TARGETS_TEST_PROG_OPTIM) $(TARGETS_TEST_PROG_DEBUG)
TARGETS_TEST = $(TARGETS_LIB_SHARED_OPTIM) $(TARGETS_NOINST_LIB_OPTIM) $(TARGETS_TEST_PROG_OPTIM)
TARGETS_TEST_DEBUG = $(TARGETS_LIB_SHARED_DEBUG) $(TARGETS_NOINST_LIB_DEBUG) $(TARGETS_TEST_PROG_DEBUG)
TARGETS_TEST_COVER = $(TARGETS_LIB_SHARED_COVER) $(TARGETS_NOINST_LIB_COVER) $(TARGETS_TEST_PROG_COVER)
Expand All @@ -523,13 +526,14 @@ TARGETS_LIB_STATIC = $(TARGETS_LIB_STATIC_OPTIM) $(TARGETS_LIB_STATIC_DEBUG) $(
TARGETS_LIB_SHARED = $(TARGETS_LIB_SHARED_OPTIM) $(TARGETS_LIB_SHARED_DEBUG) $(TARGETS_LIB_SHARED_COVER)
TARGETS_NOINST_LIB = $(TARGETS_NOINST_LIB_OPTIM) $(TARGETS_NOINST_LIB_DEBUG) $(TARGETS_NOINST_LIB_COVER)
TARGETS_PROG = $(TARGETS_PROG_OPTIM) $(TARGETS_PROG_DEBUG) $(TARGETS_PROG_COVER)
TARGETS_DEV_PROG = $(TARGETS_DEV_PROG_OPTIM) $(TARGETS_DEV_PROG_DEBUG)
TARGETS_NOINST_PROG = $(TARGETS_NOINST_PROG_OPTIM) $(TARGETS_NOINST_PROG_DEBUG) $(TARGETS_NOINST_PROG_COVER)
TARGETS_TEST_PROG = $(TARGETS_TEST_PROG_OPTIM) $(TARGETS_TEST_PROG_DEBUG) $(TARGETS_TEST_PROG_COVER)
TARGETS_PROG_ALL = $(foreach x,$(TARGETS_PROG),$(x) $(x)-noinst) $(TARGETS_NOINST_PROG) $(TARGETS_TEST_PROG)
TARGETS_PROG_ALL = $(foreach x,$(TARGETS_PROG) $(TARGETS_DEV_PROG),$(x) $(x)-noinst) $(TARGETS_NOINST_PROG) $(TARGETS_TEST_PROG)

TARGETS = $(TARGETS_LIB_STATIC) $(TARGETS_LIB_SHARED) $(TARGETS_NOINST_LIB) $(TARGETS_PROG_ALL)
TARGETS = $(TARGETS_LIB_STATIC) $(TARGETS_LIB_SHARED) $(TARGETS_NOINST_LIB) $(TARGETS_PROG_ALL)

TARGETS_LIB_SHARED_ALIASES = $(foreach x,$(INST_LIBRARIES),$(foreach y,OPTIM DEBUG COVER,$(call TARGETS_LIB_SHARED_ALIASES_2,$(x),$(SUFFIX_LIB_SHARED_$(y)))))
TARGETS_LIB_SHARED_ALIASES = $(foreach x,$(REGULAR_LIBRARIES),$(foreach y,OPTIM DEBUG COVER,$(call TARGETS_LIB_SHARED_ALIASES_2,$(x),$(SUFFIX_LIB_SHARED_$(y)))))
TARGETS_LIB_SHARED_ALIASES_2 = $(call GET_SHARED_LIB_ALIASES,$(call GET_LIBRARY_NAME,$(1))$(2),$(call GET_VERSION_FOR_TARGET,$(1)))

# ARGS: qual_name, version
Expand Down Expand Up @@ -653,8 +657,8 @@ clean clean/after: $(patsubst %,subdir/%/clean,$(AVAIL_PASSIVE_SUBDIRS))
# INSTALL / UNINSTALL

.PHONY: install/header/dir install/lib/dirs install/prog/dirs
.PHONY: install/headers install/static-libs install/shared-libs install/progs
.PHONY: uninstall/static-libs uninstall/shared-libs uninstall/progs uninstall/extra
.PHONY: install/headers install/static-libs install/shared-libs install/progs install/dev-progs
.PHONY: uninstall/static-libs uninstall/shared-libs uninstall/progs uninstall/dev-progs uninstall/extra

ifeq ($(NO_BUILD_ON_INSTALL),)
install/local: default/local
Expand All @@ -669,6 +673,7 @@ install/progs: $(TARGETS_PROG_OPTIM)
ifneq ($(ENABLE_INSTALL_DEBUG_PROGS),)
install/progs: $(TARGETS_PROG_DEBUG)
endif
install/dev-progs: $(TARGETS_DEV_PROG_OPTIM) $(TARGETS_DEV_PROG_DEBUG)
endif

INSTALL_FILTER_2 = $(subst $(COMMA), ,$(INSTALL_FILTER))
Expand All @@ -685,7 +690,13 @@ endif
ifneq ($(filter progs,$(INSTALL_FILTER_2)),)
install/local: install/progs
endif
ifneq ($(filter dev-progs,$(INSTALL_FILTER_2)),)
install/local: install/dev-progs
endif

ifneq ($(filter dev-progs,$(INSTALL_FILTER_2)),)
uninstall/after: uninstall/dev-progs
endif
ifneq ($(filter progs,$(INSTALL_FILTER_2)),)
uninstall/after: uninstall/progs
endif
Expand Down Expand Up @@ -789,12 +800,21 @@ $(foreach x,bin $(EXTRA_INSTALL_PREFIXES),$(call INSTALL_RECIPE_PROGS,$(x),$(str
uninstall/progs:
$(foreach x,bin $(EXTRA_INSTALL_PREFIXES),$(call UNINSTALL_RECIPE_PROGS,$(x),$(strip $(call GET_PROG_INST_NAMES,$(x)))))

install/dev-progs: install/dev-prog/dirs
$(call INSTALL_RECIPE_PROGS,bin,$(strip $(TARGETS_DEV_PROG_OPTIM) $(TARGETS_DEV_PROG_DEBUG)))

uninstall/dev-progs:
$(call UNINSTALL_RECIPE_PROGS,bin,$(strip $(TARGETS_DEV_PROG_OPTIM) $(TARGETS_DEV_PROG_DEBUG)))

install/lib/dirs:
$(call INSTALL_RECIPE_DIRS,$(strip $(foreach x,lib $(EXTRA_INSTALL_PREFIXES),$(if $($(x)_LIBRARIES),$(call GET_LIB_INSTALL_DIR,$(x))))))

install/prog/dirs:
$(call INSTALL_RECIPE_DIRS,$(strip $(foreach x,bin $(EXTRA_INSTALL_PREFIXES),$(if $($(x)_PROGRAMS),$(call GET_PROG_INSTALL_DIR,$(x))))))

install/dev-prog/dirs:
$(call INSTALL_RECIPE_DIRS,$(strip $(if $(DEV_PROGRAMS),$(call GET_PROG_INSTALL_DIR,bin))))

endef

$(eval $(INSTALL_RULES))
Expand Down Expand Up @@ -960,11 +980,11 @@ $(foreach x,$(call GET_OBJECTS_FOR_TARGET,$(1),.o),$(call RECORD_TARGETS_FOR_OBJ
endef

$(foreach x,$(NOINST_PROGRAMS) $(TEST_PROGRAMS),$(eval $(call NOINST_PROG_RULES,$(x),$(call EXPAND_LIB_REFS,$(x)),$(call GET_DEPS_FOR_TARGET,$(x)))))
$(foreach x,$(INST_PROGRAMS),$(eval $(call INST_PROG_RULES,$(x),$(call EXPAND_LIB_REFS,$(x)),$(call GET_DEPS_FOR_TARGET,$(x)))))
$(foreach x,$(REGULAR_PROGRAMS) $(DEV_PROGRAMS),$(eval $(call INST_PROG_RULES,$(x),$(call EXPAND_LIB_REFS,$(x)),$(call GET_DEPS_FOR_TARGET,$(x)))))



# CREATING LIBRARIES
# CREATING/LINKING LIBRARIES

# ARGS: target, objects, extra_deps
define STATIC_LIBRARY_RULE
Expand Down Expand Up @@ -1053,7 +1073,7 @@ $(foreach x,$(call GET_OBJECTS_FOR_TARGET,$(1),.o),$(call RECORD_TARGETS_FOR_OBJ
endef

$(foreach x,$(NOINST_LIBRARIES),$(eval $(call NOINST_LIB_RULES,$(x),$(call GET_DEPS_FOR_TARGET,$(x)))))
$(foreach x,$(INST_LIBRARIES),$(eval $(call INST_LIB_RULES,$(x),$(call EXPAND_LIB_REFS,$(x)),$(call GET_DEPS_FOR_TARGET,$(x)))))
$(foreach x,$(REGULAR_LIBRARIES),$(eval $(call INST_LIB_RULES,$(x),$(call EXPAND_LIB_REFS,$(x)),$(call GET_DEPS_FOR_TARGET,$(x)))))



Expand Down
2 changes: 1 addition & 1 deletion src/tightdb/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ table_view_basic.hpp table_macros.hpp group.hpp group_shared.hpp query.hpp \
query_conditions.hpp lang_bind_helper.hpp tightdb_nmmintrin.h replication.hpp

lib_LIBRARIES = libtightdb.a
bin_PROGRAMS = tightdb-config
DEV_PROGRAMS = tightdb-config

libtightdb_a_SOURCES = terminate.cpp string_buffer.cpp file.cpp thread.cpp utf8.cpp \
utilities.cpp alloc.cpp alloc_slab.cpp array.cpp array_string.cpp array_string_long.cpp \
Expand Down

0 comments on commit 2635de4

Please sign in to comment.