forked from nima/python-dmidecode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
131 lines (116 loc) · 4.52 KB
/
Makefile
File metadata and controls
131 lines (116 loc) · 4.52 KB
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
#. ******* coding:utf-8 AUTOHEADER START v1.2 *******
#. vim: fileencoding=utf-8 syntax=Makefile sw=4 ts=4 et
#.
#. © 2007-2010 Nima Talebi <nima@autonomy.net.au>
#. © 2009-2010 David Sommerseth <davids@redhat.com>
#. © 2002-2008 Jean Delvare <khali@linux-fr.org>
#. © 2000-2002 Alan Cox <alan@redhat.com>
#.
#. This file is part of python-dmidecode.
#.
#. python-dmidecode is free software: you can redistribute it and/or modify
#. it under the terms of the GNU General Public License as published by
#. the Free Software Foundation, either version 2 of the License, or
#. (at your option) any later version.
#.
#. python-dmidecode is distributed in the hope that it will be useful,
#. but WITHOUT ANY WARRANTY; without even the implied warranty of
#. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#. GNU General Public License for more details.
#.
#. You should have received a copy of the GNU General Public License
#. along with python-dmidecode. If not, see <http://www.gnu.org/licenses/>.
#.
#. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
#. WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
#. MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
#. EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
#. INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
#. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
#. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
#. LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
#. OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
#. ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#.
#. ADAPTED M. STONE & T. PARKER DISCLAIMER: THIS SOFTWARE COULD RESULT IN INJURY
#. AND/OR DEATH, AND AS SUCH, IT SHOULD NOT BE BUILT, INSTALLED OR USED BY ANYONE.
#.
#. $AutoHeaderSerial::20100225 $
#. ******* AUTOHEADER END v1.2 *******
PY_BIN := python2
VERSION := $(shell cd src;$(PY_BIN) -c "from setup_common import *; print(get_version());")
PACKAGE := python-dmidecode
PY_VER := $(shell $(PY_BIN) -c 'import sys; print("%d.%d"%sys.version_info[0:2])')
PY_MV := $(shell echo $(PY_VER) | cut -b 1)
PY := python$(PY_VER)
SO_PATH := build/lib.linux-$(shell uname -m)-$(PY_VER)
ifeq ($(PY_MV),2)
SO := $(SO_PATH)/dmidecodemod.so
else
SOABI := $(shell $(PY_BIN) -c 'import sysconfig; print(sysconfig.get_config_var("SOABI"))')
SO := $(SO_PATH)/dmidecodemod.$(SOABI).so
endif
SHELL := /bin/bash
GCOV ?= 0
CC_OPTS := -O2
SETUP_PY_OPTS :=
ifeq ($(GCOV),1)
CC_OPTS := -coverage -O0 -fprofile-arcs -ftest-coverage
SETUP_PY_OPTS := --gcov
endif
###############################################################################
.PHONY: all
all: build dmidump
.PHONY: build
build: $(PY)-dmidecodemod.so
$(PY)-dmidecodemod.so: $(SO)
cp $< $@
$(SO):
$(PY) src/setup.py $(SETUP_PY_OPTS) build
dmidump: src/util.o src/efi.o src/dmilog.o
$(CC) $(CC_OPTS) -o $@ src/dmidump.c $^ -g -Wall -D_DMIDUMP_MAIN_
.PHONY: install
install:
$(PY) src/setup.py install
.PHONY: uninstall
uninstall:
$(PY) src/setup.py uninstall
.PHONY: clean
clean:
-$(PY) src/setup.py clean --all
-rm -f *.so lib/*.o core dmidump src/*.o
-rm -rf build
-rm -rf rpm
-rm -rf src/setup_common.py[oc]
-rm -rf __pycache__ src/__pycache__
-rm -rf $(PACKAGE)-$(VERSION) $(PACKAGE)-$(VERSION).tar.gz
$(MAKE) -C unit-tests clean
.PHONY: tarball
tarball:
rm -rf $(PACKAGE)-$(VERSION)
mkdir $(PACKAGE)-$(VERSION)
cp -r contrib doc examples Makefile man README src dmidecode.py unit-tests/ $(PACKAGE)-$(VERSION)
tar -czvf $(PACKAGE)-$(VERSION).tar.gz $(PACKAGE)-$(VERSION)
.PHONY: rpm-prep
rpm-prep:
mkdir -p rpm/{BUILD,RPMS,SRPMS,SPECS,SOURCES}
cp contrib/$(PACKAGE).spec rpm/SPECS
cp $(PACKAGE)-$(VERSION).tar.gz rpm/SOURCES
.PHONY: rpm
rpm: tarball rpm-prep
rpmbuild -ba --define "_topdir $(shell pwd)/rpm" rpm/SPECS/$(PACKAGE).spec
.PHONY: rpm-md5
rpm-md5: tarball rpm-prep
rpmbuild-md5 -ba --define "_topdir $(shell pwd)/rpm" rpm/SPECS/$(PACKAGE).spec
.PHONY: unit
unit:
$(MAKE) -C unit-tests
.PHONY: version
version:
@echo "python-dmidecode: $(VERSION)"
@echo "python version: $(PY_VER) ($(PY))"
.PHONY: conflicts
conflicts:
@comm -12 \
<(dpkg-deb -c ../../DPKGS/python-dmidecode_$(VERSION)-1_amd64.deb | awk '$$NF!~/\/$$/{print$$NF}'|sort) \
<(dpkg-deb -c ../../DPKGS/python-dmidecode-dbg_$(VERSION)-1_amd64.deb | awk '$$NF!~/\/$$/{print$$NF}'|sort)