summaryrefslogblamecommitdiffstats
path: root/Makefile
blob: 9bf5b8ffeada6690b97b807c4e820c6655207bf8 (plain) (tree)
1
2
3
4
5
6
7
8
9

                     
 




                                       
 

                                         
 
                        
 














                                                                        
 



                                      
 



















                                                                        

                  
                                                                               
                                                  
 


                              
            
                                           
                       
                                                        



                                                                         


                               
 





                                                
 
             
                                         












                                                                    
 

                                                           

                 







                                            
PACKAGE :=	quilt
VERSION :=	0.21

prefix :=	/usr/local
bindir :=	$(prefix)/bin
datadir :=	$(prefix)/share
mandir :=	$(datadir)/man
docdir :=	$(datadir)/doc/packages

QUILT_DIR =	$(datadir)/$(PACKAGE)
LIB_DIR =	$(datadir)/$(PACKAGE)/lib

CFLAGS =	-g -Wall

#-----------------------------------------------------------------------
SRC +=		COPYING AUTHORS TODO BUGS Makefile \
		quilt.spec quilt.changes \
		misc/akmp-patch-scripts-0.9.tar.gz \
		misc/jr-quilt-0.1.0.tar.bz2 \
		misc/test.tar.gz

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

QUILT_IN :=	add applied delete diff files import new next patches \
		pop previous push refresh remove rest series setup top

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

LIB_IN :=	apatch rpatch patchfns 
LIB_SRC :=	$(LIB_IN:%=%.in) parse-patch spec2series \
		backup-files.c
LIB :=		$(LIB_IN) parse-patch spec2series backup-files
SRC +=		$(LIB_SRC:%=lib/%)
DIRT +=		$(LIB_IN:%=lib/%) lib/backup-files{,.o}

DOC_IN :=	README
DOC_SRC :=	$(DOC_IN:%=%.in)
DOC :=		$(DOC_IN) docco.txt
SRC +=		$(DOC_SRC) docco.txt
DIRT +=		$(DOC_IN)

MAN1 :=		bin/guards.1
#-----------------------------------------------------------------------

all : scripts

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

README : README.in
	@awk '/@REFERENCE@/ { system("$(MAKE) -s reference") ; next }'$$'\n'' \
			   { print }' 2>&1 $< > $@

.PHONY :: reference
reference : $(QUILT:%=quilt/%)
	@for i in $+; \
	do \
		echo "$$i >> README" >&2; \
		echo; \
		(bash -c ". lib/patchfns ; . $$i -h"); \
	done | \
	awk '/Usage:/	{ sub(/Usage: ?/, "") ; print ; next } '$$'\n'' \
	     		{ printf "  %s\n", $$0 }'
		
bin/guards.1 : bin/guards
	mkdir -p $$(dirname $@)
	pod2man $< > $@

dist :
	rm -f $(PACKAGE)-$(VERSION)
	ln -s . $(PACKAGE)-$(VERSION)
	tar cvfz $(PACKAGE)-$(VERSION).tar.gz \
		$(SRC:%=$(PACKAGE)-$(VERSION)/%)
	rm -f $(PACKAGE)-$(VERSION)

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

	install -d $(BUILD_ROOT)$(QUILT_DIR)
	install -m 755 $(QUILT:%=quilt/%) $(BUILD_ROOT)$(QUILT_DIR)/

	install -d $(BUILD_ROOT)$(LIB_DIR)
	install -m 755 $(filter-out lib/patchfns lib/backup-files, \
			 $(LIB:%=lib/%)) $(BUILD_ROOT)$(LIB_DIR)/
	install -m 644 lib/patchfns $(BUILD_ROOT)$(LIB_DIR)/
	install -m 755 -s lib/backup-files $(BUILD_ROOT)$(LIB_DIR)/

	install -d $(BUILD_ROOT)$(docdir)/$(PACKAGE)
	install -m 644 README $(BUILD_ROOT)$(docdir)/$(PACKAGE)/

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

clean distclean :
	rm -f $(DIRT)

% : %.in
	@echo "$< -> $@"
	@sed -e "s:@LIB@:$(LIB_DIR):g" \
	     -e "s:@QUILT@:$(QUILT_DIR):g" \
	     $< > $@
	@chmod --reference=$< $@