File: depfun.mak

package info (click to toggle)
bidentd 1.1.4-1.1
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd, sid, stretch, wheezy
  • size: 276 kB
  • sloc: php: 498; cpp: 266; sh: 54; makefile: 47
file content (197 lines) | stat: -rw-r--r-- 7,597 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
# This is Bisqwit's generic depfun.mak, included from Makefile.
# The same file is used in many different projects.
#
# depfun.mak version 1.6.1
#
# Required vars:
#
#  ${CPP}        - C preprocessor name, usually "gcc"
#  ${CPPFLAGS}   - preprocessor flags (including defs)
#
#  ${ARCHFILES}  - All file names to include in archive
#                  .depend, depfun.mak and Makefile are
#                  automatically included.
#  ${ARCHNAME}   - Name of program. Example: testprog-0.0.1
#
# Optional vars:
#
#  ${ARCHDIR}       - Directory for the archives.
#                     Must end with '/'.
#  ${INSTALLPROGS}  - Programs to be installed (space delimited)
#  ${BINDIR}        - Directory for installed programs (without /)
#                     Example: /usr/local/bin
#  ${INSTALL}       - Installer program, example: install
#  ${DEPDIRS}       - Optional dependency dirs to account in .depend
#
#  ${EXTRA_ARCHFILES} - More files to include in archive,
#                       but without dependency checking


# Note: This requires perl. FIXME change it to sed
.depend: ${ARCHFILES}
	@echo "Checking dependencies..."
	@rm -f $@.tmp
	@for dir in "" ${DEPDIRS}; \
	 do n="`pwd`";\
	    if [ ! -z "$$dir" ]; then cd "$$dir"; fi; \
	    for s in *.c *.cc *.cpp; \
	    do if echo "$$s"|grep -vq '^\*';\
	       then \
	       cd "$$n";\
	       ${CPP} ${CPPFLAGS} -MM -MG "$$dir""$$s" |\
	        perl -pe "s|^([^ ])|$$dir\\1|" \
	         > $@."$$s";\
	    fi&done; \
	    cd "$$n"; \
	 done; wait
	@touch $@.dummy
	@cat $@.* >$@
	@cp -f $@ $@.tmp
	@sed 's/\.o:/.lo:/' <$@.tmp >>$@
	@rm -f $@.*

depend dep: .depend


-include .depend

git_release: ${ARCHFILES} ;
	# Create the release commit
	git commit --allow-empty -a -m 'Release version ${VERSION} (dev)' # commit in dev brach
	git rev-parse HEAD > .git/PUSHED_HEAD
	git checkout release || git checkout -b release
	 #
	 # Set the cache & index to exact copy of the original branch
	 #
	 git rm -fr --cached '*' &> /dev/null
	 git checkout PUSHED_HEAD .
	 #
	 # Limit the index to those files we publish
	 #
	 git rm -fr --cached '*' &> /dev/null
	 git add -f --ignore-errors ${ARCHFILES} ${EXTRA_ARCHFILES} depfun.mak Makefile
	 @if [ -f docmaker.php ]; then php -q docmaker.php ${ARCHNAME} > README.html; git add docmaker.php README.html; fi
	 @if [ -f makediff.php ]; then git add makediff.php; fi
	 #
	 # Create a merge commit
	 #
	 cp .git/PUSHED_HEAD .git/MERGE_HEAD
	 git commit -m 'Release version ${VERSION}' # commit in release
	 #
	 # Create the archive
	 #
	 @- mkdir ${ARCHDIR} 2>/dev/null
	 git archive --format=tar --prefix=${ARCHNAME}/ HEAD > ${ARCHDIR}${ARCHNAME}.tar
	# Return to the original branch
	git checkout -f $$(cd .git/refs/heads;grep -l `cat ../../PUSHED_HEAD` * || echo PUSHED_HEAD)
	git update-server-info
	@make arch_finish_pak
	@make omabin_link${DEPFUN_OMABIN}

git_test_release: ${ARCHFILES}
	# Create the testing commit
	git commit --allow-empty -a -m 'Test release ${VERSION} (dev)' # commit in dev branch
	git rev-parse HEAD > .git/PUSHED_HEAD
	git checkout release || git checkout -b release
	 # 
	 # Backup the HEAD in release branch
	 #
	 git rev-parse release > .git/RELEASE_HEAD
	 #
	 # Set the cache & index to exact copy of the original branch
	 #
	 git rm -fr --cached '*' &> /dev/null
	 git checkout PUSHED_HEAD .
	 #
	 # Limit the index to those files we publish
	 #
	 git rm -fr --cached '*' &> /dev/null
	 git add -f --ignore-errors ${ARCHFILES} ${EXTRA_ARCHFILES} depfun.mak Makefile
	 @if [ -f docmaker.php ]; then php -q docmaker.php ${ARCHNAME} > README.html; git add docmaker.php README.html; fi
	 @if [ -f makediff.php ]; then git add makediff.php; fi
	 #
	 # Create a merge commit
	 #
	 cp .git/PUSHED_HEAD .git/MERGE_HEAD
	 git commit -m 'Test release' # commit in release
	 #
	 # Create the testing directory
	 #
	 rm -rf test_release
	 git archive --format=tar --prefix=test_release/ HEAD | tar xvf - | sed 's/^/	/'
	 #
	 # Reset the release branch to its previous state
	 #
	 git reset --hard RELEASE_HEAD
	# Return to the original branch
	git checkout -f $$(cd .git/refs/heads;grep -l `cat ../../PUSHED_HEAD` * || echo PUSHED_HEAD)
	git update-server-info
	git gc --quiet
	@echo
	@echo ----------------------------------------------------------------------
	@echo 'Would-be release extracted to test_release/ -- go ahead and try it.'
	@echo ----------------------------------------------------------------------
	@echo

UNUSED_archpak: ${ARCHFILES} ;
	@if [ "${ARCHNAME}" = "" ]; then echo ARCHNAME not set\!;false;fi
	- mkdir ${ARCHNAME} ${ARCHDIR} 2>/dev/null
	cp --parents -lfr ${ARCHFILES} ${EXTRA_ARCHFILES} depfun.mak Makefile ${ARCHNAME}/ 2>&1 >/dev/null | while read line;do cp --parents -fr "`echo "$$line"|sed 's/.*${ARCHNAME}\///;s/'\''.*//'`" ${ARCHNAME}/; done
	- if [ -f docmaker.php ]; then php -q docmaker.php ${ARCHNAME} >README.html; ln -f docmaker.php README.html ${ARCHNAME}/;fi
	if [ -f makediff.php ]; then ln -f makediff.php ${ARCHNAME}/; fi
	#- rm -f ${ARCHDIR}${ARCHNAME}.zip
	#- zip -9rq ${ARCHDIR}${ARCHNAME}.zip ${ARCHNAME}/
	#- rar a ${ARCHDIR}${ARCHNAME}.rar -mm -m5 -r -s -inul ${ARCHNAME}/
	#tar cf ${ARCHDIR}${ARCHNAME}.tar ${ARCHNAME}/
	#
	find ${ARCHNAME}/ -type d > .paktmp.txt
	find ${ARCHNAME}/ -not -type d | rev | sort | rev >> .paktmp.txt
	#find ${ARCHNAME}/|/ftp/backup/bsort >.paktmp.txt
	tar -c --no-recursion -f ${ARCHDIR}${ARCHNAME}.tar -T.paktmp.txt
	rm -rf .paktmp.txt ${ARCHNAME}
	@make arch_finish_pak

arch_finish_pak:	
	- if [ "${NOBZIP2ARCHIVES}" = "" ]; then bzip2 -9 >${ARCHDIR}${ARCHNAME}.tar.bz2 < ${ARCHDIR}${ARCHNAME}.tar; fi
	if [ "${NOGZIPARCHIVES}" = "" ]; then gzip -f9 ${ARCHDIR}${ARCHNAME}.tar; fi
	rm -f ${ARCHDIR}${ARCHNAME}.tar

# Makes the packages of various types...
UNUSED_pak: archpak ;
	if [ -f makediff.php ]; then php -q makediff.php ${ARCHNAME} ${ARCHDIR} 1; fi

omabin_link${DEPFUN_OMABIN}:
	- @rm -f /WWW/src/arch/${ARCHNAME}.tar.{bz2,gz}
	- ln -f ${ARCHDIR}${ARCHNAME}.tar.{bz2,gz} /WWW/src/arch/
	if [ -f progdesc.php ]; then cp -p --remove-destination progdesc.php /WWW/src/.desc-$(subst /,,$(dir $(subst -,/,$(ARCHNAME)))).php 2>/dev/null || cp -fp progdesc.php /WWW/src/.desc-$(subst /,,$(dir $(subst -,/,$(ARCHNAME)))).php; fi

# This is Bisqwit's method to install the packages to web-server...
UNUSED_omabin${DEPFUN_OMABIN}: archpak
	if [ -f makediff.php ]; then php -q makediff.php ${ARCHNAME} ${ARCHDIR}; fi
	#- @rm -f /WWW/src/arch/${ARCHNAME}.{zip,rar,tar.{bz2,gz}}
	#- ln -f ${ARCHDIR}${ARCHNAME}.{zip,rar,tar.{bz2,gz}} /WWW/src/arch/
	@make omabin_link${DEPFUN_OMABIN}

install${DEPFUN_INSTALL}: ${INSTALLPROGS}
	- if [ ! "${BINDIR}" = "" ]; then mkdir --parents $(BINDIR) 2>/dev/null; mkdir $(BINDIR) 2>/dev/null; \
	   for s in ${INSTALLPROGS} ""; do if [ ! "$$s" = "" ]; then \
	     ${INSTALL} -c -s -o bin -g bin -m 755 "$$s" ${BINDIR}/"$$s";fi;\
	   done; \
	  fi; \
	  if [ ! "${MANDIR}" = "" ]; then mkdir --parents $(MANDIR) 2>/dev/null; mkdir $(MANDIR) 2>/dev/null; \
	   for s in ${INSTALLMANS} ""; do if [ ! "$$s" = "" ]; then \
	     ${INSTALL} -m 644 "$$s" ${MANDIR}/man"`echo "$$s"|sed 's/.*\.//'`"/"$$s";fi;\
	   done; \
	  fi
	
uninstall${DEPFUN_INSTALL} deinstall${DEPFUN_INSTALL}:
	for s in ${INSTALLPROGS}; do rm -f ${BINDIR}/"$$s";done
	- for s in ${INSTALLLIBS}; do rm -f ${LIBDIR}/"$$s";done
	for s in ${INSTALLMANS} ""; do if [ ! "$$s" = "" ]; then \
	  rm -f ${MANDIR}/man"`echo "$$s"|sed 's/.*\.//'`"/"$$s";fi;\
	done; \

.PHONY: pak dep depend archpak omabin \
	install${DEPFUN_INSTALL} \
	deinstall${DEPFUN_INSTALL} \
	uninstall${DEPFUN_INSTALL}