File: sys-build.mk

package info (click to toggle)
glib2.0 2.0.1-2
  • links: PTS
  • area: main
  • in suites: woody
  • size: 2,072 kB
  • ctags: 24
  • sloc: sh: 4,219; makefile: 254
file content (167 lines) | stat: -rw-r--r-- 4,948 bytes parent folder | download | duplicates (80)
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
157
158
159
160
161
162
163
164
165
166
167
#!/usr/bin/make -f
# Separate tarball/patch build system by Adam Heath <doogie@debian.org>

# The magic targets that you need to concern yourself with are:
#
# source.build:		Unpacks upstream tarballs, optionally applies patches
#			to fix the upstream patches, then applies upstream
#			patches.
# source.make:		Applies debian patches.
# source.clean:		Cleans the build directory, then unfixes the upstream
#			patches.
# source.compile:	Will compile the source for you.  Please check
#			debian/scripts/vars.
# source.cmd:		When calling this target, if you define a variable
#			SOURCE_CMD, it will run that command in the build
#			tree.
# make-diff:		Generates debian.diff in the current directory which
#			contains all edits that are currently in the build
#			tree.
#
# Nothing in this file should require any editting.  Please look at
# debian/scripts/vars for things to change for the local environment.
#
# debian/rules target		command
# ----------------------------------------------------------------
# clean:			$(MAKE) -f debian/sys-build.mk source.clean
# build:			$(MAKE) -f debian/sys-build.mk source.compile
#					for simple systems.
# build:			$(MAKE) -f debian/sys-build.mk source.make
#					and, in the rules file, you can
#					build the targets you want.
SHELL=/bin/bash
ifndef NOISY
.SILENT:
endif

include debian/scripts/vars
# remove quotes
DIFF_EXCLUDE:=$(patsubst %,-x %,$(shell echo $(DIFF_EXCLUDE)))

ifdef TAR_DIR
BUILD_TREE=$(SOURCE_DIR)/$(TAR_DIR)
else
BUILD_TREE=$(SOURCE_DIR)
endif

SOURCE_CMD=:

ifdef CLEAN_IGNORE
	CLEAN_CMD=-
	CLEAN_SH=
else
	CLEAN_CMD=
	CLEAN_SH=
endif
ifndef CLEAN_TARGET
	CLEAN_TARGET=clean
endif

foo:
	echo $(DIFF_EXCLUDE)

make-diff:
	mv $(BUILD_TREE) bak
	$(MAKE) -f debian/sys-build.mk source.clean
	$(MAKE) -f debian/sys-build.mk source.make
	mv $(BUILD_TREE) $(BUILD_TREE).orig
	mv bak $(BUILD_TREE)

ifdef TAR_DIR
ifdef CLEAN_TARGET_EXTERNAL
	$(CLEAN_CMD)$(MAKE) -f debian/rules $(CLEAN_TARGET_EXTERNAL)
else
	$(CLEAN_CMD)$(MAKE) -C $(BUILD_TREE) $(CLEAN_TARGET)
endif
	-(cd $(SOURCE_DIR);diff -ruN $(TAR_DIR).orig $(TAR_DIR) $(DIFF_EXCLUDE)) > debian.diff
else
ifdef CLEAN_TARGET_EXTERNAL
	$(CLEAN_CMD)$(MAKE) -f debian/rules $(CLEAN_TARGET_EXTERNAL)
else
	$(CLEAN_CMD)for a in $(BUILD_TREE)/*;do $(MAKE) -C $$a $(CLEAN_TARGET);done
endif
	-(diff -ruN $(BUILD_TREE).orig $(BUILD_TREE) $(DIFF_EXCLUDE)) > debian.diff
	if [ ! -s debian.diff ];then\
		rm debian.diff;\
	fi
endif
	rm -rf $(BUILD_TREE).orig

patchapply: $(STAMP_DIR)/patchapply
$(STAMP_DIR)/patchapply: $(STAMP_DIR)/source.build $(STAMP_DIR)
	$(SHELL) debian/scripts/lib patch.apply
	touch $@
	rm -f $(STAMP_DIR)/patchunapply

patchunapply: $(STAMP_DIR)/patchunapply
$(STAMP_DIR)/patchunapply: $(STAMP_DIR)/source.build $(STAMP_DIR)
	$(SHELL) debian/scripts/lib patch.unapply
	touch $@
	rm -f $(STAMP_DIR)/patchapply

.export: SOURCE_TREE

#
# The rules that really do the work all start with $(STAMPDIR)
# This little trick allows us to use stamp files to keep us from
# having to rerun long targets over and over.  It also puts
# all stamp files in one place, for easy cleaning.
#
# If a stampdir rule depends on something else, be sure it is
# another stampdir rule.  Depending on base rule won't work.
#

source.build: $(STAMP_DIR)/source.build
STAMP_DIR_TARGETS+= $(STAMP_DIR)/source.build
$(STAMP_DIR)/source.build: $(STAMP_DIR)/source.unpack $(STAMP_DIR)/source.patch $(STAMP_DIR)
	touch $@

source.make: $(STAMP_DIR)/source.make
STAMP_DIR_TARGETS+= $(STAMP_DIR)/source.make
$(STAMP_DIR)/source.make: $(STAMP_DIR)/source.build $(STAMP_DIR)/patchapply $(STAMP_DIR)
	touch $@

source.unpack: $(STAMP_DIR)/source.unpack
STAMP_DIR_TARGETS+= $(STAMP_DIR)/source.unpack
$(STAMP_DIR)/source.unpack: $(STAMP_DIR)
	$(SHELL) debian/scripts/source.unpack
	touch $@

source.patch: $(STAMP_DIR)/source.patch
STAMP_DIR_TARGETS+= $(STAMP_DIR)/source.patch
$(STAMP_DIR)/source.patch: $(STAMP_DIR)/source.unpack $(STAMP_DIR)/fix.source.patch $(STAMP_DIR)
	$(SHELL) debian/scripts/lib source.patch
	touch $@

fix.source.patch: $(STAMP_DIR)/fix.source.patch
STAMP_DIR_TARGETS+= $(STAMP_DIR)/fix.source.patch
$(STAMP_DIR)/fix.source.patch: $(STAMP_DIR)
	$(SHELL) debian/scripts/lib fix.source.patch
	touch $@

unfix.source.patch: $(STAMP_DIR)/unfix.source.patch
STAMP_DIR_TARGETS+= $(STAMP_DIR)/unfix.source.patch
$(STAMP_DIR)/unfix.source.patch: $(STAMP_DIR)
	$(SHELL) debian/scripts/lib unfix.source.patch
	touch $@

source.compile: $(STAMP_DIR)/source.compile
STAMP_DIR_TARGETS+= $(STAMP_DIR)/source.compile
$(STAMP_DIR)/source.compile: $(STAMP_DIR)/source.make $(STAMP_DIR)
	$(MAKE) -C $(BUILD_TREE) $(BUILD_TARGET)
	touch $@

source.command:
	(cd $(BUILD_TREE); $(SOURCE_CMD))

DIR_TARGETS+=$(STAMP_DIR)
$(STAMP_DIR_TARGETS): $(STAMP_DIR)

$(DIR_TARGETS)/:
	mkdir -p $@

source.clean: unfix.source.patch
	$(SHELL) debian/scripts/lib source.clean
	rm -f $(STAMP_DIR_TARGETS)
	rm -rf $(STAMP_DIR)
	$(MAKE) -C debian/scripts clean