/make (eb22eec387e1df3844f99f9a204f0bc218f3b176) (7996 bytes) (mode 100755) (type blob)
#!/bin/sh
#this script is brutal and verbose, has no tricks and is quite linear, then
#quite easy to deal with
#for the moment, it's hardcoded for a gcc toolchain... BAD! Since now
#gcc is a c++ piece of shit
# stolen from ffmpeg configure like a pig
set -e
# prevent locale nonsense from breaking basic text processing
LC_ALL=C
export LC_ALL
# libtool versioning?? Is age ok??
libkmod_api=2
libkmod_rev=3
libkmod_age=2
libkmod_so_version=${libkmod_api}.${libkmod_rev}.${libkmod_age}
fake_root=fake_root
#-------------------------------------------------------------------------------
# it's benign here, but keep in mind it does define the order of static linking
# which is important for proper symbol selection
libkmod_src_files='
src/libkmod.c
src/libkmod-list.c
src/libkmod-config.c
src/libkmod-index.c
src/libkmod-module.c
src/libkmod-file.c
src/libkmod-elf.c
src/libkmod-signature.c
src/shared/util.c
src/shared/strbuf.c
src/shared/hash.c
'
# it's benign here, but keep in mind it does define the order of static linking
# which is important for proper symbol selection
kmod_src_files='
src/tools/kmod.c
src/tools/lsmod.c
src/tools/rmmod.c
src/tools/insmod.c
src/tools/modinfo.c
src/tools/modprobe.c
src/tools/depmod.c
src/tools/static-nodes.c
src/tools/log.c
src/shared/util.c
src/shared/strbuf.c
src/shared/hash.c
src/shared/array.c
src/shared/scratchbuf.c
'
#-------------------------------------------------------------------------------
sep_start()
{
printf '###############################################################################\n'
}
sep_end()
{
printf '###############################################################################\n\n'
}
subsep_start()
{
printf '*******************************************************************************\n'
}
subsep_end()
{
printf '*******************************************************************************\n'
}
################################################################################
if test -f make; then
src_path=.
else
src_path=$(cd $(dirname "$0"); pwd)
echo "$src_path" | grep -q '[[:blank:]]' &&
die "out of tree builds are impossible with whitespace in source path."
fi
################################################################################
is_in()
{
value=$1
shift
for var in $*; do
[ $var = $value ] && return 0
done
return 1
}
die_unknown()
{
echo "Unknown option \"$1\"."
echo "See $0 --help for available options."
exit 1
}
set_default()
{
for opt; do
eval : \${$opt:=\$${opt}_default}
done
}
spaces_concat()
{
printf "$1" | tr -s '[:space:]' ' '
}
CMDLINE_SET='
bin_cc
bin_ccld
libkmod_cc
libkmod_ar
dbin_cc
dbin_ccld
slibkmod_cc
slibkmod_ccld
prefix
bindir
libdir
includedir
sysconfdir
version
'
################################################################################
#command line set defaults
#-------------------------------------------------------------------------------
bin_cc_default="gcc -Wall -Wextra -Wno-unused-parameter \
-Wno-format-truncation \
-std=gnu99 -O2 -c"
bin_ccld_default="gcc -static"
libkmod_cc_default="gcc -Wall -Wextra -Wno-unused-parameter \
-std=gnu99 -O2 -fPIC -c"
libkmod_ar_default="ar rcs"
dbin_cc_default="gcc -Wall -Wextra -Wno-unused-parameter \
-Wno-format-truncation \
-std=c99 -O2 -c"
dbin_ccld_default="gcc -Wl,--as-needed"
slibkmod_cc_default="gcc -Wall -Wextra -Wno-unused-parameter \
-std=c99 -O2 -fPIC -c"
slibkmod_ccld_default="gcc -shared \
-Wl,--version-script=$src_path/libkmod.sym \
-Wl,-soname,libkmod.so.$libkmod_api \
-Wl,--as-needed"
#-------------------------------------------------------------------------------
prefix_default=/usr/local
bindir_default='$prefix/bin'
libdir_default='$prefix/lib'
includedir_default='$prefix/include'
sysconfdir_default='$prefix/etc'
version_default=24
set_default $CMDLINE_SET
libkmod_only=no
disable_static=no
disable_dynamic=no
################################################################################
################################################################################
show_help(){
cat <<EOF
Usage: make [options]
default to build libkmod and kmod
Options: [defaults in brackets after descriptions]
Help options:
--help print this message
Standard options:
--libkmod-only build only libkmod
--disable-static disable the build of static lib and static binary
--disable-dynamic disable the build of shared lib and dynamic binary
--prefix=PREFIX architecture independent prefix [$prefix_default]
--eprefix=EPREFIX architecture dependent exec prefix [$eprefix_default]
--libdir=DIR object code libraries [$libdir_default]
--includedir=DIR C header files [$includedir_default]
--sysconfdir=DIR read-only single-machine data [$sysconfdir_default]
--version=VERSION override the version number [$version_default]
Advanced options:
--bin-cc=CC use C compiler command line CC for static target kmod [$(spaces_concat "$bin_cc_default")]
--bin-ccld=CCLD use linker command line CCLD for static target kmod [$(spaces_concat "$bin_ccld_default")]
--dbin-cc=CC use C compiler command line CC for dynamic target kmod [$(spaces_concat "$dbin_cc_default")]
--dbin-ccld=CCLD use linker command line CCLD for dynamic target kmod [$(spaces_concat "$dbin_ccld_default")]
--libkmod-cc=CC use C compiler command line CC for static target libkmod [$(spaces_concat "$libkmod_cc_default")]
--libkmod-ar=AR use archive command line AR for static target libkmod [$(spaces_concat "$libkmod_ar_default")]
--slibkmod-cc=CC use C compiler command line CC for shared target libkmod [$(spaces_concat "$slibkmod_cc_default")]
--slibkmod-ccld=CCLD use linker command line CCLD for shared target libkmod [$(spaces_concat "$slibkmod_ccld_default")]
EOF
exit 0
}
################################################################################
for opt do
optval="${opt#*=}"
case "$opt" in
--help|-h) show_help
;;
--libkmod-only)
libkmod_only=yes
;;
--disable-static)
disable_static=yes
;;
--disable-dynamic)
disable_dynamic=yes
;;
*)
optname=${opt%%=*}
optname=${optname#--}
optname=$(echo "$optname" | sed 's/-/_/g')
if is_in $optname $CMDLINE_SET; then
eval $optname='$optval'
else
die_unknown $opt
fi
;;
esac
done
################################################################################
sep_start;echo "source path is $src_path";sep_end
path_expand()
{
e_v=$1
#we set a maximum expansion depth of 3
for d in 1 2 3
do
e_v=$(eval echo "$e_v")
done
#get rid of ugly double // in path
echo "$e_v" | sed -e 's%//%/%g'
}
sep_start;echo 'expanding final paths:'
e_prefix=$(path_expand "$prefix")
e_bindir=$(path_expand "$bindir")
e_libdir=$(path_expand "$libdir")
e_includedir=$(path_expand "$includedir")
e_sysconfdir=$(path_expand "$sysconfdir")
echo "prefix=$e_prefix"
echo "bin=$e_bindir"
echo "libdir=$e_libdir"
echo "includedir=$e_includedir"
echo "sysconfdir=$e_sysconfdir"
sep_end
################################################################################
mkdir -p -- ./src
printf "#ifndef LIBKMOD_PATHS_H\n#define LIBKMOD_PATHS_H\n#define SYSCONFDIR \"%b\"\n#endif" "$e_sysconfdir" >./src/libkmod-paths.h
################################################################################
. $src_path/make.libkmod.sh
if test x$libkmod_only != xyes; then
. $src_path/make.kmod.sh
fi
################################################################################
sep_start;echo 'generating pkg-config file for libkmod'
mkdir -p -- $fake_root$e_libdir/pkgconfig
cp -f $src_path/libkmod.pc.in $fake_root$e_libdir/pkgconfig/libkmod.pc
sed -i "s%@VERSION@%$version%" $fake_root$e_libdir/pkgconfig/libkmod.pc
sed -i "s%@libdir@%$e_libdir%" $fake_root$e_libdir/pkgconfig/libkmod.pc
sed -i "s%@includedir@%$e_includedir%" $fake_root$e_libdir/pkgconfig/libkmod.pc
sep_end
Mode |
Type |
Size |
Ref |
File |
100644 |
blob |
24 |
e6022749c4477acab27a7400e6da12dbf9ca459e |
LICENSE |
100644 |
blob |
497 |
67770db1400780a648447bc57fbbb585351597b1 |
README |
100644 |
blob |
160 |
9e3228ba612b2bfdadcc397d05a51fa6d5338da3 |
libkmod.pc.in |
100644 |
blob |
2138 |
95f1c1f9a17b129ffe7010c8b15537be25207678 |
libkmod.sym |
100755 |
blob |
7996 |
eb22eec387e1df3844f99f9a204f0bc218f3b176 |
make |
100644 |
blob |
2199 |
44e692a6b2129875a7d54258d454e572f44a64af |
make.kmod.sh |
100644 |
blob |
2612 |
18374ad1ba5d1534433748e11c6e6d9584d8e589 |
make.libkmod.sh |
040000 |
tree |
- |
3738113a9daf07542e063dab30bbcc4b885d758b |
src |
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"
Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/sylware/nyankmod
Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/sylware/nyankmod
Clone this repository using git:
git clone git://git.rocketgit.com/user/sylware/nyankmod
You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a
merge request:
... clone the repository ...
... make some changes and some commits ...
git push origin main