]> git.llucax.com Git - software/mutt-debian.git/blob - debian/sys-build.mk
mutt (1.5.9-2sarge2) stable-security; urgency=high
[software/mutt-debian.git] / debian / sys-build.mk
1 #!/usr/bin/make -f
2 # Separate tarball/patch build system by Adam Heath <doogie@debian.org>
3
4 # The magic targets that you need to concern yourself with are:
5 #
6 # source.build:         Unpacks upstream tarballs, optionally applies patches
7 #                       to fix the upstream patches, then applies upstream
8 #                       patches.
9 # source.make:          Applies debian patches.
10 # source.clean:         Cleans the build directory, then unfixes the upstream
11 #                       patches.
12 # source.compile:       Will compile the source for you.  Please check
13 #                       debian/scripts/vars.
14 # source.cmd:           When calling this target, if you define a variable
15 #                       SOURCE_CMD, it will run that command in the build
16 #                       tree.
17 # make-diff:            Generates debian.diff in the current directory which
18 #                       contains all edits that are currently in the build
19 #                       tree.
20 #
21 # Nothing in this file should require any editting.  Please look at
22 # debian/scripts/vars for things to change for the local environment.
23 #
24 # debian/rules target           command
25 # ----------------------------------------------------------------
26 # clean:                        $(MAKE) -f debian/sys-build.mk source.clean
27 # build:                        $(MAKE) -f debian/sys-build.mk source.compile
28 #                                       for simple systems.
29 # build:                        $(MAKE) -f debian/sys-build.mk source.make
30 #                                       and, in the rules file, you can
31 #                                       build the targets you want.
32 SHELL=/bin/bash
33 ifndef NOISY
34 .SILENT:
35 endif
36
37 include debian/scripts/vars
38 # remove quotes
39 DIFF_EXCLUDE:=$(patsubst %,-x %,$(shell echo $(DIFF_EXCLUDE)))
40
41 ifdef TAR_DIR
42 BUILD_TREE=$(SOURCE_DIR)/$(TAR_DIR)
43 else
44 BUILD_TREE=$(SOURCE_DIR)
45 endif
46
47 SOURCE_CMD=:
48
49 ifdef CLEAN_IGNORE
50         CLEAN_CMD=-
51         CLEAN_SH=
52 else
53         CLEAN_CMD=
54         CLEAN_SH=
55 endif
56 ifndef CLEAN_TARGET
57         CLEAN_TARGET=clean
58 endif
59
60 foo:
61         echo $(DIFF_EXCLUDE)
62
63 make-diff:
64         mv $(BUILD_TREE) bak
65         $(MAKE) -f debian/sys-build.mk source.clean
66         $(MAKE) -f debian/sys-build.mk source.make
67         mv $(BUILD_TREE) $(BUILD_TREE).orig
68         mv bak $(BUILD_TREE)
69
70 ifdef TAR_DIR
71 ifdef CLEAN_TARGET_EXTERNAL
72         $(CLEAN_CMD)$(MAKE) -f debian/rules $(CLEAN_TARGET_EXTERNAL)
73 else
74         $(CLEAN_CMD)$(MAKE) -C $(BUILD_TREE) $(CLEAN_TARGET)
75 endif
76         -(cd $(SOURCE_DIR);diff -ruN $(TAR_DIR).orig $(TAR_DIR) $(DIFF_EXCLUDE)) > debian.diff
77 else
78 ifdef CLEAN_TARGET_EXTERNAL
79         $(CLEAN_CMD)$(MAKE) -f debian/rules $(CLEAN_TARGET_EXTERNAL)
80 else
81         $(CLEAN_CMD)for a in $(BUILD_TREE)/*;do $(MAKE) -C $$a $(CLEAN_TARGET);done
82 endif
83         -(diff -ruN $(BUILD_TREE).orig $(BUILD_TREE) $(DIFF_EXCLUDE)) > debian.diff
84         if [ ! -s debian.diff ];then\
85                 rm debian.diff;\
86         fi
87 endif
88         rm -rf $(BUILD_TREE).orig
89
90 patchapply: $(STAMP_DIR)/patchapply
91 $(STAMP_DIR)/patchapply: $(STAMP_DIR)/source.build $(STAMP_DIR)
92         $(SHELL) debian/scripts/lib patch.apply
93         touch $@
94         rm -f $(STAMP_DIR)/patchunapply
95
96 patchunapply: $(STAMP_DIR)/patchunapply
97 $(STAMP_DIR)/patchunapply: $(STAMP_DIR)/source.build $(STAMP_DIR)
98         $(SHELL) debian/scripts/lib patch.unapply
99         touch $@
100         rm -f $(STAMP_DIR)/patchapply
101
102 .export: SOURCE_TREE
103
104 #
105 # The rules that really do the work all start with $(STAMPDIR)
106 # This little trick allows us to use stamp files to keep us from
107 # having to rerun long targets over and over.  It also puts
108 # all stamp files in one place, for easy cleaning.
109 #
110 # If a stampdir rule depends on something else, be sure it is
111 # another stampdir rule.  Depending on base rule won't work.
112 #
113
114 source.build: $(STAMP_DIR)/source.build
115 STAMP_DIR_TARGETS+= $(STAMP_DIR)/source.build
116 $(STAMP_DIR)/source.build: $(STAMP_DIR)/source.unpack $(STAMP_DIR)/source.patch $(STAMP_DIR)
117         touch $@
118
119 source.make: $(STAMP_DIR)/source.make
120 STAMP_DIR_TARGETS+= $(STAMP_DIR)/source.make
121 $(STAMP_DIR)/source.make: $(STAMP_DIR)/source.build $(STAMP_DIR)/patchapply $(STAMP_DIR)
122         touch $@
123
124 source.unpack: $(STAMP_DIR)/source.unpack
125 STAMP_DIR_TARGETS+= $(STAMP_DIR)/source.unpack
126 $(STAMP_DIR)/source.unpack: $(STAMP_DIR)
127         $(SHELL) debian/scripts/source.unpack
128         touch $@
129
130 source.patch: $(STAMP_DIR)/source.patch
131 STAMP_DIR_TARGETS+= $(STAMP_DIR)/source.patch
132 $(STAMP_DIR)/source.patch: $(STAMP_DIR)/source.unpack $(STAMP_DIR)/fix.source.patch $(STAMP_DIR)
133         $(SHELL) debian/scripts/lib source.patch
134         touch $@
135
136 fix.source.patch: $(STAMP_DIR)/fix.source.patch
137 STAMP_DIR_TARGETS+= $(STAMP_DIR)/fix.source.patch
138 $(STAMP_DIR)/fix.source.patch: $(STAMP_DIR)
139         $(SHELL) debian/scripts/lib fix.source.patch
140         touch $@
141
142 unfix.source.patch: $(STAMP_DIR)/unfix.source.patch
143 STAMP_DIR_TARGETS+= $(STAMP_DIR)/unfix.source.patch
144 $(STAMP_DIR)/unfix.source.patch: $(STAMP_DIR)
145         $(SHELL) debian/scripts/lib unfix.source.patch
146         touch $@
147
148 source.compile: $(STAMP_DIR)/source.compile
149 STAMP_DIR_TARGETS+= $(STAMP_DIR)/source.compile
150 $(STAMP_DIR)/source.compile: $(STAMP_DIR)/source.make $(STAMP_DIR)
151         $(MAKE) -C $(BUILD_TREE) $(BUILD_TARGET)
152         touch $@
153
154 source.command:
155         (cd $(BUILD_TREE); $(SOURCE_CMD))
156
157 DIR_TARGETS+=$(STAMP_DIR)
158 $(STAMP_DIR_TARGETS): $(STAMP_DIR)
159
160 $(DIR_TARGETS)/:
161         mkdir -p $@
162
163 source.clean: unfix.source.patch
164         $(SHELL) debian/scripts/lib source.clean
165         rm -f $(STAMP_DIR_TARGETS)
166         rm -rf $(STAMP_DIR)
167         $(MAKE) -C debian/scripts clean