File: rules

package info (click to toggle)
contest 0.61-5
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 228 kB
  • ctags: 217
  • sloc: ansic: 2,121; makefile: 98; sh: 3
file content (91 lines) | stat: -rwxr-xr-x 2,544 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
#!/usr/bin/make -f

export DEB_BUILD_ARCH      := $(shell dpkg-architecture $(ha) -qDEB_BUILD_ARCH)
export DEB_BUILD_GNU_CPU   := $(shell dpkg-architecture $(ha) -qDEB_BUILD_GNU_CPU)
export DEB_BUILD_GNU_SYSTEM:= $(shell dpkg-architecture $(ha) -qDEB_BUILD_GNU_SYSTEM)
export DEB_BUILD_GNU_TYPE  := $(shell dpkg-architecture $(ha) -qDEB_BUILD_GNU_TYPE)
export DEB_HOST_ARCH       := $(shell dpkg-architecture $(ha) -qDEB_HOST_ARCH)
export DEB_HOST_GNU_CPU    := $(shell dpkg-architecture $(ha) -qDEB_HOST_GNU_CPU)
export DEB_HOST_GNU_SYSTEM := $(shell dpkg-architecture $(ha) -qDEB_HOST_GNU_SYSTEM)
export DEB_HOST_GNU_TYPE   := $(shell dpkg-architecture $(ha) -qDEB_HOST_GNU_TYPE)


# some useful vars
SRC_DIR = $(shell pwd)
TEMP_DIR = $(SRC_DIR)/debian/tmp
BIN_DIR = $(TEMP_DIR)/usr/bin
MAN_DIR = $(TEMP_DIR)/usr/share/man
DOC_DIR = $(TEMP_DIR)/usr/share/doc/contest
EXAMPLES_DIR = $(DOC_DIR)/examples

install_file = install -p -o root -g root -m 644
make_dir = install -p -d -o root -g root -m 755


# checks if the current directory is the right one by testing debian/control 
# and bmark.c existence
define check_dir
	@test -f debian/control -a -f bmark.c || exit 1
endef

# creates the necessary directories
define create_dir
	$(check_dir);
	@$(make_dir) $(TEMP_DIR)/DEBIAN;
	@$(make_dir) $(BIN_DIR);
	@$(make_dir) $(MAN_DIR)/man1;
	@$(make_dir) $(DOC_DIR);
	@$(make_dir) $(EXAMPLES_DIR);
endef

# checks if the current user is root
define check_root
	@test `whoami` = "root" || exit 1;
endef

# installs appropriate documentation (and examples)
define install_doc
	@$(install_file) README $(DOC_DIR)
	@gzip -9f $(DOC_DIR)/README
	@$(install_file) contest.config $(EXAMPLES_DIR)
	@$(install_file) debian/changelog $(DOC_DIR)/changelog.Debian
	@gzip -9 $(DOC_DIR)/changelog.Debian
	@$(install_file) debian/copyright $(DOC_DIR)
	@$(install_file) debian/README.Debian $(DOC_DIR)
endef


build: stamp-build

stamp-build:
	make
	touch stamp-build

clean: 
	$(check_dir)
	rm -fr debian/tmp
	rm -f debian/files debian/substvars
	rm -f stamp-build stamp-binary
	make clean


binary: binary-arch binary-indep 

binary-indep: build

binary-arch: build stamp-binary

stamp-binary:
	$(check_root)
	$(create_dir)
	make install INSTPATH=$(TEMP_DIR) BIN=$(BIN_DIR) MAN=$(MAN_DIR)
	strip -R.note -R.comment $(BIN_DIR)/contest
	$(install_doc)
	dpkg-shlibdeps contest
	chown -R root.root $(TEMP_DIR)
	chmod -R go=rX     $(BIN_DIR)
	dpkg-gencontrol -isp
	dpkg --build $(TEMP_DIR) ..
	touch stamp-binary

.PHONY: build clean binary binary-arch binary-indep