File: rules

package info (click to toggle)
kicad 5.1.4+dfsg1-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 239,572 kB
  • sloc: cpp: 462,955; ansic: 58,106; python: 4,970; sh: 488; awk: 294; makefile: 259; xml: 116; perl: 10
file content (150 lines) | stat: -rwxr-xr-x 5,537 bytes parent folder | download | duplicates (2)
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
#!/usr/bin/make -f
#export DH_VERBOSE=1

export DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)
export DEB_BUILD_MAINT_OPTIONS = hardening=+all
DPKG_EXPORT_BUILDFLAGS = 1
include /usr/share/dpkg/buildflags.mk
CFLAGS+=$(CPPFLAGS)
CXXFLAGS+=$(CPPFLAGS)

# out of tree build folder for kicad application
DEB_BUILD_DIR=debian/build
# default install folder
INSTDIR=$(CURDIR)/debian/tmp
# catching make jobs from DEB_BUILD_OPTIONS
PARALLEL_BUILD=$(echo $DEB_BUILD_OPTIONS | sed -e '/parallel=/!s/.*/1/;s/.*parallel=\([0-9]\+\).*/\1/g')

# other variables
include /usr/share/dpkg/pkg-info.mk
VERSION_EXTRA   = $(shell echo "$(DEB_VERSION)" | cut -d+ -f2-)
DATE            = $(shell date +'%Y-%m-%d' -d@"$(SOURCE_DATE_EPOCH)")
export REVDATE := $(shell TZ=UTC date -d@"$(SOURCE_DATE_EPOCH)" +%Y-%m-%d)

PREPROCESS_FILES := $(wildcard debian/*.in)

ASCIIDOCFILES := \
	doc/src/cvpcb/cvpcb.adoc \
	doc/src/doc_writing_style_policy/doc_writing_style_policy.adoc \
	doc/src/eeschema/eeschema.adoc \
	doc/src/gerbview/gerbview.adoc \
	doc/src/getting_started_in_kicad/getting_started_in_kicad.adoc \
	doc/src/gui_translation_howto/gui_translation_howto.adoc \
	doc/src/idf_exporter/idf_exporter.adoc \
	doc/src/kicad/kicad.adoc \
	doc/src/pcbnew/pcbnew.adoc \
	doc/src/pl_editor/pl_editor.adoc \
	doc/src/plugins/plugins.adoc \
	$(NULL)

DEB_KICAD_CMAKE_OPTS := \
	-DBUILD_GITHUB_PLUGIN=ON \
	-DCMAKE_C_COMPILER=/usr/bin/clang \
	-DCMAKE_CXX_COMPILER=/usr/bin/clang++ \
	-DCMAKE_CXX_FLAGS="$(CXXFLAGS)" \
	-DCMAKE_INSTALL_PREFIX=/usr \
	-DCMAKE_SHARED_LINKER_FLAGS_RELEASE="$(LDFLAGS)" \
	-DKICAD_SCRIPTING=ON \
	-DKICAD_SCRIPTING_ACTION_MENU=ON \
	-DKICAD_SCRIPTING_PYTHON3=ON \
	-DKICAD_SCRIPTING_MODULES=ON \
	-DKICAD_SCRIPTING_WXPYTHON=ON \
	-DKICAD_SCRIPTING_WXPYTHON_PHOENIX=ON \
	-DKICAD_SPICE=ON \
	-DKICAD_USE_OCE=ON \
	-DKICAD_VERSION_EXTRA="+$(VERSION_EXTRA)" \
	$(NULL)

DEB_DOC_CMAKE_OPTS := \
	-DCMAKE_INSTALL_PREFIX=/usr \
	$(NULL)

DEB_I18N_CMAKE_OPTS := \
	-DCMAKE_INSTALL_PREFIX=/usr \
	-DKICAD_I18N_UNIX_STRICT_PATH=ON \
	$(NULL)

$(PREPROCESS_FILES:.in=): %: %.in
	sed -e 's,/@DEB_HOST_MULTIARCH@,$(DEB_HOST_MULTIARCH:%=/%),g' $< > $@

%:
	dh $@ --with-python3

override_dh_auto_configure:
	sed -i 's/@REVDATE@/$(REVDATE)/' $(ASCIIDOCFILES)
	mkdir -p $(DEB_BUILD_DIR)
	#################################
	# configuring KiCad application #
	#################################
	dh_auto_configure --sourcedirectory=$(CURDIR) --builddirectory=$(DEB_BUILD_DIR) -- $(DEB_KICAD_CMAKE_OPTS)
	###################################
	# configuring KiCad documentation #
	###################################
	dh_auto_configure --sourcedirectory=$(CURDIR)/doc --builddirectory=$(DEB_BUILD_DIR)/doc -- $(DEB_DOC_CMAKE_OPTS)
	################################
	# configuring KiCad i18n files #
	################################
	dh_auto_configure --sourcedirectory=$(CURDIR)/i18n --builddirectory=$(DEB_BUILD_DIR)/i18n -- $(DEB_I18N_CMAKE_OPTS)

override_dh_auto_build:
	# The other parts of KiCad like documentation, i18n files and the
	# libraries don't need to be build as arch depended, they even
	# don't need to be prebuild before calling dh_install. So ignoring
	# here. Only build the KiCad application here.
	dh_auto_build --sourcedirectory=$(CURDIR) --builddirectory=$(DEB_BUILD_DIR)

override_dh_auto_install: $(PREPROCESS_FILES:.in=)
	################################
	# installing KiCad application #
	################################
	dh_auto_install --destdir=$(INSTDIR) --sourcedirectory=$(CURDIR) --builddirectory=$(DEB_BUILD_DIR)
	# Removing a potentially added RUNPATH from the Pcbnew Python library.
	chrpath --delete $(CURDIR)/debian/tmp/usr/lib/python3/dist-packages/_pcbnew.so
	###############################################
	# building and installing KiCad documentation #
	###############################################
	dh_auto_install --destdir=$(INSTDIR) --sourcedirectory=$(CURDIR)/doc --builddirectory=$(DEB_BUILD_DIR)/doc
	###############################
	# installing KiCad i18n files #
	###############################
	dh_auto_install --destdir=$(INSTDIR) --sourcedirectory=$(CURDIR)/i18n --builddirectory=$(DEB_BUILD_DIR)/i18n
	# some tweaks before running the next dh sequencers
	# fixing icon sizes
	images=$$(find $(INSTDIR)/usr/share/icons/hicolor/48x48 -name "*.png"); \
	for f in $$images; do \
		size=$$(identify $$f | sed -n 's/.* PNG \(4[^ ]*\) .*/\1/ p'); \
		if [ "$$size" != "48x48" ]; then \
			echo "Resize $$(basename $$f) : $$size => 48x48"; \
			convert -resize '48x48!' $$f $$f.tmp && mv $$f.tmp $$f; \
		fi; \
	done
	# The kicad XPM icon comes with a to high resolution, fixing before install.
	convert -resize '32x32!' $(CURDIR)/bitmaps_png/icons/icon_kicad.xpm $(CURDIR)/bitmaps_png/icons/kicad.xpm

override_dh_install:
	dh_install
	dh_python3

override_dh_fixperms-arch:
	dh_fixperms
	# fixing file permissions for *.py files in kicad
	for i in `find $(CURDIR)/debian/kicad/usr -type f -name "*.py"`; do \
		FOUND_PYTHON=$$(head -n1 $$i | grep python); \
		if [ "$$FOUND_PYTHON" != "" ]; then \
			chmod +x $$i; \
		else \
			chmod -x $$i; \
		fi; \
	done

override_dh_strip-arch:
	dh_strip
	# strip unneeded symbols from the kicad specific libraries in /usr/lib/kicad/
	strip --strip-unneeded --remove-section=.comment $(CURDIR)/debian/kicad/usr/lib/kicad/_*.kiface

override_dh_shlibdeps:
	dh_shlibdeps -a -l $(CURDIR)/debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH) \
		-Xlibkicad_3dsg \
		-Xlibs3d_plugin_idf \
		-Xlibs3d_plugin_vrml \
		-X_pcbnew.$(DEB_HOST_MULTIARCH)