| 1 |
# |
| 2 |
# Copyright 2015, International Business Machines |
| 3 |
# |
| 4 |
# Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 |
# you may not use this file except in compliance with the License. |
| 6 |
# You may obtain a copy of the License at |
| 7 |
# |
| 8 |
# http://www.apache.org/licenses/LICENSE-2.0 |
| 9 |
# |
| 10 |
# Unless required by applicable law or agreed to in writing, software |
| 11 |
# distributed under the License is distributed on an "AS IS" BASIS, |
| 12 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 |
# See the License for the specific language governing permissions and |
| 14 |
# limitations under the License. |
| 15 |
# |
| 16 |
|
| 17 |
include config.mk |
| 18 |
|
| 19 |
# Verbose level: |
| 20 |
# V=0 means completely silent |
| 21 |
# V=1 means brief output |
| 22 |
# V=2 means full output |
| 23 |
V ?= 2 |
| 24 |
|
| 25 |
include config.mk |
| 26 |
|
| 27 |
ifeq ($(V),0) |
| 28 |
Q := @ |
| 29 |
MAKEFLAGS += --silent |
| 30 |
MAKE += -s |
| 31 |
endif |
| 32 |
|
| 33 |
ifeq ($(V),1) |
| 34 |
MAKEFLAGS += --silent |
| 35 |
MAKE += -s |
| 36 |
endif |
| 37 |
|
| 38 |
PLATFORM ?= $(shell uname -i) |
| 39 |
|
| 40 |
distro = $(shell lsb_release -d | cut -f2) |
| 41 |
|
| 42 |
subdirs += lib tools misc |
| 43 |
|
| 44 |
ifdef WITH_LIBCXL |
| 45 |
subdirs += init |
| 46 |
endif |
| 47 |
|
| 48 |
UDEV_RULES_D ?= /etc/udev/rules.d |
| 49 |
MODPROBE_D ?= /etc/modprobe.d |
| 50 |
|
| 51 |
all: $(subdirs) |
| 52 |
|
| 53 |
# Rules for the recursive build |
| 54 |
tools misc: lib |
| 55 |
|
| 56 |
# z_ prefixed version of libz, intended to be linked statically with |
| 57 |
# our libz version to provide the software zlib functionality. |
| 58 |
# |
| 59 |
ifeq ($(CONFIG_DLOPEN_MECHANISM),0) |
| 60 |
|
| 61 |
HAS_WGET = $(shell which wget > /dev/null 2>&1 && echo y || echo n) |
| 62 |
HAS_CURL = $(shell which curl > /dev/null 2>&1 && echo y || echo n) |
| 63 |
OBJCOPY = @printf "\t[OBJCP]\t%s\n" `basename "$@"`; $(CROSS)objcopy |
| 64 |
|
| 65 |
define Q |
| 66 |
@/bin/echo -e " [$1]\t$(2)" |
| 67 |
@$(3) |
| 68 |
endef |
| 69 |
|
| 70 |
lib: zlib-1.2.8/libz.so |
| 71 |
|
| 72 |
zlib-1.2.8/libz.so: zlib-1.2.8.cfg |
| 73 |
@/bin/echo -e " [BUILD]\tzlib-1.2.8" |
| 74 |
@$(MAKE) -C zlib-1.2.8 1>&2 > /dev/null |
| 75 |
|
| 76 |
zlib-1.2.8.cfg: zlib-1.2.8.tar.gz |
| 77 |
@/bin/echo -e " [TAR]\t$<" |
| 78 |
@tar xfz $< |
| 79 |
@/bin/echo -e " [CFG]\tzlib-1.2.8" |
| 80 |
@(cd zlib-1.2.8 && CFLAGS=-O2 ./configure --prefix=/opt/genwqe) \ |
| 81 |
1>&2 > /dev/null |
| 82 |
@touch zlib-1.2.8.cfg |
| 83 |
|
| 84 |
zlib-1.2.8.tar.gz: |
| 85 |
ifeq (${HAS_WGET},y) |
| 86 |
$(call Q,WGET,zlib-1.2.8.tar.gz, wget -O zlib-1.2.8.tar.gz -q http://www.zlib.net/zlib-1.2.8.tar.gz) |
| 87 |
else ifeq (${HAS_CURL},y) |
| 88 |
$(call Q,CURL,zlib-1.2.8.tar.gz, curl -o zlib-1.2.8.tar.gz -s http://www.zlib.net/zlib-1.2.8.tar.gz) |
| 89 |
endif |
| 90 |
|
| 91 |
endif |
| 92 |
|
| 93 |
# Only build if the subdirectory is really existent |
| 94 |
.PHONY: $(subdirs) install |
| 95 |
$(subdirs): |
| 96 |
@if [ -d $@ ]; then \ |
| 97 |
$(MAKE) -C $@ C=0 || exit 1; \ |
| 98 |
fi |
| 99 |
|
| 100 |
rpmbuild_setup: |
| 101 |
@mkdir -p ~/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS} |
| 102 |
$(RM) ~/.rpmmacros |
| 103 |
echo '%_topdir %(echo $$HOME)/rpmbuild' > ~/.rpmmacros |
| 104 |
|
| 105 |
# |
| 106 |
# Create required tar.gz archive and copy everything to the right |
| 107 |
# places. Create version.mk since the Fedora build system requires |
| 108 |
# running without git. |
| 109 |
# |
| 110 |
rpmbuild: |
| 111 |
@$(MAKE) -s distclean |
| 112 |
@rm -rf /tmp/genwqe-user-$(RPMVERSION) |
| 113 |
@mkdir -p /tmp/genwqe-user-$(RPMVERSION) |
| 114 |
@cp -ar * /tmp/genwqe-user-$(RPMVERSION)/ |
| 115 |
(cd /tmp && tar cfz v$(RPMVERSION).tar.gz genwqe-user-$(RPMVERSION)) |
| 116 |
rpmbuild -ta -v /tmp/v$(RPMVERSION).tar.gz |
| 117 |
@rm -rf /tmp/genwqe-user-$(RPMVERSION) |
| 118 |
$(RM) /tmp/v$(RPMVERSION).tar.gz |
| 119 |
|
| 120 |
# Install/Uninstall |
| 121 |
install uninstall: |
| 122 |
@for dir in $(subdirs); do \ |
| 123 |
if [ -d $$dir ]; then \ |
| 124 |
$(MAKE) -C $$dir $@ || exit 1; \ |
| 125 |
fi \ |
| 126 |
done |
| 127 |
|
| 128 |
install_udev_rules: |
| 129 |
mkdir -p $(UDEV_RULES_D) |
| 130 |
cp etc/udev/rules.d/52-genwqedevices.rules $(UDEV_RULES_D)/ |
| 131 |
|
| 132 |
uninstall_udev_rules: |
| 133 |
$(RM) $(UDEV_RULES_D)/52-genwqedevices.rules |
| 134 |
|
| 135 |
install_modprobe_d: |
| 136 |
mkdir -p $(MODPROBE_D) |
| 137 |
cp etc/modprobe.d/genwqe.conf $(MODPROBE_D)/ |
| 138 |
|
| 139 |
uninstall_modprobe_d: |
| 140 |
$(RM) $(MODPROBE_D)/genwqe.conf |
| 141 |
|
| 142 |
help: |
| 143 |
@echo "Build GenWQE/CAPI hardware accelerator tools" |
| 144 |
@echo |
| 145 |
@echo "Possible Makefile options:" |
| 146 |
@echo " V=0 silent, 1 normal (default), 2 verbose" |
| 147 |
@echo " FORCE_32BIT=0 64-bit (default), 1 32-bit" |
| 148 |
@echo " BUILD_SIMCODE=1 use pslse version of libcxl, 0 use libcxl " |
| 149 |
@echo " (default)" |
| 150 |
@echo " CONFIG_DLOPEN_MECHANISM=0 statically link against private" |
| 151 |
@echo " software zlib, 1 use dlopen to include software zlib" |
| 152 |
@echo " (default)" |
| 153 |
@echo " BUILD_AGZIP_TOOLS=1 Set flag to build extra CAPI Gzip tools." |
| 154 |
@echo " This tools require json-c package installed." |
| 155 |
@echo " (default = 0)" |
| 156 |
@echo |
| 157 |
|
| 158 |
# Automatically perform tests - card selected automatically |
| 159 |
test: test_hardware test_software |
| 160 |
|
| 161 |
test_hardware: all |
| 162 |
./misc/basic_hardware_tests.sh |
| 163 |
|
| 164 |
test_software: all |
| 165 |
./misc/basic_software_tests.sh |
| 166 |
|
| 167 |
distclean: clean |
| 168 |
@$(RM) -r sim_* zlib-1.2.8 zlib-1.2.8.tar.gz |
| 169 |
|
| 170 |
clean: |
| 171 |
@for dir in $(subdirs); do \ |
| 172 |
if [ -d $$dir ]; then \ |
| 173 |
$(MAKE) -C $$dir $@ || exit 1; \ |
| 174 |
fi \ |
| 175 |
done |
| 176 |
@$(RM) genwqe-$(RPMVERSION).tar.gz libz.o libz_prefixed.o zlib-1.2.8.cfg |
| 177 |
@if [ -d zlib-1.2.8 ]; then \ |
| 178 |
$(MAKE) -s -C zlib-1.2.8 distclean; \ |
| 179 |
fi |
| 180 |
@find . -depth -name '*~' -exec rm -rf '{}' \; -print |
| 181 |
@find . -depth -name '.#*' -exec rm -rf '{}' \; -print |
| 182 |
@$(RM) *.bin *.log |