Debian Codegraph @

Makefile

raw ◀ ▶
2 Debian patches touch this file
1 #
2 # This file is provided under a dual BSD/GPLv2 license. When using or
3 # redistributing this file, you may do so under either license.
4 #
5 # GPL LICENSE SUMMARY
6 #
7 # Copyright(c) 2017 Intel Corporation.
8 #
9 # This program is free software; you can redistribute it and/or modify
10 # it under the terms of version 2 of the GNU General Public License as
11 # published by the Free Software Foundation.
12 #
13 # This program is distributed in the hope that it will be useful, but
14 # WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 # General Public License for more details.
17 #
18 # Contact Information:
19 # Intel Corporation, www.intel.com
20 #
21 # BSD LICENSE
22 #
23 # Copyright(c) 2017 Intel Corporation.
24 #
25 # Redistribution and use in source and binary forms, with or without
26 # modification, are permitted provided that the following conditions
27 # are met:
28 #
29 # * Redistributions of source code must retain the above copyright
30 # notice, this list of conditions and the following disclaimer.
31 # * Redistributions in binary form must reproduce the above copyright
32 # notice, this list of conditions and the following disclaimer in
33 # the documentation and/or other materials provided with the
34 # distribution.
35 # * Neither the name of Intel Corporation nor the names of its
36 # contributors may be used to endorse or promote products derived
37 # from this software without specific prior written permission.
38 #
39 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
40 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
41 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
42 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
43 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
45 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
46 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
47 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
48 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
49 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
50 #
51
52
53 HISTORY = .outdirs
54 HISTORIC_TARGETS = $(patsubst %, %_clean, $(shell cat $(HISTORY) 2> /dev/null))
55
56 RPM_NAME := libpsm2
57 CONFIG_FILE := .config
58 TEMP_INST_DIR := $(shell mktemp -d)
59
60 ifeq ($(CONFIG_FILE), $(wildcard $(CONFIG_FILE)))
61 include $(CONFIG_FILE)
62 endif
63
64 PSM_HAL_ENABLE ?= *
65
66 PSM_HAL_ENABLE_D = $(wildcard $(addprefix psm_hal_,$(PSM_HAL_ENABLE)))
67
68 PSM_HAL_INSTANCE_OBJFILES = $(addsuffix /*.o,$(PSM_HAL_ENABLE_D))
69
70 SUBDIRS = ptl_self ptl_ips ptl_am libuuid opa ${wildcard $(PSM_HAL_ENABLE_D)}
71 top_srcdir := $(shell readlink -m .)
72
73 # Default locations
74 OUTDIR := $(top_srcdir)/build_release
75 MOCK_OUTDIR := $(top_srcdir)/build_mock
76 DEBUG_OUTDIR := $(top_srcdir)/build_debug
77
78 # We need a temporary test variable, as the OUTDIR macro
79 # can be overriden by the shell and thus not run.
80 TESTOUTDIR= $(shell readlink -m $(OUTDIR))
81 ifeq ($(top_srcdir), $(TESTOUTDIR))
82 $(error OUTDIR cannot be the same as your source folder ${top_srcdir}))
83 endif
84
85 ifeq (/,$(TESTOUTDIR))
86 $(error OUTDIR cannot be the / folder ))
87 endif
88
89 # Forces any value to be full path.
90 # We don't need to override MOCK_OUTDIR or DEBUG_OUTDIR
91 # as they are recursive make invocations and use OUTDIR
92 ifneq ($(MAKECMDGOALS), mock)
93 ifneq ($(MAKECMDGOALS), debug)
94 override OUTDIR := $(shell readlink -m $(OUTDIR))
95 endif
96 endif
97
98 PSM2_VERNO_MAJOR := $(shell sed -n 's/^\#define.*PSM2_VERNO_MAJOR.*0x0\?\([1-9a-f]\?[0-9a-f]\+\).*/\1/p' $(top_srcdir)/psm2.h)
99 PSM2_VERNO_MINOR := $(shell sed -n 's/^\#define.*PSM2_VERNO_MINOR.*0x\([0-9]\?[0-9a-f]\+\).*/\1/p' $(top_srcdir)/psm2.h)
100 PSM2_LIB_MAJOR := $(shell printf "%d" ${PSM2_VERNO_MAJOR})
101 PSM2_LIB_MINOR := $(shell printf "%d" `sed -n 's/^\#define.*PSM2_VERNO_MINOR.*\(0x[0-9a-f]\+\).*/\1/p' $(top_srcdir)/psm2.h`)
102 LINKER_SCRIPT_FILE = ${OUTDIR}/psm2_linker_script.map
103 SOURCES_CHKSUM_FILES = Makefile buildflags.mak $(LINKER_SCRIPT_FILE) \
104 `find . -regex '\(.*\.h\|.*\.c\)' -not -path "./test/*" -not -path "./tools/*" -not -path "_revision.c" | sort`
105 SOURCES_CHKSUM_VALUE = $(shell cat ${SOURCES_CHKSUM_FILES} | sha1sum | cut -d' ' -f 1)
106 OPA_LIB_MAJOR := 4
107 OPA_LIB_MINOR := 0
108
109 export PSM2_VERNO_MAJOR
110 export PSM2_LIB_MAJOR
111 export PSM2_VERNO_MINOR
112 export PSM2_LIB_MINOR
113 export OPA_LIB_MAJOR
114 export OPA_LIB_MINOR
115 export CCARCH ?= gcc
116 export FCARCH ?= gfortran
117 export AR ?= ar
118
119 include $(top_srcdir)/buildflags.mak
120
121 # We need to unexport these environs as during mock testing and normal calls,
122 # if they are exported then during each submake they will be evaulated again.
123 # This is costly and the LINKER_SCRIPT_FILE doesn't exist until after its
124 # target rule runs.
125 unexport SOURCES_CHKSUM_FILES
126 unexport SOURCES_CHKSUM_VALUE
127 unexport LINKER_SCRIPT_FILE
128 INCLUDES += -I$(top_srcdir) -I$(top_srcdir)/ptl_ips -I$(OUTDIR)
129
130 ifneq (x86_64,$(arch))
131 ifneq (i386,$(arch))
132 $(error Unsupported architecture $(arch))
133 endif
134 endif
135
136 ifndef LIBDIR
137 ifeq (${arch},x86_64)
138 INSTALL_LIB_TARG=/usr/lib64
139 else
140 INSTALL_LIB_TARG=/usr/lib
141 endif
142 else
143 INSTALL_LIB_TARG=${LIBDIR}
144 endif
145 export DESTDIR
146 export INSTALL_LIB_TARG
147
148 TARGLIB := libpsm2
149 COMPATMAJOR := $(shell sed -n 's/^\#define.*PSM2_VERNO_COMPAT_MAJOR.*0x0\?\([1-9a-f]\?[0-9a-f]\+\).*/\1/p' \
150 $(top_srcdir)/psm2.h)
151 COMPATLIB := libpsm_infinipath
152
153 MAJOR := $(PSM2_LIB_MAJOR)
154 MINOR := $(PSM2_LIB_MINOR)
155
156 nthreads := $(shell echo $$(( `nproc` * 2 )) )
157
158 # The following line sets the DISTRO variable to:
159 # 'rhel' if the host is running RHEL.
160 # 'suse' if the host is running SUSE.
161 # 'fedora' if the host is running Fedora.
162 # 'ubuntu' if the host is running Ubuntu.
163 #
164 # The DISTRO variable is used subsequently for variable
165 # behaviors of the 3 distros.
166
•167 DISTRO := $(shell . /etc/os-release; if [ "$$ID" = "sle_hpc" ]; then ID="sles"; fi; echo $$ID)
168
169 # By default the following two variables have the following values:
170 LIBPSM2_COMPAT_CONF_DIR := /etc
171 LIBPSM2_COMPAT_SYM_CONF_DIR := /etc
172 # We can't set SPEC_FILE_RELEASE_DIST to an empty value, a space will result.
173 # It then messes up sed operations for PSM_CUDA=1.
174 # So leaving the commented out line here as documentation to NOT set it.
175 # SPEC_FILE_RELEASE_DIST :=
176 UDEV_40_PSM_RULES := %{_udevrulesdir}/40-psm.rules
177
178 ifeq (fedora,$(DISTRO))
179 # On Fedora, we change these two variables to these values:
180 LIBPSM2_COMPAT_CONF_DIR := /usr/lib
181 LIBPSM2_COMPAT_SYM_CONF_DIR := %{_prefix}/lib
182 SPEC_FILE_RELEASE_DIST := %{?dist}
183 UDEV_40_PSM_RULES :=#
184 else ifeq (rhel,${DISTRO})
185 # Insert code specific to RHEL here.
186 else ifeq (sles,${DISTRO})
187 # Insert code specific to SLES here.
188 endif
189
190 ifdef PSM_CUDA
191 #Value needs to be something without spaces or dashes '-'
192 SPEC_FILE_RELEASE_DIST += cuda
193 endif
194
195 export LIBPSM2_COMPAT_CONF_DIR
196
197 # The desired version number comes from the most recent tag starting with "v"
•198 ifeq (true, false)
199 ISGIT := 1 # Cache the result for later
200 # Note, we don't define ISGIT if we are not in a git folder
201 VERSION := $(shell git describe --tags --abbrev=0 --match='psm-v*' | sed -e 's/^psm-v//' -e 's/-/_/')
202 else
203 ISGIT := 0
204 VERSION := version
205 endif
206
207 # If we have a file called 'rpm_release_extension' (as on github),
208 # we take the release extension number from this file
209 RELEASE_EXT := $(shell if [ -e rpm_release_extension ] ;\
210 then cat rpm_release_extension; fi)
211 CURRENTSHA := $(shell if [ $(ISGIT) = 1 -a -f rpm_release_extension ] ;\
212 then git log --pretty=format:'%h' -n 1; fi)
213 RPMEXTHASH := $(shell if [ $(ISGIT) = 1 -a -f rpm_release_extension ] ;\
214 then git log --pretty=format:'%h' -n 1 rpm_release_extension; fi)
215
216 # This logic should kick-in only on github
217 ifdef RELEASE_EXT
218 ifneq ($(CURRENTSHA), $(RPMEXTHASH))
219 # On github, the last commit for each release should be the one to bump up
220 # the release extension number in 'rpm_release_extension'. Further commits
221 # are counted here and appended to the final rpm name to distinguish commits
222 # present only on github
223 NCOMMITS := $(shell if [ $(ISGIT) = 1 -a -f rpm_release_extension ] ;\
224 then git log --children $(RPMEXTHASH)..$(CURRENTSHA) \
225 --pretty=oneline . | wc -l; fi)
226 RELEASE := $(RELEASE_EXT)_$(NCOMMITS)
227 endif
228 endif
229
230 # The desired release number comes the git describe following the version which
231 # is the number of commits since the version tag was planted suffixed by the g<commitid>
232 ifndef RELEASE
233 RELTAG := "psm-v$(VERSION)"
234 RELEASE := $(shell if [ -f rpm_release_extension ]; then cat rpm_release_extension;\
235 elif [ $(ISGIT) = 1 ] ; then git rev-list $(RELTAG)..HEAD -- . | wc -l; \
236 else echo "release" ; fi)
237 endif
238
239 DIST_SHA := ${shell if [ $(ISGIT) = 1 ] ; then git log -n1 --pretty=format:%H .; \
240 else echo DIST_SHA ; fi}
241
242 # Concatenated version and release
243 ifndef VERSION_RELEASE_OVERRIDE
244 VERSION_RELEASE := $(VERSION).$(RELEASE)
245 else
246 VERSION_RELEASE := ${VERSION_RELEASE_OVERRIDE}
247 endif
248
249 LDLIBS := -lrt -ldl -lnuma ${EXTRA_LIBS} -pthread
250
251 PKG_CONFIG ?= pkg-config
252
253 UDEVDIR := $(shell $(PKG_CONFIG) --variable=udevdir udev 2>/dev/null)
254 ifndef UDEVDIR
255 UDEVDIR = /lib/udev
256 endif
257
258 export UDEVDIR
259
260 # The DIST variable is a name kernel corresponding to:
261 # 1. The name of the directory containing the source code distribution
262 # (see dist: target below).
263 # 2. The basename of the filename of the tar file created in the dist:
264 # target.
265 DIST := ${RPM_NAME}-${VERSION_RELEASE}
266
267 # If user has empty RPM NAME BASEEXT (defined or not), then attempt to
268 # see if we are running on SLES 12.3 or newer.
269 # If we are, then change the base package name, but not the supporting
270 # packages to libpsm2-2. Do note this requires support both in the Makefile
271 # specfile target rule as well as changes in the libpsm2.spec.in
272 # file as well.
273 ifeq ($(RPM_NAME_BASEEXT),)
274 # Detect current version of the OS
275 OS := $(shell grep -m1 NAME /etc/os-release | cut -f 2 -d\")
276 OSVERSION := $(shell grep VERSION_ID /etc/os-release | cut -f 2 -d\" | cut -f 1 -d.)
277 OSSUBVERSION := $(shell grep VERSION_ID /etc/os-release | cut -f 2 -d\" | cut -f 2 -d.)
278
279 override RPM_NAME_BASEEXT := $(shell \
280 if [ "$(OS)" = "SLES" -o "$(OS)" = "SLE_HPC" ]; then \
281 if [ $(OSVERSION) -gt 11 ]; then \
282 if [ $(OSVERSION) -eq 12 ]; then \
283 if [ $(OSSUBVERSION) -gt 2 ]; then \
284 echo "-2"; \
285 fi \
286 else \
287 echo "-2"; \
288 fi \
289 fi \
290 fi)
291 endif
292
293 HALDECLFILE=$(OUTDIR)/psm2_hal_inlines_d.h
294 HALIMPLFILE=$(OUTDIR)/psm2_hal_inlines_i.h
295
296 all: symlinks $(HALDECLFILE) $(HALIMPLFILE) | $(OUTDIR)
297 @if [ ! -e $(HISTORY) ] || [ -z "`grep -E '^$(OUTDIR)$$' $(HISTORY)`" ]; then \
298 echo $(OUTDIR) >> $(HISTORY); \
299 fi
300 # Our buildflags.mak exports all variables, all are propogated to submakes.
301 @for subdir in $(SUBDIRS); do \
302 mkdir -p $(OUTDIR)/$$subdir; \
303 $(MAKE) -j $(nthreads) -C $$subdir OUTDIR=$(OUTDIR)/$$subdir; \
304 if [ $$? -ne 0 ]; then exit 1; fi ;\
305 done
306 $(MAKE) -j $(nthreads) $(OUTDIR)/${TARGLIB}.so
307 $(MAKE) -j $(nthreads) $(OUTDIR)/${TARGLIB}.a
308 @mkdir -p $(OUTDIR)/compat
309 $(MAKE) -j $(nthreads) -C compat OUTDIR=$(OUTDIR)/compat
310
311 $(HALDECLFILE): | $(OUTDIR)
312 @test -f $(HALDECLFILE) || ( \
313 n_hal_insts=$(words $(wildcard $(PSM_HAL_ENABLE_D)));\
314 echo "#define PSMI_HAL_INST_CNT $$n_hal_insts" > $(HALDECLFILE);\
315 if [ $$n_hal_insts -eq 1 ]; then \
316 echo "#define PSMI_HAL_INLINE inline" >> $(HALDECLFILE);\
317 hal_inst_dir=$(PSM_HAL_ENABLE_D); \
318 echo "#define PSMI_HAL_CAT_INL_SYM(KERNEL) hfp_$(subst psm_hal_,,$(PSM_HAL_ENABLE_D))" \
319 "## _ ## KERNEL" >> $(HALDECLFILE);\
320 echo "#include \"psm2_hal_inline_t.h\"" >> $(HALDECLFILE);\
321 else \
322 echo "#define PSMI_HAL_INLINE /* nothing */" >> $(HALDECLFILE);\
323 fi )
324
325 $(HALIMPLFILE): | $(OUTDIR)
326 @test -f $(HALIMPLFILE) || ( \
327 n_hal_insts=$(words $(wildcard $(PSM_HAL_ENABLE_D)));\
328 if [ $$n_hal_insts -eq 1 ]; then\
329 hal_inst=$(PSM_HAL_ENABLE_D);\
330 echo "#include \"$$hal_inst/psm_hal_inline_i.h\"" >> $(HALIMPLFILE);\
331 else\
332 echo "/* no inlining since more than 1 hal instance" >> $(HALIMPLFILE);\
333 echo " is included in the libpsm2 linkage. */" >> $(HALIMPLFILE);\
334 fi )
335
336 %_clean:
337 make OUTDIR=$* clean
338
339 clean: cleanlinks
340 rm -rf ${OUTDIR}
341 @if [ -e $(HISTORY) ]; then \
342 grep -v -E "^$(OUTDIR)$$" $(HISTORY) > $(HISTORY)_tmp; \
343 mv $(HISTORY)_tmp $(HISTORY); \
344 if [ "`wc -c $(HISTORY) | cut -d ' ' -f 1`" -eq 0 ]; then \
345 rm -f $(HISTORY); \
346 fi; \
347 fi
348 rm -fr $(TEMP_INST_DIR)
349
350 # Easily add more items to config target if more options need
351 # to be cached.
352 config: $(CONFIG_FILE)
353
354 $(CONFIG_FILE):
355 @echo PSM_HAL_ENABLE=$(PSM_HAL_ENABLE) > $(CONFIG_FILE)
356 @echo CCARCH=$(CCARCH) >> $(CONFIG_FILE)
357 @echo HFI_BRAKE_DEBUG=$(HFI_BRAKE_DEBUG) >> $(CONFIG_FILE)
358 @echo PSM_DEBUG=$(PSM_DEBUG) >> $(CONFIG_FILE)
359 @echo PSM_AVX512=$(PSM_AVX512) >> $(CONFIG_FILE)
360 @echo PSM_LOG=$(PSM_LOG) >> $(CONFIG_FILE)
361 @echo PSM_LOG_FAST_IO=$(PSM_LOG_FAST_IO) >> $(CONFIG_FILE)
362 @echo PSM_PERF=$(PSM_PERF) >> $(CONFIG_FILE)
363 @echo PSM_HEAP_DEBUG=$(PSM_HEAP_DEBUG) >> $(CONFIG_FILE)
364 @echo PSM_PROFILE=$(PSM_PROFILE) >> $(CONFIG_FILE)
365 @echo PSM_CUDA=$(PSM_CUDA) >> $(CONFIG_FILE)
366 @echo Wrote $(CONFIG_FILE)
367
368 mock: OUTDIR := $(MOCK_OUTDIR)
369 mock:
370 $(MAKE) OUTDIR=$(OUTDIR) PSM2_MOCK_TESTING=1
371
372 debug: OUTDIR := $(DEBUG_OUTDIR)
373 debug:
374 $(MAKE) OUTDIR=$(OUTDIR) PSM_DEBUG=1
375
376 test_clean:
377 if [ -d ./test ]; then \
378 $(MAKE) -C test clean; \
379 fi
380
381 specfile_clean:
382 rm -f ${OUTDIR}/${RPM_NAME}.spec
383
384 distclean: specfile_clean cleanlinks $(HISTORIC_TARGETS) test_clean
385 rm -f $(CONFIG_FILE)
386 rm -rf ${OUTDIR}/${DIST}
387 rm -f ${OUTDIR}/${DIST}.tar.gz
388 rm -fr temp.* *.rej.patch
389
390 $(OUTDIR):
391 mkdir -p ${OUTDIR}
392
393 symlinks:
394 @test -L $(top_srcdir)/include/linux-x86_64 || \
395 ln -sf linux-i386 $(top_srcdir)/include/linux-x86_64
396
397 cleanlinks:
398 rm -rf $(top_srcdir)/include/linux-x86_64
399
400 install: all
401 for subdir in $(SUBDIRS) ; do \
402 mkdir -p $(OUTDIR)/$$subdir ; \
403 $(MAKE) -j $(nthreads) -C $$subdir OUTDIR=$(OUTDIR)/$$subdir install ; \
404 done
405 $(MAKE) -j $(nthreads) $(OUTDIR)/${TARGLIB}.so OUTDIR=$(OUTDIR)
406 $(MAKE) -j $(nthreads) -C compat OUTDIR=$(OUTDIR)/compat install
407 install -D $(OUTDIR)/${TARGLIB}.so.${MAJOR}.${MINOR} \
408 ${DESTDIR}${INSTALL_LIB_TARG}/${TARGLIB}.so.${MAJOR}.${MINOR}
409 (cd ${DESTDIR}${INSTALL_LIB_TARG} ; \
410 ln -sf ${TARGLIB}.so.${MAJOR}.${MINOR} ${TARGLIB}.so.${MAJOR} ; \
411 ln -sf ${TARGLIB}.so.${MAJOR} ${TARGLIB}.so)
412 install -D $(OUTDIR)/${TARGLIB}.a \
413 ${DESTDIR}${INSTALL_LIB_TARG}/${TARGLIB}.a
414 install -m 0644 -D psm2.h ${DESTDIR}/usr/include/psm2.h
415 install -m 0644 -D psm2_mq.h ${DESTDIR}/usr/include/psm2_mq.h
416 install -m 0644 -D psm2_am.h ${DESTDIR}/usr/include/psm2_am.h
417 ifneq (fedora,${DISTRO})
418 install -m 0644 -D 40-psm.rules ${DESTDIR}$(UDEVDIR)/rules.d/40-psm.rules
419 endif
420 # The following files and dirs were part of the noship rpm:
421 mkdir -p ${DESTDIR}/usr/include/hfi1diag
422 mkdir -p ${DESTDIR}/usr/include/hfi1diag/linux-x86_64
423 install -m 0644 -D include/linux-x86_64/bit_ops.h ${DESTDIR}/usr/include/hfi1diag/linux-x86_64/bit_ops.h
424 install -m 0644 -D include/linux-x86_64/sysdep.h ${DESTDIR}/usr/include/hfi1diag/linux-x86_64/sysdep.h
425 install -m 0644 -D include/opa_udebug.h ${DESTDIR}/usr/include/hfi1diag/opa_udebug.h
426 install -m 0644 -D include/opa_debug.h ${DESTDIR}/usr/include/hfi1diag/opa_debug.h
427 install -m 0644 -D include/opa_intf.h ${DESTDIR}/usr/include/hfi1diag/opa_intf.h
428 for h in opa_user_gen1.h opa_service_gen1.h opa_common_gen1.h ; do \
429 sed -e 's/#include "opa_user_gen1.h"/#include "opa_user.h"/' \
430 -e 's/#include "opa_common_gen1.h"/#include "opa_common.h"/' \
431 -e 's/#include "hfi1_deprecated_gen1.h"/#include "hfi1_deprecated.h"/' \
432 -e 's/#include "opa_service_gen1.h"/#include "opa_service.h"/' psm_hal_gen1/$$h \
433 > $(TEMP_INST_DIR)/$$h ; \
434 done
435 cat include/opa_user.h $(TEMP_INST_DIR)/opa_user_gen1.h > $(TEMP_INST_DIR)/opa_user.h
436 cat include/opa_service.h $(TEMP_INST_DIR)/opa_service_gen1.h > $(TEMP_INST_DIR)/opa_service.h
437 install -m 0644 -D $(TEMP_INST_DIR)/opa_user.h ${DESTDIR}/usr/include/hfi1diag/opa_user.h
438 install -m 0644 -D $(TEMP_INST_DIR)/opa_service.h ${DESTDIR}/usr/include/hfi1diag/opa_service.h
439 install -m 0644 -D $(TEMP_INST_DIR)/opa_common_gen1.h ${DESTDIR}/usr/include/hfi1diag/opa_common.h
440 install -m 0644 -D include/opa_byteorder.h ${DESTDIR}/usr/include/hfi1diag/opa_byteorder.h
441 install -m 0644 -D include/psm2_mock_testing.h ${DESTDIR}/usr/include/hfi1diag/psm2_mock_testing.h
442 install -m 0644 -D include/opa_revision.h ${DESTDIR}/usr/include/hfi1diag/opa_revision.h
443 install -m 0644 -D psmi_wrappers.h ${DESTDIR}/usr/include/hfi1diag/psmi_wrappers.h
444 install -m 0644 -D psm_hal_gen1/hfi1_deprecated_gen1.h ${DESTDIR}/usr/include/hfi1diag/hfi1_deprecated.h
445 rm -fr $(TEMP_INST_DIR)
446
447 specfile: specfile_clean | $(OUTDIR)
448 sed -e 's/@VERSION@/'${VERSION_RELEASE}'/g' libpsm2.spec.in | \
449 sed -e 's/@TARGLIB@/'${TARGLIB}'/g' \
450 -e 's/@RPM_NAME@/'${RPM_NAME}'/g' \
451 -e 's/@RPM_NAME_BASEEXT@/'${RPM_NAME_BASEEXT}'/g' \
452 -e 's/@COMPATLIB@/'${COMPATLIB}'/g' \
453 -e 's/@COMPATMAJOR@/'${COMPATMAJOR}'/g' \
454 -e 's;@UDEVDIR@;'${UDEVDIR}';g' \
455 -e 's/@MAJOR@/'${MAJOR}'/g' \
456 -e 's/@MINOR@/'${MINOR}'/g' \
457 -e 's:@LIBPSM2_COMPAT_CONF_DIR@:'${LIBPSM2_COMPAT_CONF_DIR}':g' \
458 -e 's:@LIBPSM2_COMPAT_SYM_CONF_DIR@:'${LIBPSM2_COMPAT_SYM_CONF_DIR}':g' \
459 -e 's;@SPEC_FILE_RELEASE_DIST@;'${SPEC_FILE_RELEASE_DIST}';g' \
460 -e 's/@DIST_SHA@/'${DIST_SHA}'/g' > \
461 ${OUTDIR}/${RPM_NAME}.spec
462 if [ -f /etc/redhat-release ] && [ `grep -o "[0-9.]*" /etc/redhat-release | cut -d"." -f1` -lt 7 ]; then \
463 sed -i 's;@40_PSM_RULES@;'${UDEVDIR}'/rules.d/40-psm.rules;g' ${OUTDIR}/${RPM_NAME}.spec; \
464 else \
465 sed -i 's;@40_PSM_RULES@;'${UDEV_40_PSM_RULES}';g' ${OUTDIR}/${RPM_NAME}.spec; \
466 fi
467
468 # We can't totally prevent two make dist calls in a row from packaging
469 # the previous make dist, unless we switch to using a dedicated ./src folder
470 # That will come in the next major revision of the Makefile for now we can
471 # prevent the easy and default cases
472 #
473 # Notes on PRUNE_LIST:
474 # To make the dist, we always eliminate the psm_hal_MOCK dir.
475 # we also eliminate the psm hal instances that are not enabled via the PSM_HAL_ENABLE variable.
476 # To implement this, we build the prune list in two passes:
477 # 1. The first pass includes all of the common items we want to exclude.
478 # 2. The second pass we include the differnce of
479 # (all of the PSM HAL instances) minus (the PSM hal instances that are enabled)
480 # The final prune list is supplied to find, and the dist is created.
481 dist: distclean
482 mkdir -p ${OUTDIR}/${DIST}
483 PRUNE_LIST=""; \
484 for pd in ".git" "cscope*" "$(shell realpath --relative-to=${top_srcdir} ${OUTDIR})" \
485 "*.orig" "*~" "#*" ".gitignore" "doc" "libcm" "psm.supp" "test" "psm_hal_MOCK" \
486 "psm_test" "tools" "artifacts" "*.rej.patch"; do \
487 PRUNE_LIST="$$PRUNE_LIST -name $$pd -prune -o"; \
488 done; \
489 for hid in psm_hal_* ; do \
490 found=0; \
491 for ehid in $(PSM_HAL_ENABLE_D) ; do \
492 if [ "$$hid" = "$$ehid" ]; then \
493 found=1; \
494 break; \
495 fi; \
496 done; \
497 if [ $$found -eq 0 ]; then \
498 PRUNE_LIST="$$PRUNE_LIST -name $$hid -prune -o"; \
499 fi; \
500 done; \
501 for x in $$(/usr/bin/find . \
502 $$PRUNE_LIST \
503 -print); do \
504 dir=$$(dirname $$x); \
505 mkdir -p ${OUTDIR}/${DIST}/$$dir; \
506 [ ! -d $$x ] && cp $$x ${OUTDIR}/${DIST}/$$dir; \
507 done
508 if [ $(ISGIT) = 1 ] ; then git log -n1 --pretty=format:%H . > ${OUTDIR}/${DIST}/COMMIT ; fi
509 echo ${RELEASE} > ${OUTDIR}/${DIST}/rpm_release_extension
510 cd ${OUTDIR}; tar czvf ${DIST}.tar.gz ${DIST}
511 @echo "${DIST}.tar.gz is located in ${OUTDIR}/${DIST}.tar.gz"
512
513 ofeddist:
514 $(MAKE) -j $(nthreads) dist
515
516 # rebuild the cscope database, skipping sccs files, done once for
517 # top level
518 cscope:
519 find * -type f ! -name '[ps].*' \( -iname '*.[cfhs]' -o \
520 -iname \\*.cc -o -name \\*.cpp -o -name \\*.f90 \) -print | cscope -bqu -i -
521
522 sources-checksum:
523 @echo ${SOURCES_CHKSUM_VALUE}
524
525 ${TARGLIB}-objs := ptl_am/am_reqrep_shmem.o \
526 ptl_am/am_reqrep.o \
527 ptl_am/ptl.o \
528 ptl_am/cmarwu.o \
529 ptl_am/am_cuda_memhandle_cache.o \
530 psm_context.o \
531 psm_ep.o \
532 psm_ep_connect.o \
533 psm_error.o \
534 psm_utils.o \
535 psm_sysbuf.o \
536 psm_timer.o \
537 psm_am.o \
538 psm_mq.o \
539 psm_mq_utils.o \
540 psm_mq_recv.o \
541 psm_mpool.o \
542 psm_stats.o \
543 psm_memcpy.o \
544 psm_mock.o \
545 psm.o \
546 psm_perf.o \
547 libuuid/psm_uuid.o \
548 libuuid/parse.o \
549 libuuid/pack.o \
550 libuuid/unpack.o \
551 libuuid/unparse.o \
552 ptl_ips/ptl.o \
553 ptl_ips/ptl_rcvthread.o \
554 ptl_ips/ips_scb.o \
555 ptl_ips/ips_epstate.o \
556 ptl_ips/ips_recvq.o \
557 ptl_ips/ips_recvhdrq.o \
558 ptl_ips/ips_proto.o \
559 ptl_ips/ips_proto_recv.o \
560 ptl_ips/ips_proto_connect.o \
561 ptl_ips/ips_proto_expected.o \
562 ptl_ips/ips_tid.o \
563 ptl_ips/ips_tidcache.o \
564 ptl_ips/ips_tidflow.o \
565 ptl_ips/ips_crc32.o \
566 ptl_ips/ips_proto_dump.o \
567 ptl_ips/ips_proto_mq.o \
568 ptl_ips/ips_proto_am.o \
569 ptl_ips/ips_path_rec.o \
570 ptl_ips/ips_opp_path_rec.o \
571 ptl_ips/ips_writehdrq.o \
572 ptl_self/ptl.o \
573 opa/*.o \
574 psm_diags.o \
575 psm2_hal.o \
576 $(PSM_HAL_INSTANCE_OBJFILES) \
577 psmi_wrappers.o
578
579 ${TARGLIB}-objs := $(patsubst %.o, ${OUTDIR}/%.o, ${${TARGLIB}-objs})
580
581 DEPS:= $(${TARGLIB}-objs:.o=.d)
582 -include $(DEPS)
583
584 ${OUTDIR}/${TARGLIB}.so: ${OUTDIR}/${TARGLIB}.so.${MAJOR}
585 ln -fs ${TARGLIB}.so.${MAJOR}.${MINOR} $@
586
587 ${OUTDIR}/${TARGLIB}.so.${MAJOR}: ${OUTDIR}/${TARGLIB}.so.${MAJOR}.${MINOR}
588 ln -fs ${TARGLIB}.so.${MAJOR}.${MINOR} $@
589
590 # when we build the shared library, generate a revision and date
591 # string in it, for easier id'ing when people may have copied the
592 # file around. Generate it such that the ident command can find it
593 # and strings -a | grep OPA does a reasonable job as well.
594 $(OUTDIR)/${TARGLIB}.so.${MAJOR}.${MINOR}: ${${TARGLIB}-objs} $(LINKER_SCRIPT_FILE)
595 echo "char psmi_hfi_IFS_version[]=\"`printenv RELEASE_TAG`\";" > ${OUTDIR}/_revision.c
596 date -u -d@$${SOURCE_DATE_EPOCH:-$$(date +%s)} +'char psmi_hfi_build_timestamp[] ="%F %T%:z";' >> ${OUTDIR}/_revision.c
597 echo "char psmi_hfi_sources_checksum[] =\"${SOURCES_CHKSUM_VALUE}\";" >> ${OUTDIR}/_revision.c
598 echo "char psmi_hfi_git_checksum[] =\"`git rev-parse HEAD`\";" >> ${OUTDIR}/_revision.c
599 $(CC) -c $(CFLAGS) $(BASECFLAGS) $(INCLUDES) ${OUTDIR}/_revision.c -o $(OUTDIR)/_revision.o
600 $(CC) $(LINKER_SCRIPT) $(LDFLAGS) -o $@ -Wl,-soname=${TARGLIB}.so.${MAJOR} -shared \
601 ${${TARGLIB}-objs} $(OUTDIR)/_revision.o $(LDLIBS)
602
603 $(OUTDIR)/${TARGLIB}.a: $(OUTDIR)/${TARGLIB}.so.${MAJOR}.${MINOR}
604 $(AR) rcs $(OUTDIR)/${TARGLIB}.a ${${TARGLIB}-objs} $(OUTDIR)/_revision.o
605
606 ${OUTDIR}/%.o: ${top_srcdir}/%.c
607 $(CC) $(CFLAGS) $(BASECFLAGS) $(INCLUDES) -MMD -c $< -o $@
608
609 $(LINKER_SCRIPT_FILE): psm2_linker_script_map.in
610 sed "s/_psm2_additional_globals_;/$(PSM2_ADDITIONAL_GLOBALS)/" \
611 psm2_linker_script_map.in > ${OUTDIR}/psm2_linker_script.map
612
613 .PHONY: all %_clean clean config mock debug distclean symlinks cleanlinks install specfile dist ofeddist cscope sources-checksum