Linux Archive

Linux Archive (http://www.linux-archive.org/)
-   ArchLinux Pacman Development (http://www.linux-archive.org/archlinux-pacman-development/)
-   -   makepkg: add option to include debugging compiler flags (http://www.linux-archive.org/archlinux-pacman-development/706643-makepkg-add-option-include-debugging-compiler-flags.html)

Allan McRae 09-23-2012 02:44 PM

makepkg: add option to include debugging compiler flags
 
Add a "debug" option that appends the compiler flags specified in the
variables DEBUG_CFLAGS and DEBUG_CXXFLAGS in makepkg.conf to their
counterpart buildflags.

Signed-off-by: Allan McRae <allan@archlinux.org>
---
doc/PKGBUILD.5.txt | 3 +++
doc/makepkg.conf.5.txt | 12 ++++++++++++
etc/makepkg.conf.in | 8 ++++++--
scripts/makepkg.sh.in | 8 +++++++-
4 files changed, 28 insertions(+), 3 deletions(-)

diff --git a/doc/PKGBUILD.5.txt b/doc/PKGBUILD.5.txt
index 0dca4a2..113e2c4 100644
--- a/doc/PKGBUILD.5.txt
+++ b/doc/PKGBUILD.5.txt
@@ -274,6 +274,9 @@ A normal sync or upgrade will not use its value.
`!makeflags` with select packages that have problems building with
custom makeflags such as `-j2` (or higher).

+ *debug*;;
+ Add the user-specified debug flags (DEBUG_CFLAGS, DEBUG_CXXFLAGS) to
+ their counterpart buildflags as specified in linkman:makepkg.conf[5].

build() Function
----------------
diff --git a/doc/makepkg.conf.5.txt b/doc/makepkg.conf.5.txt
index 3dbaea1..cf7026c 100644
--- a/doc/makepkg.conf.5.txt
+++ b/doc/makepkg.conf.5.txt
@@ -77,6 +77,14 @@ Options
This is often used to set the number of jobs used, for example, `-j2`.
Other flags that make accepts can also be passed.

+**DEBUG_CFLAGS=**"debug_cflags"::
+ Additional compiler flags appended to CFLAGS for use in debugging. Usually
+ this would include: ``-g'. Read gcc(1) for more details on the wide
+ variety of compiler flags available.
+
+**DEBUG_CXXFLAGS=**"debug_cxxflags"::
+ Debug flags used for the C++ compiler; see DEBUG_CFLAGS for more info.
+
**BUILDENV=(**fakeroot !distcc color !ccache check !sign**)**::
This array contains options that affect the build environment, the defaults
are shown here. All options should always be left in the array; to enable
@@ -165,6 +173,10 @@ Options
Compress binary executable files using UPX. Additional options
can be passed to UPX by specifying the `UPXFLAGS` variable.

+ *debug*;;
+ Add the user-specified debug flags as specified in DEBUG_CFLAGS and
+ DEBUG_CXXFLAGS to their counterpart buildflags.
+
**INTEGRITY_CHECK=(**check1 ...**)**::
File integrity checks to use. Multiple checks may be specified; this
affects both generation and checking. The current valid options are:
diff --git a/etc/makepkg.conf.in b/etc/makepkg.conf.in
index dcec6f5..0de85c9 100644
--- a/etc/makepkg.conf.in
+++ b/etc/makepkg.conf.in
@@ -33,6 +33,9 @@ CHOST="@CHOST@"
#LDFLAGS=""
#-- Make Flags: change this for DistCC/SMP systems
#MAKEFLAGS="-j2"
+#-- Debugging flags
+#DEBUG_CFLAGS="-g"
+#DEBUG_CXXFLAGS="-g"

################################################## #######################
# BUILD ENVIRONMENT
@@ -62,7 +65,7 @@ BUILDENV=(fakeroot !distcc color !ccache check !sign)
# These are default values for the options=() settings
################################################## #######################
#
-# Default: OPTIONS=(strip docs libtool emptydirs zipman purge !upx)
+# Default: OPTIONS=(strip docs libtool emptydirs zipman purge !upx !debug)
# A negated option will do the opposite of the comments below.
#
#-- strip: Strip symbols from binaries/libraries
@@ -72,8 +75,9 @@ BUILDENV=(fakeroot !distcc color !ccache check !sign)
#-- zipman: Compress manual (man and info) pages in MAN_DIRS with gzip
#-- purge: Remove files specified by PURGE_TARGETS
#-- upx: Compress binary executable files using UPX
+#-- debug: Add debugging flags as specified in DEBUG_* variables
#
-OPTIONS=(strip docs libtool emptydirs zipman purge !upx)
+OPTIONS=(strip docs libtool emptydirs zipman purge !upx !debug)

#-- File integrity checks to use. Valid: md5, sha1, sha256, sha384, sha512
INTEGRITY_CHECK=(md5)
diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
index 40e8c2f..7b516ff 100644
--- a/scripts/makepkg.sh.in
+++ b/scripts/makepkg.sh.in
@@ -44,7 +44,8 @@ declare -r confdir='@sysconfdir@'
declare -r BUILDSCRIPT='@BUILDSCRIPT@'
declare -r startdir="$PWD"

-packaging_options=('strip' 'docs' 'libtool' 'emptydirs' 'zipman' 'purge' 'upx')
+packaging_options=('strip' 'docs' 'libtool' 'emptydirs' 'zipman' 'purge' 'upx'
+ 'debug')
other_options=('ccache' 'distcc' 'buildflags' 'makeflags')
splitpkg_overrides=('pkgver' 'pkgrel' 'epoch' 'pkgdesc' 'arch' 'url' 'license'
'groups' 'depends' 'optdepends' 'provides' 'conflicts'
@@ -1335,6 +1336,11 @@ run_function() {
unset CPPFLAGS CFLAGS CXXFLAGS LDFLAGS
fi

+ if check_option "debug" "y"; then
+ CFLAGS+=" $DEBUG_CFLAGS"
+ CXXFLAGS+=" $DEBUG_CXXFLAGS"
+ fi
+
# clear user-specified makeflags if requested
if check_option "makeflags" "n"; then
unset MAKEFLAGS
--
1.7.12.1


All times are GMT. The time now is 07:03 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.