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 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185
|
###
### This file is a makefile fragment to be included on top of
### the debian/rules makefile __and__ on top of the package
### makefile. It does nothing, as all is conditioned on a couple of
### variables: _debian_policy_ for the debian's policy variables
### definitions, and create_debug_lib for the overwriting rule.
###
this_dir=${shell pwd}
abs_src = /usr/src/$(shell basename ${this_dir})
######################## debian policy implementation ########################
ifdef _debian_policy_
# this is the version of the policy to be included in
# debian/control file through $${update_standards_version}
std-version = 2.4.0
version=${shell expr `pwd` : '.*-\([0-9.]*\)'}
version_major=${shell expr `pwd` : '.*-\([0-9]*\).[0-9.]*'}
arch = ${shell dpkg --print-gnu-build-architecture}
# the directories that needs to be created;
# better list them here than in another file.
#
# ATTENTION: some makefile adds ../ in front of $$prefix
# others change curdir as it were shoes ...
# use relative d_build in the first case,
relative_d_build = debian/tmp
# absolute d_build in the second case.
absolute_d_build = ${this_dir}/debian/tmp
#
d_build = ${absolute_d_build}
#
d_deb = ${d_build}/DEBIAN
d_etc = ${d_build}/etc
d_lib = ${d_build}/lib
d_usr = ${d_build}/usr
d_ulib = ${d_build}/usr/lib
d_bin = ${d_build}/usr/bin
d_sbin = ${d_build}/usr/sbin
d_incl = ${d_build}/usr/include
d_man = ${d_build}/usr/man
d_menu = ${d_build}/usr/lib/menu
d_locl = ${d_build}/usr/share/locale
d_doc = ${d_build}/usr/doc/${package}
d_dirs = ${d_deb} ${d_etc} ${d_lib} ${d_usr} ${d_ulib} ${d_bin} ${d_sbin} ${d_incl} ${d_man} ${d_menu} ${d_locl} ${d_doc}
# simple commands
define checkdir
@echo -e "\n\t########## ${package} rules $@ ##########\n"
test -f debian/rules
endef
define install_dir
install -p -o root -g root -m 755 -d
endef
define install_bin
install -p -o root -g root -m 755
endef
define install_data
install -p -o root -g root -m 644
endef
define compress_docs
find -type f \( -name "changelog.Debian" -or -size +4k \) \
! -name "copyright" \
! -name "*.html" ! -name "*.htm" \
! -name "*.gif" ! -name "*.css" \
! -name "*.gz" ! -iname "*.z" \
| xargs --no-run-if-empty gzip -v9
endef
define clean_dirs
cd ${d_build} \
&& touch ${d_deb}/md5sums \
&& until ( find -type d -empty \
-exec rmdir {} \; ) ; \
do :; done 2>&1 \
| sed 's/No such file or directory/ removed/'
endef
define install_md5sums
find . -path './DEBIAN' -prune -o -type f -printf "%P " \
| xargs --no-run-if-empty md5sum >DEBIAN/md5sums
endef
### can set a prefix to install for different binary packages.
### eg.: prefix="dbg_" && cd debian && ${install_DEBIAN_scripts}
### will install debian/dbg_postinst as tmp/DEBIAN/postinst ...
define install_DEBIAN_scripts
for script in preinst postinst prerm postrm; \
do if test -e "$${prefix}$${script}"; \
then echo " installing $${prefix}$${script}"; \
${install_bin} $${prefix}$${script} ${d_deb}/$${script} ; fi; \
done
endef
define update_standards_version
test -n "${std-version}" \
&& perl -pi~ -e 's/^(Standards-Version:).*/$$1 ${std-version}/'
endef
define install_sources
for src in `strings -a ${d_ulib}/debug/* | grep '$(abs_src)' | sort -u` ; \
do for fullname in $${src} ; \
do fulldir=`dirname $${fullname}` ; \
${install_dir} ${d_build}$${fulldir} ; \
localname=`echo $${fullname} | sed 's,^${abs_src}/,,'` ; \
ls $${localname} 2>/dev/null \
&& ${install_data} $${localname} ${d_build}$${fullname} ; \
done; done;
endef
ifdef list_build_enabled
define list_build_if_enabled
cd ${d_build} && find -ls
endef
else
define list_build_if_enabled
true
endef
endif # list_build_enabled
endif # _debian_policy_
###############################################################################
### this fragment of makefile _must_ be included in the makefile
### and this variable ( create_debug_lib ) must be passed to the
### sub-make to activate this rule. Do this in the debug building
ifdef create_debug_lib
_SRCDIR_:
ln -sf . $@
### How does this work?
### a little explanation:
### the build stage (and all the binary) depends from a file not phony
### named _SRCDIR_ which is created in the current working dir as a
### symlink to . (dot, the current dir), and removed in the clean stage.
### We overwrite the implicit rule to make objects from .c sources,
### producing the asm source file from the .c source seen through the
### _SRCDIR_ symlink. In the rule we change that strange name with the
### absolute pathname where we will store the sources, so that the
### object (and the libraries) will record that name instead that the
### actual one.
### The purpose is to have a default link from the libraries to the
### place where the debugging binary package will put the sources, so that
### gdb will diplay source lines without _any_ need of strange declarations.
define compile.c
${COMPILE.c} -S _SRCDIR_/$< -o $*.ss
endef
define compile.cc
${COMPILE.cc} -S _SRCDIR_/$< -o $*.ss
endef
define the_rest
sed 's,^.stabs \"_SRCDIR_\/,.stabs \"${abs_src}/,' $*.ss > $*.s
${COMPILE.s} -o $@ $*.s
${RM} $*.ss $*.s
endef
# overwriting implicit rule
%.o: %.c _SRCDIR_
@echo "=== overwritten rule .o:.c ($@: $^) ==="
${compile.c}
${the_rest}
# overwriting implicit rule
%.o: %.cc _SRCDIR_
@echo "=== overwritten rule .o:.cc ($@: $^) ==="
${compile.cc}
${the_rest}
endif # create_debug_lib
###############################################################################
|