blob: 67b119f6fc6e092c5d21f87088109ffaca9cdbf9 [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
Lucas De Marchibcab5cd2019-02-04 14:27:29 -080035hackargs="--enable-debug --enable-python --with-xz --with-zlib --with-openssl"
Lucas De Marchiae2612e2012-01-09 13:26:06 -020036
Lucas De Marchi6ee28132017-02-23 21:58:15 -080037if [ "x$1" = "xc" ]; then
Lucas De Marchi028d4df2018-12-17 09:52:05 -080038 shift
39 $topdir/configure CFLAGS='-g -O2' $args $hackargs "$@"
Lucas De Marchi6ee28132017-02-23 21:58:15 -080040 make clean
41elif [ "x$1" = "xg" ]; then
Lucas De Marchi028d4df2018-12-17 09:52:05 -080042 shift
43 $topdir/configure CFLAGS='-g -Og' $args "$@"
Lucas De Marchi6ee28132017-02-23 21:58:15 -080044 make clean
45elif [ "x$1" = "xl" ]; then
Lucas De Marchi028d4df2018-12-17 09:52:05 -080046 shift
47 $topdir/configure CC=clang CXX=clang++ $args "$@"
Lucas De Marchi6ee28132017-02-23 21:58:15 -080048 make clean
49elif [ "x$1" = "xa" ]; then
Lucas De Marchi028d4df2018-12-17 09:52:05 -080050 shift
51 $topdir/configure CFLAGS='-g -O2 -Wsuggest-attribute=pure -Wsuggest-attribute=const' $args "$@"
Lucas De Marchi6ee28132017-02-23 21:58:15 -080052 make clean
53elif [ "x$1" = "xs" ]; then
Lucas De Marchi028d4df2018-12-17 09:52:05 -080054 shift
55 scan-build $topdir/configure CFLAGS='-g -O0 -std=gnu11' $args "$@"
Lucas De Marchi6ee28132017-02-23 21:58:15 -080056 scan-build make
57else
58 echo
59 echo "----------------------------------------------------------------"
60 echo "Initialized build system. For a common configuration please run:"
61 echo "----------------------------------------------------------------"
62 echo
63 echo "$topdir/configure CFLAGS='-g -O2' $args"
64 echo
65 echo If you are debugging or hacking on kmod, consider configuring
66 echo like below:
Lucas De Marchi028d4df2018-12-17 09:52:05 -080067 echo
Jakov Simunic49977842018-05-16 10:24:37 -070068 echo "$topdir/configure CFLAGS='-g -O2' $args $hackargs"
Lucas De Marchi6ee28132017-02-23 21:58:15 -080069fi