File: rules

package info (click to toggle)
libtexttools 2.0.3-4
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 1,188 kB
  • ctags: 635
  • sloc: ada: 13,120; cpp: 1,679; ansic: 777; makefile: 156; sh: 2
file content (111 lines) | stat: -rwxr-xr-x 3,394 bytes parent folder | download
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
#!/usr/bin/make -f

export DH_COMPAT=4

.SUFFIXES:

# Parse the version number from the change log:
# major.minor.patchlevel-revision
regexp:=^Version: \([0-9]\+\)\.\([0-9]\+\)\.\([0-9]\+\)-\(.\+\)$$
major:=$(shell dpkg-parsechangelog | grep ^Version: | sed 's/$(regexp)/\1/')
minor:=$(shell dpkg-parsechangelog | grep ^Version: | sed  's/$(regexp)/\2/')
patch:=$(shell dpkg-parsechangelog | grep ^Version: | sed  's/$(regexp)/\3/')
revision:=$(shell dpkg-parsechangelog | grep ^Version: | sed  's/$(regexp)/\4/')

CPUS := $(shell getconf _NPROCESSORS_ONLN)

SPECS := $(wildcard *.ads)
BODIES := $(filter-out build_all.adb,$(wildcard *.adb))
OBJECTS := $(patsubst %.ads,%.o,$(SPECS))
C_OBJECTS := $(patsubst C_code/%.c,%.o,$(wildcard C_code/*.c))
STATIC_OBJECTS := $(addprefix obj-static/,$(C_OBJECTS) $(OBJECTS))
PIC_OBJECTS := $(addprefix obj-shared/,$(C_OBJECTS) $(OBJECTS))
ADAFLAGS := -O2 -gnatafno -gnatVa

build: libtexttools.a libtexttools.so.$(major).$(minor).$(patch)

libtexttools.a: $(STATIC_OBJECTS) | obj-static
	ar rc $@ obj-static/*.o
	ranlib $@

libtexttools.so.$(major).$(minor).$(patch): $(PIC_OBJECTS) | obj-shared
	gnatgcc -shared -o $@ $^ -lgnat -lncurses \
	   -Wl,--soname,libtexttools.so.$(major).$(minor)

obj-static obj-shared:
	-mkdir $@

$(addprefix obj-static/,$(OBJECTS)): build_all.adb
	cd obj-static; gnatmake -c -j$(CPUS) -g $(ADAFLAGS) -I.. build_all

$(addprefix obj-shared/,$(OBJECTS)): build_all.adb
	cd obj-shared; gnatmake -c -j$(CPUS) -fPIC $(ADAFLAGS) -I.. build_all

obj-static/%.o: C_code/%.c | obj-static
	gnatgcc -c -g -O2 -IC_code -D_Bool=int $< -o $@

obj-shared/%.o: C_code/%.c | obj-shared
	gnatgcc -c -fPIC -O2 -IC_code -D_Bool=int $< -o $@

build_all.adb: $(SPECS) $(BODIES)
	@for i in $(SPECS); do \
		p=`echo $$i | sed -e "s/\.ads//" -e "s/-/./g"` ; \
		echo "with $$p;" >> $@; \
	done
	@echo "procedure build_all is" >> $@
	@echo "begin" >> $@
	@echo "	 null;" >> $@
	@echo "end build_all;" >> $@

clean:
	dh_testdir
	dh_testroot
	dh_clean
	rm -rf obj-static obj-shared libtexttools* build_all.adb

binary-indep:

binary-arch: build pre-binary libtexttools-dev libtexttools$(major).$(minor)
	dh_fixperms -A -a
	dh_installdeb -A -a
	dh_gencontrol
	dh_md5sums
	dh_builddeb

pre-binary:
	dh_testdir
	dh_testroot
	dh_clean -k

libtexttools-dev: build
	dh_installdirs -p$@ \
		usr/share/ada/adainclude/texttools \
		usr/lib/ada/adalib/texttools \
		usr/share/doc/$@ \
		usr/lib
	dh_install -p$@ $(SPECS) $(BODIES) usr/share/ada/adainclude/texttools
	dh_install -p$@ obj-shared/*.ali usr/lib/ada/adalib/texttools
	dh_install -p$@ debian/texttools.gpr usr/share/ada/adainclude
	dh_install -p$@ libtexttools.a usr/lib
	dh_link -p$@ usr/lib/libtexttools.so.$(major).$(minor).$(patch) \
		usr/lib/libtexttools.so
	dh_installdocs -p$@ doc/*
	dh_installexamples -p$@ examples/* cpp
	dh_installchangelogs -p$@
	dh_compress -p$@ -X.ads -X.adb -XMakefile -X.cpp -X.h

libtexttools$(major).$(minor):
	dh_install -p$@ libtexttools.so.$(major).$(minor).$(patch) usr/lib
	dh_link -p$@ \
		usr/lib/libtexttools.so.$(major).$(minor).$(patch) \
		usr/lib/libtexttools.so.$(major).$(minor)
	dh_strip -p$@
	dh_makeshlibs -p$@
	dh_shlibdeps -p$@
	dh_installdocs -p$@
	dh_installchangelogs -p$@
	dh_compress -p$@

binary: binary-indep binary-arch
.PHONY: build clean binary-indep binary-arch binary
.PHONY: pre-binary libtexttools-dev libtexttools$(major).$(minor)