summaryrefslogtreecommitdiffstats
path: root/kapptemplate/kapptemplate.in
blob: dde86d0497307c70cbd0d2cf17b2bd792bce756a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
###########################################################################
#
# Function: LoadDefaults
#
# This will load in all the default values stored in the user's
# .kapptemplaterc file
#
# INPUT : $KAPPTEMPLATEVERSION, $INSTALLED_SHARE_DIR
# OUTPUT: $ECHO, $KAPPTEMPLATERC, $DEFAULT_AUTHOR, $DEFAULT_EMAIL,
#         $DEFAULT_ROOT, $SHARE_DIR, $BIN_DIR, $MKDIR, $BASENAME
#
###########################################################################
function LoadDefaults
{
    # horrid hack to try and figure out what shell we are using
    # basically, if we can find /usr/ucb/echo, then we are almost for sure
    # NOT on a Linux system and probably 'echo "\c" works.  if we don't
    # find it, we'll assume that the shell is really bash.
    if [ -f "/usr/ucb/echo" ];
    then
        ECHO="echo";
    else
        ECHO="echo -e";
    fi

    # If $MAKE hasn't been set yet, try to figure out how we reach GNU make
    # ourselves.
    if [ ! "$MAKE" ];
    then
        if [ -f "/usr/bin/gmake" ] || [ -f "/usr/local/bin/gmake" ];
        then    
            MAKE="gmake";
        else
            MAKE="make";
        fi
    fi

    $ECHO "KAppTemplate v${KAPPTEMPLATEVERSION} (C) 2003 Kurt Granroth <[email protected]>";
    $ECHO;

    if [ ! "$KAPPTEMPLATERC" ];
    then
        KAPPTEMPLATERC=$HOME/.kapptemplaterc
    fi

    if [ -f $KAPPTEMPLATERC ];
    then
        . $KAPPTEMPLATERC
    else
        GetInitialDefaults
    fi

    if [ ! "$DEFAULT_AUTHOR" ];
    then
        DEFAULT_AUTHOR="Your Name";
    fi

    if [ ! "$DEFAULT_EMAIL" ];
    then
        DEFAULT_EMAIL="`whoami`@$HOST";
    fi

    if [ ! "$DEFAULT_ROOT" ];
    then
        DEFAULT_ROOT="$HOME/src";
    fi

    SHARE_DIR=$INSTALLED_SHARE_DIR;
    INCLUDE_DIR="$SHARE_DIR/include";

    if [ -f "$SHARE_DIR/bin/mkinstalldirs" ];
    then
        MKDIR=$SHARE_DIR/bin/mkinstalldirs
    else
        MKDIR=mkdir
    fi

    # Finally, get the name of the running program
    BASENAME=`echo $0 | sed 's@^.*/@@g'`;
}

# We start by loading the 'common' file containing all useful
# functions
if [ -f $INSTALLED_SHARE_DIR/include/kapptemplate.common ];
then
    . $INSTALLED_SHARE_DIR/include/kapptemplate.common
else
    $ECHO "Could not find common file 'kapptemplate.common'";
    $ECHO;
    exit 1;
fi

# Then, we load all the default environment variables and perform
# any necessary initialization
LoadDefaults

# Parse the command line
CMDLINE=$@;
ParseCommandLine

# Do a sanity check and build the various module lists
BuildModuleLists

if [ ! "$WHICH_ONE" ] && [ "$ALL_DEFAULTS" ];
then
    WHICH_ONE=1;
fi
if [ ! "$WHICH_ONE" ];
then
    # Find out how to use kapptemplate this time
    $ECHO "Please select the type of framework you wish to generate";
    $ECHO "1. Full featured KDE application [default]";
    $ECHO "2. Full featured KPart application";
    $ECHO "3. KPart plugin";
    $ECHO "4. Convert existing source to automake/autoconf framework";
    $ECHO "Choose [1-4]: \c";
    read WHICH_ONE;
    $ECHO;
fi;

# Start the proper module
case $WHICH_ONE in
    2)
        . $INCLUDE_DIR/kpartapp.module;;
    3)
        . $INCLUDE_DIR/kpartplugin.module;;
    4)
        . $INCLUDE_DIR/existing.module;;
    *)
        . $INCLUDE_DIR/kapptemplate.module;;
esac