blob: e4997c4c53e37309bbed97cd8e3faaa32f6563f6 [file] [log] [blame]
Lucas De Marchi15cfa1d2014-12-25 23:12:22 -02001#!/bin/sh
Lucas De Marchi6ee28132017-02-23 21:58:15 -08002
Lucas De Marchi15cfa1d2014-12-25 23:12:22 -02003set -e
Lucas De Marchiecd40ee2011-11-21 12:35:15 -02004
Lucas De Marchi6ee28132017-02-23 21:58:15 -08005oldpwd=$(pwd)
6topdir=$(dirname $0)
7cd $topdir
8
Lucas De Marchi4fb900c2012-01-10 12:55:13 -02009gtkdocize --docdir libkmod/docs || touch libkmod/docs/gtk-doc.make
Lucas De Marchi6ee28132017-02-23 21:58:15 -080010autoreconf --force --install --symlink
Lucas De Marchiecd40ee2011-11-21 12:35:15 -020011
Lucas De Marchiecd40ee2011-11-21 12:35:15 -020012libdir() {
Lucas De Marchi6ee28132017-02-23 21:58:15 -080013 echo $(cd "$1/$(gcc -print-multi-os-directory)"; pwd)
Lucas De Marchiecd40ee2011-11-21 12:35:15 -020014}
15
Lucas De Marchi6ee28132017-02-23 21:58:15 -080016args="\
17--prefix=/usr \
Lucas De Marchiecd40ee2011-11-21 12:35:15 -020018--sysconfdir=/etc \
Lucas De Marchi6ee28132017-02-23 21:58:15 -080019--libdir=$(libdir /usr/lib) \
20"
21
22if [ -f "$topdir/.config.args" ]; then
23 args="$args $(cat $topdir/.config.args)"
24fi
25
26if [ ! -L /bin ]; then
27 args="$args \
28 --with-rootprefix= \
29 --with-rootlibdir=$(libdir /lib) \
30 "
31fi
32
33cd $oldpwd
Lucas De Marchiecd40ee2011-11-21 12:35:15 -020034
Torge Matthies3821e192020-09-08 21:59:20 +020035hackargs="\
36--enable-debug \
37--enable-python \
38--with-zstd \
39--with-xz \
40--with-zlib \
41--with-openssl \
42"
Lucas De Marchiae2612e2012-01-09 13:26:06 -020043
Lucas De Marchi6ee28132017-02-23 21:58:15 -080044if [ "x$1" = "xc" ]; then
Lucas De Marchi028d4df2018-12-17 09:52:05 -080045 shift
46 $topdir/configure CFLAGS='-g -O2' $args $hackargs "$@"
Lucas De Marchi6ee28132017-02-23 21:58:15 -080047 make clean
48elif [ "x$1" = "xg" ]; then
Lucas De Marchi028d4df2018-12-17 09:52:05 -080049 shift
50 $topdir/configure CFLAGS='-g -Og' $args "$@"
Lucas De Marchi6ee28132017-02-23 21:58:15 -080051 make clean
52elif [ "x$1" = "xl" ]; then
Lucas De Marchi028d4df2018-12-17 09:52:05 -080053 shift
54 $topdir/configure CC=clang CXX=clang++ $args "$@"
Lucas De Marchi6ee28132017-02-23 21:58:15 -080055 make clean
56elif [ "x$1" = "xa" ]; then
Lucas De Marchi028d4df2018-12-17 09:52:05 -080057 shift
58 $topdir/configure CFLAGS='-g -O2 -Wsuggest-attribute=pure -Wsuggest-attribute=const' $args "$@"
Lucas De Marchi6ee28132017-02-23 21:58:15 -080059 make clean
60elif [ "x$1" = "xs" ]; then
Lucas De Marchi028d4df2018-12-17 09:52:05 -080061 shift
62 scan-build $topdir/configure CFLAGS='-g -O0 -std=gnu11' $args "$@"
Lucas De Marchi6ee28132017-02-23 21:58:15 -080063 scan-build make
64else
65 echo
66 echo "----------------------------------------------------------------"
67 echo "Initialized build system. For a common configuration please run:"
68 echo "----------------------------------------------------------------"
69 echo
70 echo "$topdir/configure CFLAGS='-g -O2' $args"
71 echo
72 echo If you are debugging or hacking on kmod, consider configuring
73 echo like below:
Lucas De Marchi028d4df2018-12-17 09:52:05 -080074 echo
Jakov Simunic49977842018-05-16 10:24:37 -070075 echo "$topdir/configure CFLAGS='-g -O2' $args $hackargs"
Lucas De Marchi6ee28132017-02-23 21:58:15 -080076fi