forked from mirrored-repos/manjaro-tools
buildpkg: try more dynamic approach to compiler settings
This commit is contained in:
parent
2d5355423d
commit
5f566540a8
10 changed files with 69 additions and 45 deletions
12
Makefile
12
Makefile
|
@ -28,6 +28,14 @@ SHARED_BASE = \
|
|||
SETS_PKG = \
|
||||
data/pkg.d/default.set
|
||||
|
||||
ARCH_CONF = \
|
||||
data/pkgarch.d/i686.conf \
|
||||
data/pkgarch.d/x86_64.conf \
|
||||
data/pkgarch.d/aarch64.conf \
|
||||
data/pkgarch.d/arm.conf \
|
||||
data/pkgarch.d/armv6h.conf \
|
||||
data/pkgarch.d/armv7h.conf
|
||||
|
||||
BIN_PKG = \
|
||||
bin/checkpkg \
|
||||
bin/lddd \
|
||||
|
@ -134,6 +142,9 @@ install_pkg:
|
|||
install -dm0755 $(DESTDIR)$(SYSCONFDIR)/manjaro-tools/pkg.d
|
||||
install -m0644 ${SETS_PKG} $(DESTDIR)$(SYSCONFDIR)/manjaro-tools/pkg.d
|
||||
|
||||
install -dm0755 $(DESTDIR)$(SYSCONFDIR)/manjaro-tools/pkgarch.d
|
||||
install -m0644 ${ARCH_CONF} $(DESTDIR)$(SYSCONFDIR)/manjaro-tools/pkgarch.d
|
||||
|
||||
install -dm0755 $(DESTDIR)$(PREFIX)/bin
|
||||
install -m0755 ${BIN_PKG} $(DESTDIR)$(PREFIX)/bin
|
||||
|
||||
|
@ -184,6 +195,7 @@ uninstall_base:
|
|||
|
||||
uninstall_pkg:
|
||||
for f in ${SETS_PKG}; do rm -f $(DESTDIR)$(SYSCONFDIR)/manjaro-tools/pkg.d/$$f; done
|
||||
for f in ${ARCH_CONF}; do rm -f $(DESTDIR)$(SYSCONFDIR)/manjaro-tools/pkgarch.d/$$f; done
|
||||
for f in ${BIN_PKG}; do rm -f $(DESTDIR)$(PREFIX)/bin/$$f; done
|
||||
rm -f $(DESTDIR)$(PREFIX)/bin/find-libprovides
|
||||
for f in ${SHARED_PKG}; do rm -f $(DESTDIR)$(PREFIX)/share/manjaro-tools/$$f; done
|
||||
|
|
|
@ -40,6 +40,7 @@ display_settings(){
|
|||
msg2 "buildsets: %s" "$(list_sets ${sets_dir_pkg})"
|
||||
msg2 "buildset_pkg: %s" "${buildset_pkg}"
|
||||
msg2 "is_buildset: %s" "${is_buildset}"
|
||||
msg2 "pkgarch_dir: %s" "${pkgarch_dir}"
|
||||
|
||||
msg "OPTIONS:"
|
||||
msg2 "arch: %s" "${target_arch}"
|
||||
|
@ -135,6 +136,7 @@ done
|
|||
prepare_conf "${target_arch}"
|
||||
|
||||
mirrors_conf=$(get_pac_mirrors_conf "${target_branch}")
|
||||
makepkg_conf=$(get_makepkg_conf "${target_arch}")
|
||||
|
||||
mkchroot_args+=(-C ${pacman_conf} -M ${makepkg_conf} -S ${mirrors_conf} -B "${build_mirror}/${target_branch}")
|
||||
|
||||
|
|
3
data/pkgarch.d/aarch64.conf
Normal file
3
data/pkgarch.d/aarch64.conf
Normal file
|
@ -0,0 +1,3 @@
|
|||
carch="aarch64"
|
||||
chost="aarch64-unknown-linux-gnu"
|
||||
cflags="-march=armv8-a -O2 -pipe -fstack-protector --param=ssp-buffer-size=4"
|
3
data/pkgarch.d/arm.conf
Normal file
3
data/pkgarch.d/arm.conf
Normal file
|
@ -0,0 +1,3 @@
|
|||
carch="arm"
|
||||
chost="armv5tel-unknown-linux-gnueabi"
|
||||
cflags="-march=armv5te -O2 -pipe -fstack-protector --param=ssp-buffer-size=4"
|
3
data/pkgarch.d/armv6h.conf
Normal file
3
data/pkgarch.d/armv6h.conf
Normal file
|
@ -0,0 +1,3 @@
|
|||
carch="armv6h"
|
||||
chost="armv6l-unknown-linux-gnueabihf"
|
||||
cflags="-march=armv6 -mfloat-abi=hard -mfpu=vfp -O2 -pipe -fstack-protector --param=ssp-buffer-size=4"
|
3
data/pkgarch.d/armv7h.conf
Normal file
3
data/pkgarch.d/armv7h.conf
Normal file
|
@ -0,0 +1,3 @@
|
|||
carch="armv7h"
|
||||
chost="armv7l-unknown-linux-gnueabihf"
|
||||
cflags="-march=armv7-a -mfloat-abi=hard -mfpu=vfpv3-d16 -O2 -pipe -fstack-protector --param=ssp-buffer-size=4"
|
3
data/pkgarch.d/i686.conf
Normal file
3
data/pkgarch.d/i686.conf
Normal file
|
@ -0,0 +1,3 @@
|
|||
carch="i686"
|
||||
chost="i686-pc-linux-gnu"
|
||||
cflags="-march=i686 -mtune=generic -O2 -pipe -fstack-protector-strong"
|
3
data/pkgarch.d/x86_64.conf
Normal file
3
data/pkgarch.d/x86_64.conf
Normal file
|
@ -0,0 +1,3 @@
|
|||
carch="x86_64"
|
||||
chost="x86_64-pc-linux-gnu"
|
||||
cflags="-march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong"
|
|
@ -16,56 +16,38 @@ get_makepkg_conf(){
|
|||
cp "${DATADIR}/makepkg.conf" "$conf"
|
||||
|
||||
sed -i "$conf" \
|
||||
-e "s|@CARCH[@]|$2|g" \
|
||||
-e "s|@CHOST[@]|$3|g" \
|
||||
-e "s|@CARCHFLAGS[@]|$4|g"
|
||||
-e "s|@CARCH[@]|$carch|g" \
|
||||
-e "s|@CHOST[@]|$chost|g" \
|
||||
-e "s|@CARCHFLAGS[@]|$cflags|g"
|
||||
|
||||
echo "$conf"
|
||||
}
|
||||
|
||||
load_compiler_settings(){
|
||||
local tarch="$1"
|
||||
|
||||
[[ -f ${pkgarch_dir}/$tarch.conf ]] || return 1
|
||||
|
||||
source ${pkgarch_dir}/$tarch.conf
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
# $1: target_arch
|
||||
prepare_conf(){
|
||||
if ! is_valid_arch_pkg "$1";then
|
||||
die "%s is not a valid arch!" "$1"
|
||||
fi
|
||||
|
||||
local carch chost cflags pac_arch='default'
|
||||
case "$1" in
|
||||
'arm')
|
||||
carch="$1"
|
||||
chost="armv5tel-unknown-linux-gnueabi"
|
||||
cflags="-march=armv5te -O2 -pipe -fstack-protector --param=ssp-buffer-size=4"
|
||||
;;
|
||||
'armv6h')
|
||||
carch="$1"
|
||||
chost="armv6l-unknown-linux-gnueabihf"
|
||||
cflags="-march=armv6 -mfloat-abi=hard -mfpu=vfp -O2 -pipe -fstack-protector --param=ssp-buffer-size=4"
|
||||
;;
|
||||
'armv7h')
|
||||
carch="$1"
|
||||
chost="armv7l-unknown-linux-gnueabihf"
|
||||
cflags="-march=armv7-a -mfloat-abi=hard -mfpu=vfpv3-d16 -O2 -pipe -fstack-protector --param=ssp-buffer-size=4"
|
||||
;;
|
||||
'aarch64')
|
||||
carch="$1"
|
||||
chost="aarch64-unknown-linux-gnu"
|
||||
cflags="-march=armv8-a -O2 -pipe -fstack-protector --param=ssp-buffer-size=4"
|
||||
;;
|
||||
'x86_64'|'multilib')
|
||||
carch="x86_64"
|
||||
chost="x86_64-pc-linux-gnu"
|
||||
cflags="-march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong"
|
||||
if [[ "$1" == 'multilib' ]];then
|
||||
pac_arch='multilib'
|
||||
is_multilib=true
|
||||
fi
|
||||
;;
|
||||
'i686')
|
||||
carch="$1"
|
||||
chost="i686-pc-linux-gnu"
|
||||
cflags="-march=i686 -mtune=generic -O2 -pipe -fstack-protector-strong"
|
||||
;;
|
||||
esac
|
||||
local pac_arch='default'
|
||||
|
||||
if [[ "$1" == 'multilib' ]];then
|
||||
load_compiler_settings "x86_64"
|
||||
pac_arch='multilib'
|
||||
is_multilib=true
|
||||
else
|
||||
load_compiler_settings "$1"
|
||||
fi
|
||||
|
||||
pacman_conf="${DATADIR}/pacman-$pac_arch.conf"
|
||||
|
||||
|
@ -73,8 +55,6 @@ prepare_conf(){
|
|||
pkg_dir="${cache_dir_pkg}/${target_branch}/$1"
|
||||
|
||||
[[ "$pac_arch" == 'multilib' ]] && target_arch='x86_64'
|
||||
|
||||
makepkg_conf=$(get_makepkg_conf "${target_arch}" "$carch" "$chost" "$cflags")
|
||||
}
|
||||
|
||||
pkgver_equal() {
|
||||
|
|
18
lib/util.sh
18
lib/util.sh
|
@ -92,6 +92,16 @@ list_sets(){
|
|||
echo $prof
|
||||
}
|
||||
|
||||
# $1: pkgarch_dir
|
||||
list_pkgarches(){
|
||||
local arch temp
|
||||
for item in $(ls $1/*.conf); do
|
||||
temp=${item##*/}
|
||||
arch=${arch:-}${arch:+|}${temp%.set}
|
||||
done
|
||||
echo $arch
|
||||
}
|
||||
|
||||
# $1: sets_dir
|
||||
# $2: buildset
|
||||
eval_buildset(){
|
||||
|
@ -241,6 +251,8 @@ init_buildpkg(){
|
|||
|
||||
sets_dir_pkg="${SYSCONFDIR}/pkg.d"
|
||||
|
||||
pkgarch_dir="${SYSCONFDIR}/pkgarch.d"
|
||||
|
||||
[[ -d ${USERCONFDIR}/pkg.d ]] && sets_dir_pkg=${USERCONFDIR}/pkg.d
|
||||
|
||||
[[ -z ${buildset_pkg} ]] && buildset_pkg='default'
|
||||
|
@ -545,10 +557,10 @@ is_valid_init(){
|
|||
}
|
||||
|
||||
is_valid_arch_pkg(){
|
||||
case $1 in
|
||||
'i686'|'x86_64'|'multilib'|'arm'|'armv6h'|'armv7h'|'aarch64') return 0 ;;
|
||||
eval "case $1 in
|
||||
$(list_pkgarches "${pkgarch_dir}")|multilib) return 0 ;;
|
||||
*) return 1 ;;
|
||||
esac
|
||||
esac"
|
||||
}
|
||||
|
||||
is_valid_arch_iso(){
|
||||
|
|
Loading…
Reference in a new issue