2 # Separate tarball/patch build system by Adam Heath <doogie@debian.org>
4 # The magic targets that you need to concern yourself with are:
6 # source.build: Unpacks upstream tarballs, optionally applies patches
7 # to fix the upstream patches, then applies upstream
9 # source.make: Applies debian patches.
10 # source.clean: Cleans the build directory, then unfixes the upstream
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
17 # make-diff: Generates debian.diff in the current directory which
18 # contains all edits that are currently in the build
21 # Nothing in this file should require any editting. Please look at
22 # debian/scripts/vars for things to change for the local environment.
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
29 # build: $(MAKE) -f debian/sys-build.mk source.make
30 # and, in the rules file, you can
31 # build the targets you want.
37 include debian/scripts/vars
39 DIFF_EXCLUDE:=$(patsubst %,-x %,$(shell echo $(DIFF_EXCLUDE)))
42 BUILD_TREE=$(SOURCE_DIR)/$(TAR_DIR)
44 BUILD_TREE=$(SOURCE_DIR)
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
71 ifdef CLEAN_TARGET_EXTERNAL
72 $(CLEAN_CMD)$(MAKE) -f debian/rules $(CLEAN_TARGET_EXTERNAL)
74 $(CLEAN_CMD)$(MAKE) -C $(BUILD_TREE) $(CLEAN_TARGET)
76 -(cd $(SOURCE_DIR);diff -ruN $(TAR_DIR).orig $(TAR_DIR) $(DIFF_EXCLUDE)) > debian.diff
78 ifdef CLEAN_TARGET_EXTERNAL
79 $(CLEAN_CMD)$(MAKE) -f debian/rules $(CLEAN_TARGET_EXTERNAL)
81 $(CLEAN_CMD)for a in $(BUILD_TREE)/*;do $(MAKE) -C $$a $(CLEAN_TARGET);done
83 -(diff -ruN $(BUILD_TREE).orig $(BUILD_TREE) $(DIFF_EXCLUDE)) > debian.diff
84 if [ ! -s debian.diff ];then\
88 rm -rf $(BUILD_TREE).orig
90 patchapply: $(STAMP_DIR)/patchapply
91 $(STAMP_DIR)/patchapply: $(STAMP_DIR)/source.build $(STAMP_DIR)
92 $(SHELL) debian/scripts/lib patch.apply
94 rm -f $(STAMP_DIR)/patchunapply
96 patchunapply: $(STAMP_DIR)/patchunapply
97 $(STAMP_DIR)/patchunapply: $(STAMP_DIR)/source.build $(STAMP_DIR)
98 $(SHELL) debian/scripts/lib patch.unapply
100 rm -f $(STAMP_DIR)/patchapply
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.
110 # If a stampdir rule depends on something else, be sure it is
111 # another stampdir rule. Depending on base rule won't work.
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)
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)
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
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
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
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
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)
155 (cd $(BUILD_TREE); $(SOURCE_CMD))
157 DIR_TARGETS+=$(STAMP_DIR)
158 $(STAMP_DIR_TARGETS): $(STAMP_DIR)
163 source.clean: unfix.source.patch
164 $(SHELL) debian/scripts/lib source.clean
165 rm -f $(STAMP_DIR_TARGETS)
167 $(MAKE) -C debian/scripts clean