~jon-hill/spud/mac_port

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
151
152
153
154
155
156
#!/usr/bin/make -f

PACKAGE_NAME=diamond
MODULE_NAME=diamond
DEB_UPSTREAM_VERSION=1.0

PYVERS=$(shell pyversions -dv)

# These are used for cross-compiling and for saving the configure script
# from having to guess our platform (since we know it already)
DEB_HOST_GNU_TYPE   ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
DEB_BUILD_GNU_TYPE  ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)


config.status: configure
	dh_testdir
	# Add here commands to configure the package.

ifneq "$(wildcard /usr/share/misc/config.sub)" ""
	cp -f /usr/share/misc/config.sub config.sub
endif
ifneq "$(wildcard /usr/share/misc/config.guess)" ""
	cp -f /usr/share/misc/config.guess config.guess
endif
	./configure --host=$(DEB_HOST_GNU_TYPE) --build=$(DEB_BUILD_GNU_TYPE) --prefix=/usr --mandir=\$${prefix}/share/man --infodir=\$${prefix}/share/info CFLAGS="$(CFLAGS)" LDFLAGS="-Wl,-z,defs"

build-libspud: build-libspud-stamp
build-libspud-stamp:
	touch $@

build-libspud: config.status
	dh_testdir

	# Add here commands to compile the package.
	$(MAKE) libspud.la
	#docbook-to-man debian/fluidity.sgml > fluidity.1
	$(MAKE) doc


build-diamond: build-diamond-stamp 
build-diamond-stamp: $(PYVERS:%=build-python%)
	touch $@
build-python%: config.status
# Force setuptools, but reset sys.argv[0] to 'setup.py' because setup.py files expect that.
	cd diamond;python$* -c "import setuptools,sys;f='setup.py';sys.argv[0]=f;execfile(f,{'__file__':f,'__name__':'__main__'})" build
	touch $@
clean:
	dh_testdir
	dh_testroot
	rm -f *-stamp
	rm -rf dist build
	-find -name '*.py[co]' | xargs rm -f
	$(MAKE) clean || true
#	find . -name *.pyc -exec rm {} \;
	dh_clean

install-libspud: build-libspud install-prereq
	$(MAKE) install-libspud DESTDIR=$(CURDIR)/debian/libspud-dev
	rm -f $(CURDIR)/debian/libspud-dev/usr/include/tiny*h

install-spudtools: install-prereq
	$(MAKE) install-spudtools DESTDIR=$(CURDIR)/debian/spudtools

install-diamond: build-diamond install-prereq $(PYVERS:%=install-python%)
	dh_install
install-prereq:
	dh_testdir
	dh_testroot
	dh_clean -k
	dh_installdirs -a 

install-python%:
# Force setuptools, but reset sys.argv[0] to 'setup.py' because setup.py files expect that.
	cd diamond;python$* -c "import setuptools,sys;f='setup.py';sys.argv[0]=f;execfile(f,{'__file__':f,'__name__':'__main__'})" install --prefix=/usr --no-compile --single-version-externally-managed --root=$(CURDIR)/debian/${PACKAGE_NAME}
	if [ -d debian/${PACKAGE_NAME}/usr/lib/python$*/site-packages/${MODULE_NAME}-${DEB_UPSTREAM_VERSION}.egg-info ]; then \
	    mv debian/${PACKAGE_NAME}/usr/lib/python$*/site-packages/${MODULE_NAME}-${DEB_UPSTREAM_VERSION}.egg-info		 debian/${PACKAGE_NAME}/usr/lib/python$*/site-packages/${MODULE_NAME}.egg-info ; \
	elif [ -d debian/${PACKAGE_NAME}/usr/lib/python$*/site-packages/${MODULE_NAME}-${DEB_UPSTREAM_VERSION}-py$*.egg-info ]; then \
	    mv debian/${PACKAGE_NAME}/usr/lib/python$*/site-packages/${MODULE_NAME}-${DEB_UPSTREAM_VERSION}-py$*.egg-info		 debian/${PACKAGE_NAME}/usr/lib/python$*/site-packages/${MODULE_NAME}.egg-info ; \
	else \
	    echo "Failed to locate python egg, was it built correctly?" && exit 1 ; \
	fi

install-pyspud:
	$(MAKE) install-pyspud DESTDIR=$(CURDIR)/debian/python-spud BUILDING_DEBIAN=yes

install-dxdiff:
	$(MAKE) install-dxdiff DESTDIR=$(CURDIR)/debian/python-dxdiff

binary-arch: build-libspud install-libspud install-spudtools install-pyspud
	dh_testdir
	dh_testroot
	dh_installchangelogs 
	dh_installdocs
	dh_installexamples
#	dh_install
#	dh_installmenu
#	dh_installdebconf	
#	dh_installlogrotate
#	dh_installemacsen
#	dh_installpam
#	dh_installmime
#	Fallback to dh_pysupport of dh_python2 is not available (as on Ubuntu Lucid)
	([ -x $(which dh_python2) ] && dh_python2) || dh_pysupport
#	dh_installinit
#	dh_installcron
#	dh_installinfo
	dh_installman
	dh_link
	dh_strip
	dh_compress
	dh_fixperms
#	dh_perl
	dh_makeshlibs
	dh_installdeb
	dh_shlibdeps
	dh_gencontrol
	dh_md5sums
	dh_builddeb

binary-indep: build-diamond install-diamond build-libspud install-libspud install-spudtools install-dxdiff
	dh_testdir -i
	dh_testroot -i
#	Fallback to dh_pysupport of dh_python2 is not available (as on Ubuntu Lucid)
	([ -x $(which dh_python2) ] && dh_python2 -i) || dh_pysupport -i
	dh_installdocs -i
	dh_installdirs -i
	dh_installexamples  -i
	dh_strip -i
	dh_compress -i -X.py
	dh_fixperms -i
	: # Replace all '#!' calls to python with $(PYTHON)
	: # and make them executable
	for i in \
	  `find debian/diamond/usr/bin -type f` \
	  `find debian/diamond/usr/lib -type f`; \
	do \
	  case "$$i" in *-[0-9].[0-9]) continue; esac; \
	  sed '1s,#!.*python[^ ]*\(.*\),#! /usr/bin/python\1,' \
		$$i > $$i.temp; \
	  if cmp --quiet $$i $$i.temp; then \
	    rm -f $$i.temp; \
	  else \
	    mv -f $$i.temp $$i; \
	    chmod 755 $$i; \
	    echo "fixed interpreter: $$i"; \
	  fi; \
	done
	dh_installdeb -i
	dh_gencontrol -i
	dh_md5sums -i
	dh_builddeb -i

binary: binary-indep binary-arch


.PHONY: build clean binary-indep binary-arch binary-diamond binary-libspud install configure