Whamcloud - gitweb
LU-6142 lnet: use list_first_entry() where appropriate.
[fs/lustre-release.git] / autoMakefile.am
1 # SPDX-License-Identifier: GPL-2.0
2
3 #
4 # This file is part of Lustre, http://www.lustre.org/
5 #
6 # autoMakefile.am
7 #
8 # Used by automake to create the top-level autoMakefile.in,
9 # which is used by config.status to create the top-level
10 # autoMakefile
11 #
12
13 SUBDIRS := @LDISKFS_SUBDIR@ \
14         . \
15         @LUSTREIOKIT_SUBDIR@ \
16         libcfs \
17         @SNMP_SUBDIR@ \
18         lnet \
19         lustre
20
21 DIST_SUBDIRS := ldiskfs \
22         lustre-iokit \
23         libcfs \
24         @SNMP_DIST_SUBDIR@ \
25         lnet \
26         lustre \
27         config
28
29 AUTOMAKE_OPTIONS = foreign
30
31 if DEQUOTE_CC_VERSION_TEXT
32 DEQUOTE = yes
33 endif
34
35 FIND_TAG_FILES_CMD = find $(top_srcdir) \
36                      -path $(top_srcdir)/ldiskfs/linux-stage \
37                      -prune -false -o -type f -name '*.[hc]'
38
39 # these empty rules are needed so that automake doesn't add its own
40 # recursive rules
41 etags-recursive:
42
43 ctags-recursive:
44
45 tags-recursive:
46
47 TAGS: etags
48
49 tags: ctags etags
50
51 etags:
52         $(RM) $(top_srcdir)/TAGS
53         ETAGSF=`etags --version | grep -iq exuberant && \
54                 echo "-I __initdata,__exitdata,EXPORT_SYMBOL"`; \
55         $(FIND_TAG_FILES_CMD) | xargs etags $$ETAGSF -a
56
57 ctags:
58         $(RM) $(top_srcdir)/tags
59         CTAGSF=`ctags --version | grep -iq exuberant && \
60                 echo "-I __initdata,__exitdata,EXPORT_SYMBOL"`; \
61         $(FIND_TAG_FILES_CMD) | xargs ctags $$CTAGSF -a
62
63 cscope-recursive:
64
65 cscope:
66         $(RM) $(top_srcdir)/cscope*.out $(top_srcdir)/cscope.files
67         $(FIND_TAG_FILES_CMD) > cscope.files
68         cscope -bRq
69
70 mkid:
71         $(FIND_TAG_FILES_CMD) | xargs mkid
72
73
74 if MODULES
75 .PHONY: ldiskfs-sources
76
77 ldiskfs-sources:
78 if LDISKFS_ENABLED
79         $(MAKE) sources -C @LDISKFS_SUBDIR@ || exit $$?
80 endif
81
82 if LINUX
83 all-am: modules
84
85 modules: undef.h ldiskfs-sources
86         $(MAKE) DEQUOTE_CC_VERSION_TEXT=$(DEQUOTE) \
87         LDFLAGS= CC="$(CC)" -C $(LINUX_OBJ) \
88         -f $(PWD)/build/Makefile LUSTRE_LINUX_CONFIG=$(LINUX_CONFIG) \
89         LINUXINCLUDE='-I$$(srctree)/arch/$$(SRCARCH)/include -Iarch/$$(SRCARCH)/include/generated -Iinclude $$(if $$(KBUILD_SRC)$$(building_out_of_srctree),-Iinclude2 -I$$(srctree)/include) -I$$(srctree)/arch/$$(SRCARCH)/include/uapi -Iarch/$$(SRCARCH)/include/generated/uapi -I$$(srctree)/include/uapi -Iinclude/generated/uapi -include $(CONFIG_INCLUDE)' \
90         $(MODULE_TARGET)=$(PWD) -o tmp_include_depends -o scripts -o \
91         include/config/MARKER $@
92 endif # LINUX
93
94 endif # MODULES
95
96 all: undef.h
97
98 undef.h: config.h.in
99         grep -v config.h.in config.h.in > $@
100
101 dist-hook: undef.h
102         find $(distdir) -name .deps -o \
103                         -name CVS -o \
104                         -name .svn -o \
105                         -name .git -o \
106                         -name .#* -exec rm -rf {} \;
107
108 EXTRA_DIST = @PACKAGE_TARNAME@.spec     \
109         build/Makefile                  \
110         build/Rules.in                  \
111         config.h.in                     \
112         lustre-dkms_pre-build.sh        \
113         lustre-dkms_post-build.sh       \
114         LUSTRE-VERSION-GEN              \
115         LUSTRE-VERSION-FILE             \
116         undef.h                         \
117         autogen.sh                      \
118         config/lustre-version.m4
119
120 # contrib is a directory.  Putting a directory in EXTRA_DIST
121 # recursively includes the entire directory contents in the
122 # distribution tarball (the tarball created with "make dist").
123 EXTRA_DIST += contrib
124 EXTRA_DIST += rpm
125
126 rpm-local:
127         @(if test -z "$(RPMBUILD)"; then \
128                 echo -e "\n" \
129         "*** Required util 'rpmbuild' missing. Please install the\n" \
130         "*** package for your distribution which provides 'rpmbuild',\n" \
131         "*** re-run configure, and try again.\n"; \
132                 exit 1; \
133         fi; \
134         $(MKDIR_P) $(rpmbuilddir)/TMP   && \
135         $(MKDIR_P) $(rpmbuilddir)/BUILD && \
136         $(MKDIR_P) $(rpmbuilddir)/RPMS  && \
137         $(MKDIR_P) $(rpmbuilddir)/SRPMS && \
138         $(MKDIR_P) $(rpmbuilddir)/SPECS && \
139         $(MKDIR_P) $(rpmbuilddir)/SOURCES)
140
141 if SERVER
142 dkms-srpm: $(PACKAGE)-dkms.spec dist Makefile
143         rpmbuilddir=`mktemp -t -d rpmbuild-@PACKAGE@-$$USER-XXXXXXXX`; \
144         $(MAKE) $(AM_MAKEFLAGS) \
145                 rpmbuilddir="$$rpmbuilddir" rpm-local || exit 1; \
146         $(RPMBUILD) \
147                 --define "_tmppath $$rpmbuilddir/TMP" \
148                 --define "_topdir $$rpmbuilddir" \
149                 --define "_sourcedir $(top_srcdir)" \
150                 --with servers --with zfs -without ldiskfs \
151                 --bs $(PACKAGE)-dkms.spec || exit 1; \
152         $(RPMBUILD) \
153                 --define "_tmppath $$rpmbuilddir/TMP" \
154                 --define "_topdir $$rpmbuilddir" \
155                 --define "_sourcedir $(top_srcdir)" \
156                 --with servers --without zfs --with ldiskfs \
157                 --bs $(PACKAGE)-dkms.spec || exit 1; \
158         $(RPMBUILD) \
159                 --define "_tmppath $$rpmbuilddir/TMP" \
160                 --define "_topdir $$rpmbuilddir" \
161                 --define "_sourcedir $(top_srcdir)" \
162                 --with servers --with zfs --with ldiskfs \
163                 --bs $(PACKAGE)-dkms.spec || exit 1; \
164         cp $$rpmbuilddir/SRPMS/*.src.rpm $(top_srcdir) || exit 1; \
165         rm -rf $$rpmbuilddir
166
167 dkms-rpm: dkms-srpm
168         rpmbuilddir=`mktemp -t -d rpmbuild-@PACKAGE@-$$USER-XXXXXXXX`; \
169         $(RPMBUILD) \
170                 --define "_tmppath $$rpmbuilddir/TMP" \
171                 --define "_topdir $$rpmbuilddir" \
172                 @RPMBUILD_BINARY_ARGS@ \
173                 --with servers --with zfs --without ldiskfs \
174                 --rebuild $(PACKAGE)-zfs-dkms-*.src.rpm || exit 1; \
175         $(RPMBUILD) \
176                 --define "_tmppath $$rpmbuilddir/TMP" \
177                 --define "_topdir $$rpmbuilddir" \
178                 @RPMBUILD_BINARY_ARGS@ \
179                 --with servers --without zfs --with ldiskfs \
180                 --rebuild $(PACKAGE)-ldiskfs-dkms-*.src.rpm || exit 1; \
181         $(RPMBUILD) \
182                 --define "_tmppath $$rpmbuilddir/TMP" \
183                 --define "_topdir $$rpmbuilddir" \
184                 @RPMBUILD_BINARY_ARGS@ \
185                 --with servers --with zfs --with ldiskfs \
186                 --rebuild $(PACKAGE)-all-dkms-*.src.rpm || exit 1; \
187         cp $$rpmbuilddir/RPMS/*/*.rpm $(top_srcdir) || exit 1; \
188         rm -rf $$rpmbuilddir
189 else
190
191 dkms-srpm: $(PACKAGE)-dkms.spec dist Makefile
192         rpmbuilddir=`mktemp -t -d rpmbuild-@PACKAGE@-$$USER-XXXXXXXX`; \
193         $(MAKE) $(AM_MAKEFLAGS) \
194                 rpmbuilddir="$$rpmbuilddir" rpm-local || exit 1; \
195         $(RPMBUILD) \
196                 --define "_tmppath $$rpmbuilddir/TMP" \
197                 --define "_topdir $$rpmbuilddir" \
198                 --define "_sourcedir $(top_srcdir)" \
199                 --without servers \
200                 --bs $(PACKAGE)-dkms.spec || exit 1; \
201         cp $$rpmbuilddir/SRPMS/*.src.rpm $(top_srcdir) || exit 1; \
202         rm -rf $$rpmbuilddir
203
204 dkms-rpm: dkms-srpm
205         rpmbuilddir=`mktemp -t -d rpmbuild-@PACKAGE@-$$USER-XXXXXXXX`; \
206         $(RPMBUILD) \
207                 --define "_tmppath $$rpmbuilddir/TMP" \
208                 --define "_topdir $$rpmbuilddir" \
209                 @RPMBUILD_BINARY_ARGS@ \
210                 --without servers \
211                 --rebuild $(PACKAGE)-client-dkms-*.src.rpm || exit 1; \
212         cp $$rpmbuilddir/RPMS/*/*.rpm $(top_srcdir) || exit 1; \
213         rm -rf $$rpmbuilddir
214
215 endif
216
217 dkms-srpms: dkms-srpm
218
219 dkms-rpms: dkms-rpm
220
221 rpms: srpm
222         rpmbuilddir=`mktemp -t -d rpmbuild-@PACKAGE@-$$USER-XXXXXXXX`; \
223         if test "x@CONFIG_CACHE_FILE@" != "x"; then \
224                 export CONFIG_CACHE_FILE="@CONFIG_CACHE_FILE@"; \
225         fi; \
226         $(MAKE) $(AM_MAKEFLAGS) \
227                 rpmbuilddir="$$rpmbuilddir" rpm-local || exit 1; \
228         $(RPMBUILD) \
229                 --define "_tmppath $$rpmbuilddir/TMP" \
230                 --define "_topdir $$rpmbuilddir" \
231                 @RPMBUILD_BINARY_ARGS@ \
232                 --rebuild $(distdir)-*.src.rpm || exit 1; \
233         cp $$rpmbuilddir/RPMS/*/*.rpm $(top_srcdir) || exit 1; \
234         rm -rf $$rpmbuilddir
235
236 srpm: @PACKAGE_TARNAME@.spec dist Makefile
237         rpmbuilddir=`mktemp -t -d rpmbuild-@PACKAGE@-$$USER-XXXXXXXX`; \
238         $(MAKE) $(AM_MAKEFLAGS) \
239                 rpmbuilddir="$$rpmbuilddir" rpm-local || exit 1; \
240         cp $(top_srcdir)/rpm/* $(top_srcdir); \
241         $(RPMBUILD) \
242                 --define "_tmppath $$rpmbuilddir/TMP" \
243                 --define "_topdir $$rpmbuilddir" \
244                 --define "dist %{nil}" \
245                 -ts $(distdir).tar.gz || exit 1; \
246         cp $$rpmbuilddir/SRPMS/$(distdir)-*.src.rpm $(top_srcdir) || exit 1; \
247         rm -rf $$rpmbuilddir
248
249 debs_common:
250         export SRC_GIT_HASH=$$(git log --oneline | head -1 | cut -d' ' -f1); \
251         rm -f /usr/src/lustre-$${SRC_GIT_HASH}.tar.bz2; \
252         if test -f /usr/src/lustre-$${SRC_GIT_HASH}.tar.bz2; then \
253                 echo "************************************************************" ; \
254                 echo "WARNING: move or remove /usr/src/lustre-$${SRC_GIT_HASH}.tar.bz2" ; \
255                 echo "************************************************************" ; \
256                 exit 1 ; \
257         fi
258 # In the debs target, first make sure what's in the changelog reflects
259 # the software version.
260 debs: undef.h debs_common
261         cp -v debian/changelog.in debian/changelog ; \
262         export SRC_GIT_HASH=$$(git log --oneline | head -1 | cut -d' ' -f1); \
263         lversion=$$(echo @VERSION@ | tr '_' '-'); \
264         cversion=$$(sed -ne '1s/^lustre (\(.*\)-[0-9][0-9]*).*$$/\1/p' debian/changelog); \
265         if [ "$$lversion" != "$$cversion" ]; then \
266                 echo -e "1i\nlustre ($$lversion-1) unstable; urgency=low\n\n  * Automated changelog entry update\n\n -- Andreas Dilger <adilger@whamcloud.com>  $$(date -R)\n\n.\nwq" | ed debian/changelog; \
267         fi; \
268         rm -rf debs; \
269         if test "x@ENABLE_SERVER@" = "xyes"; then \
270                 DEB_BUILD_PROFILES="server"; \
271         else \
272                 DEB_BUILD_PROFILES="client"; \
273         fi; \
274         if test "x@ENABLE_LDISKFS@" = "xyes"; then \
275                 export DEB_BUILD_PROFILES="$${DEB_BUILD_PROFILES} ldiskfs"; \
276         fi; \
277         if test "x@ENABLE_ZFS@" = "xyes"; then \
278                 export DEB_BUILD_PROFILES="$${DEB_BUILD_PROFILES} zfs"; \
279                 export SPL_SRC="@SPL@"; \
280                 export ZFS_SRC="@ZFS@"; \
281                 echo "ZFS support is enabled. Will expect pre-compiled SPL and ZFS sources in:"; \
282                 echo "SPL: $${SPL_SRC}"; \
283                 echo "ZFS: $${ZFS_SRC}"; \
284         fi; \
285         if test "x@ENABLEO2IB@" != "xno"; then \
286                 export DEB_BUILD_PROFILES="$${DEB_BUILD_PROFILES} o2ib"; \
287                 export O2IB_SRC="@O2IBPATH@"; \
288         fi; \
289         if test "x@CONFIG_CACHE_FILE@" != "x"; then \
290                 export CONFIG_CACHE_FILE="@CONFIG_CACHE_FILE@"; \
291         fi; \
292         if test "x@ENABLE_GSS@" = "xyes"; then \
293                 export DEB_BUILD_PROFILES="$${DEB_BUILD_PROFILES} gss"; \
294                 debiantmp=$$(mktemp -t -d debbuild-$$USER-XXXXXXXX) ; \
295                 cp debian/control $$debiantmp/control.bkp ; \
296                 cp debian/control.main $$debiantmp/control.main.bkp ; \
297                 cp debian/control.modules.in $$debiantmp/control.modules.in.bkp ; \
298                 sed -i "s+^\(Build-Depends: .*\)$$+\1, libkrb5-dev, libssl-dev+" debian/control.main ; \
299                 awk 'BEGIN{change=0} $$1 == "Package:" {if (($$2 == "lustre-client-utils") || ($$2 == "lustre-server-utils")) change=1; else change=0; fi } {if (($$1 == "Depends:") && change) print $$0 ", libgssapi-krb5-2, libkrb5-3, libssl1.1|libssl3"; else print; fi}' debian/control.main > $$debiantmp/control.main && mv $$debiantmp/control.main debian/control.main ; \
300                 sed -i "s+^\(Build-Depends: .*\)$$+\1, libkrb5-dev, libssl-dev+" debian/control.modules.in ; \
301         elif test "x@ENABLE_GSS@" = "xno"; then \
302                 export DEB_BUILD_PROFILES="$${DEB_BUILD_PROFILES} nogss"; \
303         fi; \
304         if test "x@ENABLE_CRYPTO@" = "xyes"; then \
305                 export DEB_BUILD_PROFILES="$${DEB_BUILD_PROFILES} crypto"; \
306         elif test "x@ENABLE_CRYPTO@" = "xno"; then \
307                 export DEB_BUILD_PROFILES="$${DEB_BUILD_PROFILES} nocrypto"; \
308         fi; \
309         if test "x@systemdsystemunitdir@" != "x"; then \
310                 export DEB_BUILD_PROFILES="$${DEB_BUILD_PROFILES} systemd"; \
311         fi; \
312         export KERNEL_OBJ="$(LINUX_OBJ)"; \
313         export KERNEL_SRC="$(LINUX)"; \
314         echo "Enabled Build Profiles: $${DEB_BUILD_PROFILES}"; \
315         echo "Kernel Source: $${KERNEL_SRC}"; \
316         echo "Kernel Object: $${KERNEL_OBJ}"; \
317         if test "x@ENABLEO2IB@" = "xno"; then \
318                 export IB_OPTIONS="--with-o2ib=no"; \
319         else \
320                 if test "x@ENABLEO2IB@" != "xyes" && \
321                    test -n "@O2IBPATH@"; then \
322                         export IB_OPTIONS="--with-o2ib=@O2IBPATH@"; \
323                 else \
324                         export IB_OPTIONS="--with-o2ib=yes"; \
325                 fi; \
326         fi; \
327         dpkg-buildpackage -us -uc -I.git -I\*.out[0-9]\* -I\*.swp || { \
328                 rc=$${PIPESTATUS[0]}; \
329                 cp $$debiantmp/control.bkp debian/control || true && \
330                 cp $$debiantmp/control.main.bkp debian/control.main || true && \
331                 cp $$debiantmp/control.modules.in.bkp debian/control.modules.in || true && \
332                 [ $${rc} -gt 1 ] && exit $${rc}; \
333                 exit 0; \
334         }; \
335         cp $$debiantmp/control.bkp debian/control || true && \
336         cp $$debiantmp/control.main.bkp debian/control.main || true && \
337         cp $$debiantmp/control.modules.in.bkp debian/control.modules.in || true && \
338         export KPKG_DEST_DIR="$$(pwd)/.." && \
339         version=$$(sed -ne '1s/^lustre (\(.*\)).*$$/\1/p' debian/changelog) && \
340         rm -rf debian/tmp/modules-deb && \
341         mkdir debian/tmp/modules-deb && \
342         pushd debian/tmp/modules-deb && \
343         dpkg -x ../../../../lustre-source_$${version}_all.deb $$(pwd) && \
344         mkdir usr_src/ && \
345         tar -C usr_src/ -xjf usr/src/lustre-$${SRC_GIT_HASH}.tar.bz2 && \
346         chmod 755 usr_src/modules/lustre/debian/rules && \
347         mkdir -p usr_share_modass && \
348         ln -s /usr/share/modass/include/ usr_share_modass/ && \
349         ln -s /usr/share/modass/packages/ usr_share_modass/ && \
350         echo "lustre" > usr_share_modass/compliant.list && \
351         export MA_DIR=$$(pwd)/usr_share_modass && \
352         KVERS=$${KVERS:-$(LINUXRELEASE)} && \
353         export KSRC_TREE=$(LINUX) && \
354         KSRC=$${KSRC:-$(LINUX_OBJ)} && \
355         TARBALL=$$(realpath usr/src/lustre-$${SRC_GIT_HASH}.tar.bz2) \
356         m-a build $${KSRC:+-k $$KSRC} $${KVERS:+-l $$KVERS} -i -u $$(pwd) lustre && \
357         popd && \
358         VER=$$(sed -ne '1s/^lustre (\(.*-[0-9][0-9]*\)).*$$/\1/p' debian/changelog) && \
359         if test "x@ENABLE_SERVER@" = "xyes"; then \
360                 DEB_SERVER_PKG="../lustre-resource-agents_$${VER}_*.deb"; \
361         fi; \
362         mkdir -p debs && \
363         mv ../lustre-dev_$${VER}_*.deb ../lustre-source_$${VER}_all.deb \
364            ../lustre-iokit_$${VER}_*.deb ../lustre-tests_$${VER}_*.deb \
365            ../lustre-*-utils_$${VER}_*.deb $${DEB_SERVER_PKG} \
366            ../lustre_$${VER}.dsc ../lustre_$${VER}_*.changes \
367            ../lustre_$${VER}.tar.gz ../lustre-*-modules-$${KVERS}_$${VER}_*.deb \
368            debs/
369
370 dkms-debs: undef.h debs_common
371         cp -v debian/changelog.in debian/changelog ; \
372         export SRC_GIT_HASH=$$(git log --oneline | head -1 | cut -d' ' -f1); \
373         lversion=$$(echo @VERSION@ | tr '_' '-'); \
374         cversion=$$(sed -ne '1s/^lustre (\(.*\)-[0-9][0-9]*).*$$/\1/p' debian/changelog); \
375         if [ "$$lversion" != "$$cversion" ]; then \
376                 echo -e "1i\nlustre ($$lversion-1) unstable; urgency=low\n\n  * Automated changelog entry update\n\n -- Brian J. Murrell <brian@interlinx.bc.ca>  $$(date -R)\n\n.\nwq" | ed debian/changelog; \
377         fi; \
378         rm -rf debs; \
379         export DEB_BUILD_PROFILES="client"; \
380         export KERNEL_OBJ="$(LINUX_OBJ)"; \
381         export KERNEL_SRC="$(LINUX)"; \
382         echo "Enabled Build Profiles: $${DEB_BUILD_PROFILES}"; \
383         echo "Kernel Source: $${KERNEL_SRC}"; \
384         echo "Kernel Object: $${KERNEL_OBJ}"; \
385         export BUILD_DKMS="true" && \
386         dpkg-buildpackage -us -uc -I.git -I\*.out[0-9]\* -I\*.swp || { \
387                 rc=$${PIPESTATUS[0]}; \
388                 [ $${rc} -gt 1 ] && exit $${rc}; \
389                 exit 0; \
390         }; \
391         VER=$$(sed -ne '1s/^lustre (\(.*-[0-9][0-9]*\)).*$$/\1/p' debian/changelog) && \
392         mkdir -p debs && \
393         mv ../lustre-dev_$${VER}_*.deb ../lustre-source_$${VER}_all.deb \
394            ../lustre-iokit_$${VER}_*.deb ../lustre-tests_$${VER}_*.deb \
395            ../lustre-*-utils_$${VER}_*.deb \
396            ../lustre_$${VER}.dsc ../lustre_$${VER}_*.changes \
397            ../lustre_$${VER}.tar.gz ../lustre-*-modules-dkms_$${VER}_*.deb \
398            debs/
399
400 EXTRA_DIST += debian/*
401
402 CSTK=/tmp/checkstack
403 CSTKO=/tmp/checkstack.orig
404
405 checkstack:
406         [ -f ${CSTK} -a ! -s ${CSTKO} ] && mv -f ${CSTK} ${CSTKO} || true
407         { for MOD in $$(find . -name "*.ko"); do                             \
408                 objdump -d $$MOD | perl contrib/scripts/checkstack.pl;       \
409           done } | grep -v " bug " | sort -nr | uniq > ${CSTK}
410         [ -f ${CSTKO} ] && ! diff -u ${CSTKO} ${CSTK} || head -n 30 ${CSTK}
411
412 checkstack-update:
413         [ -f ${CSTK} ] && mv -f ${CSTK} ${CSTKO}
414
415 checkstack-clean:
416         rm -f ${CSTK} ${CSTKO}