libnode/Makefile.rule
2010-06-06 21:28:14 +00:00

360 lines
9.2 KiB
Makefile

# $RCSfile: Makefile.rule,v $
# $Revision: 1.5 $
# $Name: $
# $Date: 2010/06/06 21:28:14 $
# $Author: agibert $
#------------------------------------------------------------------------------
# Rule Makefile
#------------------------------------------------------------------------------
# ----------------- DEFAULT RULES ---------------------
default:all
# ----------------- IMPLICITES RULES ---------------------
# Here are all the rules allowing to compile sources files
# c -> o
%.o:%.c
$(CC) $(CFLAGS) $(INCLUDE) -fPIC -c $< -o $@
# c -> executable
.c :
$(CC) $(CFLAGS) $(INCLUDE) $< -o $@ -I . $(LIB)
# o -> executable
%:%.o
$(CC) $(LFLAGS) -o $@ $? $(LIB)
# .o -> .so
%.so:%.o
$(CC) $(LDSOFLAGS) -shared -o $@ $? $(LIB)
%.a:%.o
$(AR) -r $@ $?
$(OBJECTS) : $(SRC)
# "depend" rule allow to build the dependancy file
depend:
# "all" Rule
all: dir_all
ifneq ($(SUBDIRS),)
for d in $(SUBDIRS) ; do $(MAKE) all -C $$d/ ; done
endif
dir_all: $(TARGETS)
# "clean" Rule
clean: dir_clean
ifneq ($(SUBDIRS),)
for d in $(SUBDIRS) ; do $(MAKE) clean -C $$d/ ; done
endif
dir_clean:
@(command="$(RM) $(TARGETS) $$(echo $(SRC) | sed "s/\.c/\.o/g") ;" ; \
echo $$command ; \
eval $$command ;)
# "pre_install" Rule
# This empty rule can be overiden in module Makefile in order to run pre-install commands.
pre_install:
# "post_install" Rule
# This empty rule can be overiden in module Makefile in order to run post-install commands.
post_install:
# "install" Rule
install: dir_install
ifneq ($(SUBDIRS),)
for d in $(SUBDIRS) ; do $(MAKE) install -C $$d/ ; done
endif
dir_install: dir_all
$(MAKE) pre_install
ifneq ($(FILE_BIN),)
@if test ! -d $(PATH_BIN) ; then $(MKDIR) $(PATH_BIN) ; fi
$(INSTALLBIN) $(FILE_BIN) $(PATH_BIN)
endif
ifneq ($(FILE_BINSUID),)
@if test ! -d $(PATH_BINSUID) ; then $(MKDIR) $(PATH_BINSUID) ; fi
$(INSTALLBINSUID) $(FILE_BINSUID) $(PATH_BINSUID)
endif
ifneq ($(FILE_CGI),)
@if test ! -d $(PATH_CGI) ; then $(MKDIR) $(PATH_CGI) ; fi
$(INSTALLCGI) $(FILE_CGI) $(PATH_CGI)
endif
ifneq ($(FILE_DOC),)
@if test ! -d $(PATH_DOC) ; then $(MKDIR) $(PATH_DOC) ; fi
$(INSTALLDOC) $(FILE_DOC) $(PATH_DOC)
endif
ifneq ($(FILE_ETC),)
@if test ! -d $(PATH_ETC) ; then $(MKDIR) $(PATH_ETC) ; fi
$(INSTALLETC) $(FILE_ETC) $(PATH_ETC)
endif
ifneq ($(FILE_HOME),)
@if test ! -d $(PATH_HOME) ; then $(MKDIR) $(PATH_HOME) ; fi
$(INSTALLHOME) $(FILE_HOME) $(PATH_HOME)
endif
ifneq ($(FILE_HOMEBIN),)
@if test ! -d $(PATH_HOMEBIN) ; then $(MKDIR) $(PATH_HOMEBIN) ; fi
$(INSTALLHOMEBIN) $(FILE_HOMEBIN) $(PATH_HOMEBIN)
endif
ifneq ($(FILE_LIB),)
@if test ! -d $(PATH_LIB) ; then $(MKDIR) $(PATH_LIB) ; fi
$(INSTALLLIB) $(FILE_LIB) $(PATH_LIB)
endif
ifneq ($(FILE_HOMELIB),)
@if test ! -d $(PATH_HOMELIB) ; then $(MKDIR) $(PATH_HOMELIB) ; fi
$(INSTALLHOMELIB) $(FILE_HOMELIB) $(PATH_HOMELIB)
endif
ifneq ($(FILE_INCLUDE),)
@if test ! -d $(PATH_INCLUDE) ; then $(MKDIR) $(PATH_INCLUDE) ; fi
$(INSTALLINCLUDE) $(FILE_INCLUDE) $(PATH_INCLUDE)
endif
ifneq ($(FILE_MAN),)
@for d in $(FILE_MAN) ; do \
if test ! -d $(PATH_MAN)/$(FILE_MAN) ; then \
$(MKDIR) $(PATH_MAN)/$(FILE_MAN) ; \
fi ; \
$(INSTALLMAN) $(FILE_MAN)/* $(PATH_MAN)/$(FILE_MAN) ; \
done
endif
ifneq ($(FILE_WEBCONF),)
@if test ! -d $(PATH_WEBCONF) ; then $(MKDIR) $(PATH_WEBCONF) ; fi
$(INSTALLWEBCONF) $(FILE_WEBCONF) $(PATH_WEBCONF)
endif
ifneq ($(FILE_WEBCONFSSL),)
@if test ! -d $(PATH_WEBCONFSSL) ; then $(MKDIR) $(PATH_WEBCONFSSL) ; fi
$(INSTALLWEBCONFSSL) $(FILE_WEBCONFSSL) $(PATH_WEBCONFSSL)
endif
ifneq ($(FILE_HTML),)
@if test ! -d $(PATH_HTML) ; then $(MKDIR) $(PATH_HTML) ; fi
$(INSTALLHTML) $(FILE_HTML) $(PATH_HTML)
endif
ifneq ($(FILE_WEBICONS),)
@if test ! -d $(PATH_WEBICONS) ; then $(MKDIR) $(PATH_WEBICONS) ; fi
$(INSTALLWEBICONS) $(FILE_WEBICONS) $(PATH_WEBICONS)
endif
$(MAKE) post_install
# "pre_uninstall" Rule
# This empty rule can be overiden in module Makefile in order to run pre-uninstall commands.
pre_uninstall:
# "post_uninstall" Rule
# This empty rule can be overiden in module Makefile in order to run post-uninstall commands.
post_uninstall:
# "uninstall" Rule
uninstall: dir_uninstall
ifneq ($(SUBDIRS),)
for d in $(SUBDIRS) ; do $(MAKE) uninstall -C $$d/ ; done
endif
dir_uninstall:
$(MAKE) pre_uninstall
ifneq ($(FILE_BIN),)
@(if test -d $(PATH_BIN) ; then \
$(CD) $(PATH_BIN) ; \
(echo $(MAKEFLAGS) | grep s) > /dev/null ; \
if [ $$? -ne 0 ] ; then \
echo "$(CD) $(PATH_BIN)" ; \
echo "$(RM) $(FILE_BIN)" ; \
fi ; \
$(RM) $(FILE_BIN) ; \
fi)
endif
ifneq ($(FILE_BINSUID),)
@(if test -d $(PATH_BINSUID) ; then \
$(CD) $(PATH_BINSUID) ; \
(echo $(MAKEFLAGS) | grep s) > /dev/null ; \
if [ $$? -ne 0 ] ; then \
echo "$(CD) $(PATH_BINSUID)" ; \
echo "$(RM) $(FILE_BINSUID)" ; \
fi ; \
$(RM) $(FILE_BINSUID) ; \
fi)
endif
ifneq ($(FILE_CGI),)
@(if test -d $(PATH_CGI) ; then \
$(CD) $(PATH_CGI) ; \
(echo $(MAKEFLAGS) | grep s) > /dev/null ; \
if [ $$? -ne 0 ] ; then \
echo "$(CD) $(PATH_CGI)" ; \
echo "$(RM) $(FILE_CGI)" ; \
fi ; \
$(RM) $(FILE_CGI) ; \
fi)
endif
ifneq ($(FILE_DOC),)
@(if test -d $(PATH_DOC) ; then \
$(CD) $(PATH_DOC) ; \
(echo $(MAKEFLAGS) | grep s) > /dev/null ; \
if [ $$? -ne 0 ] ; then \
echo "$(CD) $(PATH_DOC)" ; \
echo "$(RM) $(FILE_DOC)" ; \
fi ; \
$(RM) $(FILE_DOC) ; \
fi)
endif
ifneq ($(FILE_ETC),)
@(if test -d $(PATH_ETC) ; then \
$(CD) $(PATH_ETC) ; \
(echo $(MAKEFLAGS) | grep s) > /dev/null ; \
if [ $$? -ne 0 ] ; then \
echo "$(CD) $(PATH_ETC)" ; \
echo "$(RM) $(FILE_ETC)" ; \
fi ; \
$(RM) $(FILE_ETC) ; \
fi)
endif
ifneq ($(FILE_HOME),)
@(if test -d $(PATH_HOME) ; then \
$(CD) $(PATH_HOME) ; \
(echo $(MAKEFLAGS) | grep s) > /dev/null ; \
if [ $$? -ne 0 ] ; then \
echo "$(CD) $(PATH_HOME)" ; \
echo "$(RM) $(FILE_HOME)" ; \
fi ; \
$(RM) $(FILE_HOME) ; \
fi)
endif
ifneq ($(FILE_HOMEBIN),)
@(if test -d $(PATH_HOMEBIN) ; then \
$(CD) $(PATH_HOMEBIN) ; \
(echo $(MAKEFLAGS) | grep s) > /dev/null ; \
if [ $$? -ne 0 ] ; then \
echo "$(CD) $(PATH_HOMEBIN)" ; \
echo "$(RM) $(FILE_HOMEBIN)" ; \
fi ; \
$(RM) $(FILE_HOMEBIN) ; \
fi)
endif
ifneq ($(FILE_LIB),)
@(if test -d $(PATH_LIB) ; then \
$(CD) $(PATH_LIB) ; \
(echo $(MAKEFLAGS) | grep s) > /dev/null ; \
if [ $$? -ne 0 ] ; then \
echo "$(CD) $(PATH_LIB)" ; \
echo "$(RM) $(FILE_LIB)" ; \
fi ; \
$(RM) $(FILE_LIB) ; \
fi)
endif
ifneq ($(FILE_HOMELIB),)
@(if test -d $(PATH_HOMELIB) ; then \
$(CD) $(PATH_HOMELIB) ; \
(echo $(MAKEFLAGS) | grep s) > /dev/null ; \
if [ $$? -ne 0 ] ; then \
echo "$(CD) $(PATH_HOMELIB)" ; \
echo "$(RM) $(FILE_HOMELIB)" ; \
fi ; \
$(RM) $(FILE_HOMELIB) ; \
fi)
endif
ifneq ($(FILE_INCLUDE),)
@(if test -d $(PATH_INCLUDE) ; then \
$(CD) $(PATH_INCLUDE) ; \
(echo $(MAKEFLAGS) | grep s) > /dev/null ; \
if [ $$? -ne 0 ] ; then \
echo "$(CD) $(PATH_INCLUDE)" ; \
echo "$(RM) $(FILE_INCLUDE)" ; \
fi ; \
$(RM) $(FILE_INCLUDE) ; \
fi)
endif
ifneq ($(FILE_MAN),)
@(if test -d $(PATH_MAN) ; then \
$(CD) $(PATH_MAN) ; \
(echo $(MAKEFLAGS) | grep s) > /dev/null ; \
if [ $$? -ne 0 ] ; then \
echo "$(CD) $(PATH_MAN)" ; \
echo "$(RM) $(FILE_MAN)" ; \
fi ; \
$(RM) $(FILE_MAN) ; \
fi)
endif
ifneq ($(FILE_WEBCONF),)
@(if test -d $(PATH_WEBCONF) ; then \
$(CD) $(PATH_WEBCONF) ; \
(echo $(MAKEFLAGS) | grep s) > /dev/null ; \
if [ $$? -ne 0 ] ; then \
echo "$(CD) $(PATH_WEBCONF)" ; \
echo "$(RM) $(FILE_WEBCONF)" ; \
fi ; \
$(RM) $(FILE_WEBCONF) ; \
fi)
endif
ifneq ($(FILE_WEBCONFSSL),)
@(if test -d $(PATH_WEBCONFSSL) ; then \
$(CD) $(PATH_WEBCONFSSL) ; \
(echo $(MAKEFLAGS) | grep s) > /dev/null ; \
if [ $$? -ne 0 ] ; then \
echo "$(CD) $(PATH_WEBCONFSSL)" ; \
echo "$(RM) $(FILE_WEBCONFSSL)" ; \
fi ; \
$(RM) $(FILE_WEBCONFSSL) ; \
fi)
endif
ifneq ($(FILE_HTML),)
@(if test -d $(PATH_HTML) ; then \
$(CD) $(PATH_HTML) ; \
(echo $(MAKEFLAGS) | grep s) > /dev/null ; \
if [ $$? -ne 0 ] ; then \
echo "$(CD) $(PATH_HTML)" ; \
echo "$(RM) $(FILE_HTML)" ; \
fi ; \
$(RM) $(FILE_HTML) ; \
fi)
endif
ifneq ($(FILE_WEBICONS),)
@(if test -d $(PATH_WEBICONS) ; then \
$(CD) $(PATH_WEBICONS) ; \
(echo $(MAKEFLAGS) | grep s) > /dev/null ; \
if [ $$? -ne 0 ] ; then \
echo "$(CD) $(PATH_WEBICONS)" ; \
echo "$(RM) $(FILE_WEBICONS)" ; \
fi ; \
$(RM) $(FILE_WEBICONS) ; \
fi)
endif
$(MAKE) post_uninstall
# "distrib" Rule
distrib:
$(MAKE) clean
$(MKDIR) $(TMP_DIR)/$(PROG_VERSION_NAME)
$(TAR) cf - . | $(TAR) xvpf - -C $(TMP_DIR)/$(PROG_VERSION_NAME)
$(TAR) cvf - -C $(TMP_DIR) --exclude CVS $(PROG_VERSION_NAME) | $(GZIP) -9 >$(PROG_VERSION_NAME).src.tgz
$(TAR) cvf - -C $(TMP_DIR) --exclude CVS $(PROG_VERSION_NAME) | $(BZIP2) -9 >$(PROG_VERSION_NAME).src.tbz2
$(MV) $(TMP_DIR)/$(PROG_VERSION_NAME) .
$(ZIP) -r -m -9 $(PROG_VERSION_NAME).src.zip $(PROG_VERSION_NAME) -x \*/CVS/\*
$(RM) -r $(PROG_VERSION_NAME)