blob: c980f24a2d194fc144cd6e379b970b46a91d2a6a [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 Marchi6ca7c092014-04-06 17:14:23 -030035hackargs="--enable-debug --enable-python --with-xz --with-zlib"
Lucas De Marchiae2612e2012-01-09 13:26:06 -020036
Lucas De Marchi6ee28132017-02-23 21:58:15 -080037if [ "x$1" = "xc" ]; then
38 $topdir/configure CFLAGS='-g -O2' $args
39 make clean
40elif [ "x$1" = "xg" ]; then
41 $topdir/configure CFLAGS='-g -Og' $args
42 make clean
43elif [ "x$1" = "xl" ]; then
44 $topdir/configure CC=clang CXX=clang++ $args
45 make clean
46elif [ "x$1" = "xa" ]; then
47 $topdir/configure CFLAGS='-g -O2 -Wsuggest-attribute=pure -Wsuggest-attribute=const' $args
48 make clean
49elif [ "x$1" = "xs" ]; then
50 scan-build $topdir/configure CFLAGS='-g -O0 -std=gnu11' $args
51 scan-build make
52else
53 echo
54 echo "----------------------------------------------------------------"
55 echo "Initialized build system. For a common configuration please run:"
56 echo "----------------------------------------------------------------"
57 echo
58 echo "$topdir/configure CFLAGS='-g -O2' $args"
59 echo
60 echo If you are debugging or hacking on kmod, consider configuring
61 echo like below:
62 echo
63 echo "$topdir/configure CFLAGS="-g -O2" $args $hackargs"
64fi