summaryrefslogblamecommitdiffstats
path: root/Makefile.in
blob: 2831b29e9a7f04812bcb1101169c18c2725720c3 (plain) (tree)
1
2
3
4
5
6
7
8
9
10









                                        
                        
                              
                                 
                                                    
 
                         


                         

                      

                      
                      
                      
                    

                     


                        
                        
                          
                          
                          
 

                         
                    
                                 



                         
 



                                    
 
                                                                        

                                            
 

                                                                         
                                             
                          
 


                                


                                  
                                                               



                                      
 
                                                                         
                                  
 

                                    

                                                

                                                               
                                                          
 
                                                                           
                              
                                     
                                  
                                                                
 
                      
                                    
                         
                          

                                                                         
                                             
 
                                        
                       
 
                        
                                           
                            
                             
 
                                                                  
                                 
 











                                                                           
 

                                                                        
                                                   
 


                                         




                              
 





                                    
                                                                         
                                                     
 
                                         
 
                                        
 
                                           
                          
 
                                                                         

                                                                         
                                              











                                                                         

                                        
                                                       
                                   








                                                                         
                           
 
                                                        
                                     












                                                                         
 
                   
                                                            








                                                                         
                                
 
                         
                          
 
                                                               
                                      
                                     
                                                               
                                   
                                
 
                                                         





                                                                
                                                                





                                                                         
                                                       
 
                                                                                 
         
                            








                                                                         
                    
                                                          
 
                              
 
                      
                                      
              
 
                                                                                               

                
                   

                                                         




                                                                  

                                                                      





                                                                                
                                                                        
                                     
                                       




                                                                                              
                       

                                                                
 

                                                                                
 





                                                                         
 

                                                                           
 
                                                                   



                                                                         
 

                                                              
 

                                                              

                                                                         
                                                               
 




                                                                             
                                             
                                                               
                           

                                                                         
     

     
                                                                          
                             
                                       





                                                                                        
                                    
 
            






                                                                         
                                                            
 














                                                                         

                     
 
                 
                                               
                              
 
                   
               




                                                                         


            


                                                                         



                                               









                                                                              
PACKAGE :=	@PACKAGE_NAME@
VERSION :=	@PACKAGE_VERSION@
RELEASE :=	@PACKAGE_RELEASE@
PACKAGE_BUGREPORT := @PACKAGE_BUGREPORT@

prefix :=	@prefix@
exec_prefix :=	@exec_prefix@
bindir :=	@bindir@
libdir :=	@libdir@
datadir :=	@datadir@
docdir :=	@docdir@
mandir :=	$(datadir)/man
localedir :=	$(datadir)/locale
etcdir :=	$(subst /usr/etc,/etc,$(prefix)/etc)

INSTALL :=	@INSTALL@
POD2MAN :=	@POD2MAN@
COLUMN :=	@COLUMN@
GETOPT :=	@GETOPT@
CP :=		@CP@
DATE :=		@DATE@
PERL :=		@PERL@
BASH :=		@BASH@
GREP :=		@GREP@
TAIL :=		@TAIL@
TR :=		@TR@
SED :=		@SED@
AWK :=		@AWK@
DIFF :=		@DIFF@
PATCH :=	@PATCH@
MKTEMP :=	@MKTEMP@
MSGFMT :=	@MSGFMT@
DIFFSTAT :=	@DIFFSTAT@
RPMBUILD :=	@RPMBUILD@
SENDMAIL :=	@SENDMAIL@

USE_NLS :=	@USE_NLS@

CC :=		@CC@
CPPFLAGS +=	@CPPFLAGS@ @DEFS@
CFLAGS +=	@CFLAGS@
LDFLAGS +=	@LDFLAGS@
LIBS :=		@LIBS@
EXEEXT :=	@EXEEXT@

COMPAT_SYMLINKS	:= @COMPAT_SYMLINKS@
COMPAT_PROGRAMS	:= @COMPAT_PROGRAMS@

default: all

#-----------------------------------------------------------------------
DIRT +=		$(shell find . -name '*~')
DIRT +=		$(shell find . -name '.\#*')

SRC +=		COPYING AUTHORS TODO Makefile.in configure.ac		\
		config/install-sh quilt.spec.in quilt.changes		\
		bash_completion quilt.quiltrc
DIRT +=		quilt.spec

BIN_IN :=	quilt guards
BIN_SRC :=	$(BIN_IN:%=%.in)
BIN :=		$(BIN_IN)
SRC +=		$(BIN_SRC:%=bin/%)
DIRT +=		$(BIN_IN:%=bin/%)

QUILT_IN :=	$(patsubst quilt/%.in,%,$(wildcard quilt/*.in))
QUILT_SRC :=	$(QUILT_IN:%=%.in)
QUILT :=	$(QUILT_IN)
SRC +=		$(QUILT_SRC:%=quilt/%)
DIRT +=		$(QUILT_IN:%=quilt/%)

SCRIPTS_IN :=	patchfns parse-patch inspect dependency-graph edmail	\
		remove-trailing-ws

SCRIPTS_SRC :=	$(SCRIPTS_IN:%=%.in)
SCRIPTS :=	$(SCRIPTS_IN)
SRC +=		$(SCRIPTS_SRC:%=quilt/scripts/%)
DIRT +=		$(SCRIPTS_IN:%=quilt/scripts/%)

SRC +=		$(wildcard compat/*.in) $(wildcard compat/*.sh)
DIRT +=		$(patsubst %.in,%,$(wildcard compat/*.in))

COMPAT :=	$(COMPAT_PROGRAMS:%=compat/%) $(COMPAT_SYMLINKS:%=compat/%)
LIB_SRC :=	backup-files.c
LIB :=		backup-files$(EXEEXT)
SRC +=		$(LIB_SRC:%=lib/%)
DIRT +=		lib/backup-files$(EXEEXT) $(LIB_SRC:%.c=lib/%.o)

DOC_IN :=	README
DOC_SRC :=	$(DOC_IN:%=doc/%.in)
DOC :=		$(DOC_IN)
SRC +=		$(DOC_SRC)
SRC +=          doc/main.tex doc/quilt.pdf doc/Makefile doc/quilt.1.in	\
		doc/README.MAIL
DIRT +=		$(DOC_IN:%=doc/%) doc/quilt.1

MAN1 :=		bin/guards.1 doc/quilt.1
DIRT +=		$(MAN1)

LINGUAS :=	fr de ja
PO :=		quilt.pot $(LINGUAS:%=%.po)
SRC +=		$(PO:%=po/%)
DIRT +=         po/*.mo po/*~

SRC +=		$(wildcard test/*.test) test/run test/test.quiltrc
SRC +=		changes2changelog

NON_EXEC_IN :=	doc/quilt.1 doc/README quilt/scripts/patchfns

ISODATE :=	$(shell date +%Y-%m-%d)

TESTS :=	$(wildcard test/*.test)

# Settings for running the uninstalled version of quilt in the source tree:
PATH :=		$(CURDIR)/bin:$(CURDIR)/compat:$(PATH)
QUILT_DIR :=	$(CURDIR)/quilt
QUILT_LIB :=	$(CURDIR)/lib
QUILTRC :=	$(CURDIR)/test/test.quiltrc
export QUILT_DIR QUILT_LIB QUILTRC

#-----------------------------------------------------------------------

all : scripts compat $(DOC:%=doc/%) $(MAN1) mofiles

$(LIB:%=lib/%) : $(LIB_SRC:%.c=lib/%.o)
	$(CC) -o $@ $(LDFLAGS) $^ $(LIBS)

ifeq ($(USE_NLS),yes)
mofiles : $(LINGUAS:%=po/%.mo)
else
mofiles :
endif

%.mo : %.po
	msgfmt --statistics -o $@ $<

%.po : po/quilt.pot
	msgmerge -o $@ $@ $^

scripts : $(BIN:%=bin/%) $(QUILT:%=quilt/%) 				\
	  $(SCRIPTS:%=quilt/scripts/%) $(LIB:%=lib/%)

dist : clean $(PACKAGE)-$(VERSION).tar.gz

snapshot : $(PACKAGE)-$(ISODATE).tar.bz2

rpm rpmbuild : $(PACKAGE)-$(VERSION).tar.gz
	$(RPMBUILD) -ta $<

po/quilt.pot: $(filter-out debian/control.in doc/quilt.1.in		\
			   doc/README.in, $(wildcard */*.in)		\
			   		  $(wildcard */*/*.in))
	rm -f po/quilt.pot; touch po/quilt.pot
	for file in $+ ; do						\
	  if test -n "`$(SED) -ne '1{ /@BASH''@/p }' $$file`"; then	\
	    bash --dump-po-strings $$file ;				\
	  elif test -n "`$(SED) -ne '1{ /@PERL''@/p }' $$file`"; then	\
	    xgettext --from-code=UTF-8 --omit-header --language=Perl	\
	    	     --keyword=_ -o - $$file;				\
	  else								\
	    echo "Don't know how to handle $$file" >&2 ;		\
	    exit 1;							\
	  fi								\
	done								\
	|msguniq							\
	|msgcat --force-po -F - $@ -o $@

doc/README : doc/README.in $(QUILT:%=quilt/%) $(COMPAT)
	@echo "README.in -> README"
	@while read line; do						\
		case "$$line" in					\
		'@REFERENCE''@')					\
			$(MAKE) -s reference				\
			;;						\
		*)							\
			echo $$line					\
			;;						\
		esac ;							\
	done 2>&1 < $< > $@

doc/quilt.1: doc/quilt.1.in $(QUILT:%=quilt/%) $(COMPAT)
	@echo "quilt.1.in -> quilt.1"
	while read line; do						\
	  case "$$line" in						\
	  '@REFERENCE''@')						\
	    $(MAKE) -s reference |					\
	    sed -e 's/^quilt \([^ ]*\)\(.*\)/.IP "\\fB\1\\fP\2 " 4/'	\
		-e $$'s/^  \\(-[^\t]*\\)\t\\?/.IP "    \\1" 8\\\n/'	\
		-e $$'s/^  \t\\?//'					\
	    ;;								\
	  *)								\
	    echo "$$line"						\
	    ;;								\
	  esac;								\
	done < $< 2>&1 > $@

.PHONY :: reference
reference : $(QUILT:%=quilt/%) quilt/scripts/patchfns compat
	@unset LANG LC_MESSAGES LC_CTYPE LC_ALL;			\
	for i in $(QUILT);						\
	do								\
		echo;							\
		quilt $$i -h;						\
		echo;							\
	done |								\
	sed -e 's/\$$EDITOR ([^)]*)/$$EDITOR/'				\
	    -e '/^$$/!s/^/  /'						\
	    -e 's/^  Usage: *//'

bin/guards.1 : bin/guards
	$(POD2MAN) $< > $@

$(PACKAGE)-$(VERSION).tar.gz : $(SRC) configure $(PACKAGE).spec
	rm -f $(PACKAGE)-$(VERSION) $@
	ln -s . $(PACKAGE)-$(VERSION)
	tar chf - $(+:%=$(PACKAGE)-$(VERSION)/%) | gzip -9 > $@
	rm -f $(PACKAGE)-$(VERSION)
	@echo "File $@ created."

$(PACKAGE)-$(ISODATE).tar.bz2 : configure $(PACKAGE).spec
	rm -f $(PACKAGE)-$(ISODATE) $@
	ln -s . $(PACKAGE)-$(ISODATE)
	tar chf - $(+:%=$(PACKAGE)-$(ISODATE)/%) | bzip2 -9 > $@
	rm -f $(PACKAGE)-$(ISODATE)
	@echo "File $@ created."

$(PACKAGE).spec : $(PACKAGE).spec.in $(PACKAGE).changes Makefile
	@echo "Generating spec file" ;					\
	set -e ;							\
	changelog="`./changes2changelog $(PACKAGE).changes`" ;		\
	awk '{ gsub(/@VERSION''@/, "$(VERSION)") ;			\
	       gsub(/@RELEASE''@/, "$(RELEASE)") ;			\
	       gsub(/@CHANGELOG''@/, changelog) ;			\
	       print }' changelog="$$changelog" $< > $@

$(patsubst %.in,%,$(wildcard bin/*.in quilt/*.in quilt/scripts/*.in)) :: Makefile
% :: %.in
	@echo "$< -> $@" >&2
	@sed -e 's:@QUILT_LIB''@:$(libdir)/$(PACKAGE):g'		\
	     -e 's:@QUILT_DIR''@:$(datadir)/$(PACKAGE):g'		\
	     -e 's:@PERL''@:$(PERL):g'					\
	     -e 's:@BASH''@:$(BASH):g'					\
	     -e 's:@VERSION''@:$(VERSION):g'				\
	     -e 's:@RELEASE''@:$(RELEASE):g'				\
	     -e 's:@MTA''@:$(MTA):g'					\
	     -e 's:@LOCALEDIR''@:$(localedir):g'			\
	     -e 's:@DOCSUBDIR''@:$(docdir)/$(PACKAGE)-$(VERSION):g'	\
	     $< > $@
	@$(if $(filter-out $<,$(NON_EXEC_IN)),chmod +x $@)

lib/backup-files.o :: Makefile

Makefile : Makefile.in
	@echo "Please run ./configure"
	@false

compat_leftover := $(filter-out $(COMPAT),$(shell find compat/ -maxdepth 1 -type f -perm +111))

.PHONY :: compat
compat :: $(COMPAT)
	$(if $(compat_leftover),rm -f $(compat_leftover))

# VIRTUAL_SYMLINKS creates a shell script that operates similar to
# a symbolic link.  It is used to workaround the way make treats
# symlinks as targets.
#   Usage: $(call VIRTUAL_SYMLINK, source, target)
define VIRTUAL_SYMLINK
	@echo "Generating $(strip $(1)) wrapper" >&2;
	@printf "#!%s\n%s "'"$$$$@"'"\n" $(BASH) $(strip $(1)) > $(2);
endef

# Generate rules to create compat/<binary> for each binary in $(COMPAT_SYMLINKS)
define COMPAT_SYMLINK_local_install
compat/$(strip $(1)) : Makefile
	$(call VIRTUAL_SYMLINK, \
		$($(shell echo $(1) | $(AWK) '{print toupper($$1)}')), \
		compat/$(strip $(1)))
	@chmod +x compat/$(strip $(1));

endef

$(eval $(foreach symlink,$(COMPAT_SYMLINKS),$(call COMPAT_SYMLINK_local_install, $(symlink))))

install-main :: scripts
	$(INSTALL) -d $(BUILD_ROOT)$(bindir)
	$(INSTALL) -m 755 $(BIN:%=bin/%) $(BUILD_ROOT)$(bindir)/

	$(INSTALL) -d $(BUILD_ROOT)$(datadir)/$(PACKAGE)
	$(INSTALL) -m 755 $(QUILT:%=quilt/%) $(BUILD_ROOT)$(datadir)/$(PACKAGE)/

	$(INSTALL) -d $(BUILD_ROOT)$(datadir)/$(PACKAGE)/scripts
	$(INSTALL) -m 755 $(patsubst %,quilt/scripts/%,			\
			  $(filter-out patchfns,$(SCRIPTS)))		\
		   $(BUILD_ROOT)$(datadir)/$(PACKAGE)/scripts
	$(INSTALL) -m 644 quilt/scripts/patchfns			\
		   $(BUILD_ROOT)$(datadir)/$(PACKAGE)/scripts

	$(INSTALL) -d $(BUILD_ROOT)$(libdir)/$(PACKAGE)
	$(INSTALL) -m 755 $(LIB:%=lib/%) $(BUILD_ROOT)$(libdir)/$(PACKAGE)/

	$(INSTALL) -d $(BUILD_ROOT)$(docdir)/$(PACKAGE)-$(VERSION)/
	$(INSTALL) -m 644 doc/README					\
		   $(BUILD_ROOT)$(docdir)/$(PACKAGE)-$(VERSION)/
	$(INSTALL) -m 644 doc/quilt.pdf doc/README.MAIL			\
		   $(BUILD_ROOT)$(docdir)/$(PACKAGE)-$(VERSION)/

	$(INSTALL) -d $(BUILD_ROOT)$(mandir)/man1
	$(INSTALL) -m 644 $(MAN1) $(BUILD_ROOT)$(mandir)/man1/

	$(INSTALL) -d $(BUILD_ROOT)$(etcdir)
	$(INSTALL) -d $(BUILD_ROOT)$(etcdir)/bash_completion.d
	$(INSTALL) -m 644 bash_completion				\
		   $(BUILD_ROOT)$(etcdir)/bash_completion.d/quilt
	$(INSTALL) -m 644 quilt.quiltrc $(BUILD_ROOT)$(etcdir)/

install-compat: install-compat1 $(COMPAT_SYMLINKS:%=install-compat-symlink-%)
$(COMPAT_SYMLINKS:%=install-compat-symlink-%) :: install-compat1

install-compat1:
	rm -rf $(BUILD_ROOT)$(datadir)/$(PACKAGE)/compat
ifneq ($(COMPAT_PROGRAMS)$(COMPAT_SYMLINKS),)
	$(INSTALL) -d $(BUILD_ROOT)$(datadir)/$(PACKAGE)/compat
ifneq ($(COMPAT_PROGRAMS),)
	$(INSTALL) -m 755 $(COMPAT_PROGRAMS:%=compat/%)			\
		   $(BUILD_ROOT)$(datadir)/$(PACKAGE)/compat
endif
endif

# Generate rules to install symlinks for each binary in $(COMPAT_SYMLINKS)
define COMPAT_SYMLINK_install
install-compat-symlink-$(strip $(1)) ::
	ln -sf $($(shell echo $(1) | $(AWK) '{print toupper($$1)}'))	\
	       $(BUILD_ROOT)$(datadir)/$(PACKAGE)/compat/$(strip $(1))
endef

$(foreach symlink,$(COMPAT_SYMLINKS),$(eval $(call COMPAT_SYMLINK_install, $(symlink))))

install: install-main install-compat

uninstall ::
	rm -rf $(BIN:%=$(BUILD_ROOT)$(bindir)/%)			\
	       $(BUILD_ROOT)$(libdir)/$(PACKAGE)			\
	       $(BUILD_ROOT)$(datadir)/$(PACKAGE)			\
	       $(patsubst %,$(BUILD_ROOT)$(mandir)/man1/%,		\
		   $(notdir $(MAN1)))					\
	       $(BUILD_ROOT)$(etcdir)/bash_completion.d/quilt		\
	       $(BUILD_ROOT)$(etcdir)/quilt.quiltrc			\
	       $(BUILD_ROOT)$(docdir)/$(PACKAGE)-$(VERSION)/

.PHONY :: $(TESTS:%=check-%)
check: $(TESTS:%=check-%)

ifneq ($(shell . $(QUILTRC) ;  echo $$QUILT_PATCHES_PREFIX),)
CHECK_ENV := P=patches/; _P=../patches/; export P _P
endif

$(TESTS:%=check-%): scripts
	@echo "[$(@F)]"
	@LANG=C;							\
	export LANG ;							\
	$(CHECK_ENV);							\
	cd $(patsubst check-%,%,$(@D));					\
	./run $(@F)

clean :
	rm -f $(DIRT)

distclean : clean
	rm -f config.log config.status Makefile
	rm -rf autom4te.cache/

ifeq ($(USE_NLS),1)
install-main ::
	for lang in $(LINGUAS) ; do					\
		dir=$(BUILD_ROOT)$(localedir)/$$lang/LC_MESSAGES;	\
		install -d $$dir;					\
		install -m 644 po/$$lang.mo				\
		    $$dir/quilt.mo ;					\
	done

uninstall ::
	for lang in $(LINGUAS) ; do					\
		dir=$(BUILD_ROOT)$(localedir)/$$lang/LC_MESSAGES;	\
		rm -f $$dir/quilt.mo ;					\
	done
endif

.PHONY :: all install uninstall clean distclean

# Clear the suffix list
.SUFFIXES:
.SUFFIXES: .c .o .in
# Bad gmake, never *ever* try to get a file out of source control by yourself.
%: %,v
%: RCS/%,v
%: RCS/%
%: s.%
%: SCCS/s.%