initial checkin of c-implementaion of door_damon
[svn42.git] / door_daemon / configure
1 #!/bin/sh
2 #
3 #
4 #  door_daemon
5 #
6 #  Copyright (C) 2009 Christian Pointner <equinox@spreadspace.org>
7 #
8 #  This file is part of door_daemon.
9 #
10 #  door_daemon is free software: you can redistribute it and/or modify
11 #  it under the terms of the GNU General Public License version 3 as
12 #  published by the Free Software Foundation.
13 #
14 #  door_daemon is distributed in the hope that it will be useful,
15 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
16 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 #  GNU General Public License for more details.
18 #
19 #  You should have received a copy of the GNU General Public License
20 #  along with door_daemon. If not, see <http://www.gnu.org/licenses/>.
21 #
22
23 TARGET=`uname -s`
24
25 CFLAGS='-g -O2'
26 LDFLAGS='-g -Wall -O2'
27
28 PREFIX='/usr/local'
29 USERNAME='uanytun'
30 USERHOME='/var/run/uanytun'
31
32 print_usage() {
33   echo "configure --help                    print this"
34   echo "          --target=<TARGET>         build target i.e. Linux (default: autodetect)"
35   echo "          --prefix=<PREFIX>         the installation prefix (default: /usr/local)"
36   echo "          --username=<USERNAME>     create this user when installing (default: uanytun)"
37   echo "          --userhome=<PATH>         the home directory of the user to be created  (default: /var/run/uanytun)"
38 }
39
40 for arg
41 do
42   case $arg in
43   --target=*)
44     TARGET=${arg#--target=}
45   ;;
46   --prefix=*)
47     PREFIX=${arg#--prefix=}
48   ;;
49   --username=*)
50     USERNAME=${arg#--username=}
51   ;;
52   --userhome=*)
53     USERHOME=${arg#--userhome=}
54   ;;
55   --help)
56     print_usage
57     exit 0
58   ;;
59   *)
60     echo "Unknown argument: $arg"
61     print_usage
62     exit 1
63   ;;
64   esac
65 done
66
67 rm -f include.mk
68 case $TARGET in 
69   Linux)
70     echo "Linux specific build options"
71   ;;
72   OpenBSD|FreeBSD|NetBSD)
73     echo "BSD specific build options"
74     CFLAGS=$CFLAGS' -I/usr/local/include'
75     LDFLAGS=$LDFLAGS' -L/usr/local/lib'
76   ;;
77   *)
78     echo "Plattform not supported"
79     exit 1;
80   ;;
81 esac
82
83 if [ "x$PREFIX" = "x/usr" ]; then
84  ETCDIR=/etc
85 else
86  ETCDIR=$PREFIX/etc
87 fi
88
89 cat >> include.mk <<EOF
90 # this file was created automatically
91 # do not edit this file directly 
92 # use ./configure instead
93
94 TARGET := $TARGET
95 CC := gcc
96 CFLAGS := $CFLAGS
97 LDFLAGS := $LDFLAGS
98
99 SBINDIR := $PREFIX/sbin
100 MANDIR := $PREFIX/share/man
101 ETCDIR := $ETCDIR
102 USERNAME := $USERNAME
103 USERHOME := $USERHOME
104 EOF
105
106 exit 0