Makefile.libs
c853f68a
 #
 # $Id$
 #
 # module Makefile
 #(to be included from each library makefile)
 #
 # History:
 # --------
 #  2007-03-16  created by andrei
da33ba73
 #  2007-05-19  rebuild on changed install name on darwin  (andrei)
7742b1d2
 #  2008-06-27  make cfg / config.mak support (andrei)
c853f68a
 
 # NAME, MAJOR_VER and MINOR_VER should be pre-defined in the library 
 # makefile
 #
 
7742b1d2
 ifneq ($(makefile_defs_included), 1)
 $(error "the local makefile does not include Makefile.defs!")
 endif
 
da33ba73
 ifneq	(,$(filter install% %install install, $(MAKECMDGOALS)))
 compile_for_install:=yes
a91ba01f
 ifeq ($(quiet),verbose)
b5b92e04
 $(info install mode)
a91ba01f
 endif # verbose
da33ba73
 endif
 
c853f68a
 ifeq ($(NAME),)
 $(error NAME, MAJOR_VER and MINOR_VER must be defined in the library Makefile)
 endif
 ifeq ($(MAJOR_VER),)
 $(error NAME, MAJOR_VER and MINOR_VER must be defined in the library Makefile)
 endif
 ifeq ($(MINOR_VER),)
 $(error NAME, MAJOR_VER and MINOR_VER must be defined in the library Makefile)
 endif
 ifeq ($(BUGFIX_VER),)
 	BUGFIX_VER:=0
 endif
 
7742b1d2
 # if config was not loaded (makefile_defs!=1) ignore
 # the rest of makefile and try only to remake the config
 ifeq ($(makefile_defs),1)
 
 
c853f68a
 ifeq ($(OS), darwin)
3922c022
 	LIB_NAME:= \
 	$(LIB_PREFIX)$(NAME).$(MAJOR_VER).$(MINOR_VER).$(BUGFIX_VER)$(LIB_SUFFIX)
 	LIB_RUNTIME_NAME:=$(LIB_PREFIX)$(NAME).$(MAJOR_VER)$(LIB_SUFFIX)
 	LIB_LINK_NAME:=$(LIB_PREFIX)$(NAME)$(LIB_SUFFIX)
da33ba73
 	# on darwin we add an extra dependency on a file containing the install 
 	# name (we want to rebuild the library if the install path changed)
 	# this is needed because instead of a rpath link option, on darwin the
 	# path to a linked library is taken from the library itself (the path
 	# is built-in the library)
 	LIBINAME_F:=libiname.lst
08067fd5
 	NAME_LD_FLAGS= -compatibility_version $(MAJOR_VER).$(MINOR_VER) \
c853f68a
 					-current_version $(MAJOR_VER).$(MINOR_VER).$(BUGFIX_VER) \
da33ba73
 					-install_name $(LIB_INSTALL_NAME)
c853f68a
 
 else
3922c022
 	LIB_NAME:=$(LIB_PREFIX)$(NAME)$(LIB_SUFFIX).$(MAJOR_VER).$(MINOR_VER)
 	LIB_RUNTIME_NAME:=$(LIB_PREFIX)$(NAME)$(LIB_SUFFIX).$(MAJOR_VER)
 	LIB_LINK_NAME:=$(LIB_PREFIX)$(NAME)$(LIB_SUFFIX)
08067fd5
 	NAME_LD_FLAGS= $(LIB_SONAME)$(LIB_RUNTIME_NAME)
da33ba73
 	LIBINAME_F:=
c853f68a
 endif
 
08067fd5
 ifeq	($(strip $(compile_for_install)),yes)
 	LIB_INSTALL_NAME:=$(lib_target)/$(LIB_RUNTIME_NAME)
 else
 	LIB_INSTALL_NAME:=$(shell pwd)/$(LIB_RUNTIME_NAME)
 endif
 
c853f68a
 
 COREPATH ?=../..
 
 ALLDEP=Makefile $(COREPATH)/Makefile.sources $(COREPATH)/Makefile.rules \
7742b1d2
  $(COREPATH)/Makefile.libs $(COREPATH)/config.mak
c853f68a
 
 
 ifeq ($(MAKELEVEL), 0)
 # make called directly in the library dir!
 else
 # called by the main Makefile
 
 ALLDEP+=$(COREPATH)/Makefile $(COREPATH)/Makefile.defs
 
 endif
 
 include $(COREPATH)/Makefile.sources
 
 
 CFLAGS:=$(LIB_CFLAGS)
 LDFLAGS:=$(LIB_LDFLAGS) $(NAME_LD_FLAGS)
 NAME:=$(LIB_NAME)
 
 
eefcb29d
 include $(COREPATH)/Makefile.targets
c853f68a
 include $(COREPATH)/Makefile.rules
 
da33ba73
 ifeq	(,$(filter clean %clean clean% proper %proper proper%, $(MAKECMDGOALS)))
 ifneq ($(strip $(LIBINAME_F)),)
 -include $(LIBINAME_F)
 ifneq ($(strip $(LIB_INSTALL_NAME)), $(strip $(COMPILED_INAME)))
 $(shell rm -f $(LIBINAME_F))
 endif
 endif
 endif
 
 $(NAME): $(LIB_RUNTIME_NAME) $(LIB_LINK_NAME) $(LIBINAME_F)
c853f68a
 
3922c022
 $(LIB_RUNTIME_NAME):
c853f68a
 	-@ln -s $(LIB_NAME) $(LIB_RUNTIME_NAME)
 
 $(LIB_LINK_NAME):
e5d32a69
 ifeq ($(OS), freebsd)
 	-@ln -s $(LIB_RUNTIME_NAME) $(LIB_LINK_NAME)
 else
c853f68a
 	-@ln -s $(LIB_NAME) $(LIB_LINK_NAME)
e5d32a69
 endif
c853f68a
 
 .PHONY: link_clean
 link_clean:
 	-@rm -f $(LIB_RUNTIME_NAME)
 	-@rm -f $(LIB_LINK_NAME)
 
8ca5d8dd
 local-clean: link_clean
c853f68a
 
da33ba73
 .PHONY: libiname_clean
 libiname_clean:
8ca5d8dd
 	-@rm -f libiname.lst
da33ba73
 
8ca5d8dd
 local-clean: libiname_clean
da33ba73
 
28b28d2c
 $(lib_prefix)/$(lib_dir):
 	mkdir -p $(lib_prefix)/$(lib_dir)
c853f68a
 
 .PHONY: install
da33ba73
 install: $(LIB_NAME) $(lib_prefix)/$(lib_dir) $(LIBINAME_F)
e5d32a69
 ifeq ($(OS), freebsd)
 	$(INSTALL_TOUCH) $(lib_prefix)/$(lib_dir)/$(LIB_RUNTIME_NAME)
 	$(INSTALL_LIB) $(LIB_NAME) $(lib_prefix)/$(lib_dir)/$(LIB_RUNTIME_NAME)
 	rm -f $(lib_prefix)/$(lib_dir)/$(LIB_LINK_NAME)
 	cd $(lib_prefix)/$(lib_dir) ; ln -s $(LIB_RUNTIME_NAME) $(LIB_LINK_NAME)
 else
28b28d2c
 	$(INSTALL_TOUCH) $(lib_prefix)/$(lib_dir)/$(LIB_NAME)
 	$(INSTALL_LIB) $(LIB_NAME) $(lib_prefix)/$(lib_dir)
 	rm -f $(lib_prefix)/$(lib_dir)/$(LIB_RUNTIME_NAME) \
 			$(lib_prefix)/$(lib_dir)/$(LIB_LINK_NAME) 
893fd82d
 	cd $(lib_prefix)/$(lib_dir) ; ln -s $(LIB_NAME) $(LIB_RUNTIME_NAME) 
 	cd $(lib_prefix)/$(lib_dir) ; ln -s $(LIB_NAME) $(LIB_LINK_NAME) 
e5d32a69
 endif
c853f68a
 
3922c022
 
 .PHONY:install-if-newer
1b5b2a85
 install-if-newer: $(lib_prefix)/$(lib_dir)/$(LIB_RUNTIME_NAME)
3922c022
 
1b5b2a85
 $(lib_prefix)/$(lib_dir)/$(LIB_RUNTIME_NAME): $(LIB_NAME) $(LIBINAME_F)
 	@$(MAKE) install
da33ba73
 
 
 ifneq ($(strip $(LIBINAME_F)),)
 $(LIBINAME_F): $(ALLDEP)
 	@echo "COMPILED_INAME:=$(LIB_INSTALL_NAME)" > $(LIBINAME_F)
 endif
7742b1d2
 
 endif # ifeq ($(makefile_defs),1)
 include $(COREPATH)/Makefile.cfg