1SUBDIR += accessibility
2SUBDIR += archivers
3SUBDIR += astro
4SUBDIR += audio
5SUBDIR += benchmarks
6SUBDIR += biology
7SUBDIR += cad
8SUBDIR += chinese
9SUBDIR += comms
10SUBDIR += converters
11SUBDIR += core
12SUBDIR += databases
13SUBDIR += deskutils
14SUBDIR += devel
15SUBDIR += dns
16SUBDIR += editors
17SUBDIR += emulators
18SUBDIR += filesystems
19SUBDIR += finance
20SUBDIR += french
21SUBDIR += ftp
22SUBDIR += games
23SUBDIR += german
24SUBDIR += graphics
25SUBDIR += irc
26SUBDIR += japanese
27SUBDIR += java
28SUBDIR += lang
29SUBDIR += mail
30SUBDIR += math
31SUBDIR += misc
32SUBDIR += multimedia
33SUBDIR += net
34SUBDIR += net-im
35SUBDIR += net-mgmt
36SUBDIR += net-p2p
37SUBDIR += news
38SUBDIR += ports-mgmt
39SUBDIR += print
40SUBDIR += science
41SUBDIR += security
42SUBDIR += shells
43SUBDIR += sysutils
44SUBDIR += textproc
45SUBDIR += www
46SUBDIR += x11
47SUBDIR += x11-clocks
48SUBDIR += x11-drivers
49SUBDIR += x11-fm
50SUBDIR += x11-fonts
51SUBDIR += x11-servers
52SUBDIR += x11-themes
53SUBDIR += x11-toolkits
54SUBDIR += x11-wm
55
56PORTSTOP=	yes
57
58.include <bsd.port.subdir.mk>
59
60index: 	${INDEXDIR}/${INDEXFILE}
61
62INDEX_COMPRESSION_FORMAT?=	xz
63
64.if ${INDEX_COMPRESSION_FORMAT} != xz && \
65	${INDEX_COMPRESSION_FORMAT} != bz2 && ${INDEX_COMPRESSION_FORMAT} != zst
66.error "Invalid compression format: ${INDEX_COMPRESSION_FORMAT}, expecting xz, bz2 or zst"
67.endif
68
69fetchindex: ${INDEXDIR}/${INDEXFILE}.${INDEX_COMPRESSION_FORMAT}
70	@if bsdcat < ${INDEXDIR}/${INDEXFILE}.${INDEX_COMPRESSION_FORMAT} > ${INDEXDIR}/${INDEXFILE}.tmp ; then \
71		chmod a+r ${INDEXDIR}/${INDEXFILE}.tmp; \
72		${MV} ${INDEXDIR}/${INDEXFILE}.tmp ${INDEXDIR}/${INDEXFILE}; \
73		${RM} ${INDEXDIR}/${INDEXFILE}.${INDEX_COMPRESSION_FORMAT} \
74	else ; \
75		${RM} ${INDEXDIR}/${INDEXFILE}.tmp ; \
76	fi
77
78${INDEXDIR}/${INDEXFILE}.${INDEX_COMPRESSION_FORMAT}: .PHONY
79	${FETCHINDEX} ${INDEXDIR}/${INDEXFILE}.${INDEX_COMPRESSION_FORMAT} \
80		${MASTER_SITE_INDEX}${INDEXFILE}.${INDEX_COMPRESSION_FORMAT}
81
82MASTER_SITE_INDEX?=	https://www.MidnightBSD.org/ports/
83SETENV?=	/usr/bin/env
84FETCHINDEX?=	${SETENV} ${FETCH_ENV} fetch -am -o
85
86.if !defined(INDEX_JOBS)
87INDEX_JOBS!=	${SYSCTL} -n kern.smp.cpus
88.endif
89
90.if !defined(INDEX_VERBOSE)
91INDEX_ECHO_MSG=		true
92INDEX_ECHO_1ST=		echo -n
93.else
94INDEX_ECHO_MSG=		echo 1>&2
95INDEX_ECHO_1ST=		echo
96.endif
97
98# /rescue/sh is statically linked and much faster to execute than the
99# dynamically linked /bin/sh.  This is significant for targets like
100# make index that execute the shell tens of thousands of times.
101.if exists(/rescue/sh)
102INDEX_SHELL=		/rescue/sh
103.else
104INDEX_SHELL=		/bin/sh
105.endif
106
107.if !defined(INDEX_PORTS)
108INDEX_PORTS=.
109.endif
110
111.if exists(/usr/libexec/make_index)
112MAKE_INDEX=	/usr/libexec/make_index /dev/stdin
113.else
114MAKE_INDEX=	perl ${.CURDIR}/Tools/make_index
115.endif
116
117${INDEXDIR}/${INDEXFILE}: .PHONY
118	@${INDEX_ECHO_1ST} "Generating ${INDEXFILE} - please wait.."; \
119	if [ "${INDEX_PRISTINE}" != "" ]; then \
120		export LOCALBASE=/nonexistentlocal; \
121	fi; \
122	tmpdir=`/usr/bin/mktemp -d -t index` || exit 1; \
123	trap "rm -rf $${tmpdir}; exit 1" 1 2 3 5 10 13 15; \
124	( cd ${.CURDIR}; for i in ${INDEX_PORTS}; do (cd $${i} && ${MAKE} -j${INDEX_JOBS} INDEX_TMPDIR=$${tmpdir} BUILDING_INDEX=1 \
125		__MAKE_SHELL=${INDEX_SHELL} \
126		ECHO_MSG="${INDEX_ECHO_MSG}" describe); done ) || \
127		(rm -rf $${tmpdir} ; \
128		if [ "${INDEX_QUIET}" = "" ]; then \
129			echo; \
130			echo "********************************************************************"; \
131			echo "Before reporting this error, verify that you are running a supported"; \
132			echo "version of MidnightBSD (see http://www.MidnightBSD.org/ports/) "; \
133			echo "and that you have a complete and up-to-date ports collection.  "; \
134			echo; \
135			echo "Note: the latest pre-generated version of INDEX may be fetched"; \
136			echo "automatically with \"make fetchindex\"."; \
137			echo "********************************************************************"; \
138			echo; \
139		fi; \
140		exit 1); \
141	cat $${tmpdir}/${INDEXFILE}.desc.* | \
142		sed -e 's|${.CURDIR}|${PORTSDIR}|g' | \
143		(cd ${.CURDIR} ; ${MAKE_INDEX}) | \
144		sed -e 's/  */ /g' -e 's/|  */|/g' -e 's/  *|/|/g' -e 's./..g' | \
145		sort -t '|' -k 2,3 | \
146		sed -Ee 's../.g' -e ':a' -e 's|/[^/]+/\.\.||; ta' \
147		-e 's|${PORTSDIR}|/usr/mports|g' \
148		-e 's|${.CURDIR}|/usr/mports|g' > ${INDEXDIR}/${INDEXFILE}.tmp; \
149	if [ "${INDEX_PRISTINE}" != "" ]; then \
150		sed -e "s,$${LOCALBASE},/usr/local," ${INDEXDIR}/${INDEXFILE}.tmp > ${INDEXDIR}/${INDEXFILE}; \
151	else \
152		mv ${INDEXDIR}/${INDEXFILE}.tmp ${INDEXDIR}/${INDEXFILE}; \
153	fi; \
154	rm -rf $${tmpdir}; \
155	echo " Done."
156
157print-index:	${INDEXDIR}/${INDEXFILE}
158	@awk -F\| '{ printf("Port:\t%s\nPath:\t%s\nInfo:\t%s\nMaint:\t%s\nIndex:\t%s\nB-deps:\t%s\nR-deps:\t%s\nE-deps:\t%s\nP-deps:\t%s\nF-deps:\t%s\nWWW:\t%s\n\n", $$1, $$2, $$4, $$6, $$7, $$8, $$9, $$11, $$12, $$13, $$10); }' < ${INDEXDIR}/${INDEXFILE}
159
160GIT?= git
161.if !defined(SVN) || empty(SVN)
162. for _P in /usr/bin /usr/local/bin
163.  for _S in svn svnlite
164.   if exists(${_P}/${_S})
165SVN=   ${_P}/${_S}
166.   endif
167.  endfor
168. endfor
169.endif
170RSYNC?= rsync
171PORTSNAP?= portsnap
172PORTSNAP_FLAGS?= -p ${.CURDIR}
173.if !target(update)
174update:
175.if exists(${.CURDIR}/.svn)
176	@echo "--------------------------------------------------------------"
177	@echo ">>> Updating ${.CURDIR} using Subversion"
178	@echo "--------------------------------------------------------------"
179	cd ${.CURDIR}; ${SVN} update
180.elif exists(${.CURDIR}/.git)
181.  if exists(${.CURDIR}/.git/svn)
182	@echo "--------------------------------------------------------------"
183	@echo ">>> Updating ${.CURDIR} from git+svn repository"
184	@echo "--------------------------------------------------------------"
185	cd ${.CURDIR}; ${GIT} svn rebase
186.  else
187	@echo "--------------------------------------------------------------"
188	@echo ">>> Updating ${.CURDIR} from git repository"
189	@echo "--------------------------------------------------------------"
190	cd ${.CURDIR}; ${GIT} pull --rebase
191.  endif
192.elif defined(RSYNC_UPDATE) && defined(PORTS_RSYNC_SOURCE)
193	@echo "--------------------------------------------------------------"
194	@echo ">>> Updating with ${RSYNC} from ${PORTS_RSYNC_SOURCE}"
195	@echo "--------------------------------------------------------------"
196	@${RSYNC} ${RSYNC_FLAGS} ${PORTS_RSYNC_SOURCE}/ ${.CURDIR}/
197.else
198	@echo "--------------------------------------------------------------"
199	@echo ">>> Running ${PORTSNAP}"
200	@echo "--------------------------------------------------------------"
201.if !exists(${PORTSDIR}/.portsnap.INDEX)
202	@echo "Error: 'make update' uses portsnap(8) by default and"
203	@echo "needs ${PORTSDIR} to be created by portsnap on its first run."
204	@echo "Please run 'portsnap fetch extract' first."
205.else
206	@${PORTSNAP} ${PORTSNAP_FLAGS} fetch
207	@${PORTSNAP} ${PORTSNAP_FLAGS} update
208.endif
209.endif
210.endif
211