(file) Return to MakeMakefile.sh CVS log (file) (dir) Up to [OMI] / omi / mak

  1 mike  1.1 #!/bin/bash
  2           
  3           ##==============================================================================
  4           ##
  5           ## Check arguments
  6           ##
  7           ##==============================================================================
  8           
  9           if [ "$#" = "0" ]; then
 10               echo "Usage: $0 (lib|cshlib|cxxshlib|cprog|cxxprog) [OPTIONS]"
 11               echo "Try --help for help."
 12               exit 1
 13           fi
 14           
 15           case $1 in
 16               -*)
 17                   ;;
 18               *)
 19                   TYPE=$1
 20                   shift 1
 21           esac
 22 mike  1.1 
 23           ##==============================================================================
 24           ##
 25           ## Get command line arguments.
 26           ##
 27           ##==============================================================================
 28           
 29           for opt
 30           do
 31           
 32             arg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
 33           
 34             case $opt in
 35           
 36               -h | --help)
 37                 HELP=1
 38                 ;;
 39           
 40               --top=*)
 41                 TOP=$arg 
 42                 ;;
 43 mike  1.1 
 44               --project=*)
 45                 PROJECT=$arg 
 46                 ;;
 47           
 48               --sources=*)
 49                 SOURCES=$arg 
 50                 ;;
 51           
 52               --defines=*)
 53                 DEFINES=$arg 
 54                 ;;
 55           
 56               --includes=*)
 57                 INCLUDES=$arg 
 58                 ;;
 59           
 60               --libraries=*)
 61                 LIBRARIES=$arg 
 62                 ;;
 63           
 64 mike  1.1     *)
 65                 echo "$0: unknown option:  $opt"
 66                 exit 1
 67                 ;;
 68           
 69             esac
 70           done
 71           
 72           ##==============================================================================
 73           ##
 74           ## Print the help message
 75           ##
 76           ##==============================================================================
 77           
 78           if [ "$HELP" = "1" ]; then
 79           
 80           cat<<EOF
 81           
 82           Usage: $0 (lib|cshlib|cxxshlib|cprog|cxxprog) [OPTIONS]
 83           
 84           OVERVIEW:
 85 mike  1.1     This script generates a makefile (called 'GNUmakefile').
 86           
 87           OPTIONS:
 88               -h, --help  Print this help message.
 89               --top       Relative directory that contains 'configure' script.
 90               --project   Name of project (defaults to current directory name).
 91               --sources   List of source files (defaults to *.c and *.cpp).
 92               --headers   List of headers files (defaults to *.h).
 93               --defines   List macros definitions.
 94               --includes  List of include paths (relative to current directory).
 95               --libraries List of dependent library names.
 96           
 97           EOF
 98           
 99           exit 0
100           
101           fi
102           
103           ##==============================================================================
104           ##
105           ## $TYPE
106 mike  1.1 ##
107           ##==============================================================================
108           
109           case $TYPE in
110               lib)
111                 TYPE=LIBRARY
112                 ;;
113               cshlib)
114                 TYPE=CSHLIBRARY
115                 ;;
116               cxxshlib)
117                 TYPE=CXXSHLIBRARY
118                 ;;
119               cprog)
120                 TYPE=CPROGRAM
121                 ;;
122               cxxprog)
123                 TYPE=CXXPROGRAM
124                 ;;
125               *)
126                 echo "$0: unknown or missing type argument: '$TYPE'"
127 mike  1.1       echo ""
128                 exit 1
129                 ;;
130           esac
131           
132           ##==============================================================================
133           ##
134           ## $TOP
135           ##
136           ##==============================================================================
137           
138           if [ "$TOP" == "" ]; then
139               if [ -f "../configure" ]; then
140                   TOP=..
141               fi
142               if [ -f "../../configure" ]; then
143                   TOP=../..
144               fi
145               if [ -f "../../../configure" ]; then
146                   TOP=../../..
147               fi
148 mike  1.1     if [ -f "../../../../configure" ]; then
149                   TOP=../../../..
150               fi
151               if [ -f "../../../../../configure" ]; then
152                   TOP=../../../../..
153               fi
154               if [ -f "../../../../../../configure" ]; then
155                   TOP=../../../../../..
156               fi
157               if [ -f "../../../../../../../configure" ]; then
158                   TOP=../../../../../../..
159               fi
160           
161               if [ "$TOP" == "" ]; then
162                   echo "$0: unable to find top (please use --top option)"
163                   exit 1
164               fi
165           fi
166           
167           ##==============================================================================
168           ##
169 mike  1.1 ## $PROJECT
170           ##
171           ##==============================================================================
172           
173           if [ "$PROJECT" = "" ]; then
174               TMP=`pwd`
175               PROJECT=`basename $TMP`
176           fi
177           
178           ##==============================================================================
179           ##
180           ## $SOURCES
181           ##
182           ##==============================================================================
183           
184           if [ "$SOURCES" = "" ]; then
185               SOURCES="`ls *.c 2> /dev/null``ls *.cpp 2> /dev/null`"
186           fi
187           
188           ##==============================================================================
189           ##
190 mike  1.1 ## Write 'GNUmakefile'
191           ##
192           ##==============================================================================
193           
194           cat > GNUmakefile <<END
195           TOP = $TOP
196           include \$(TOP)/config.mak
197           
198           $TYPE = $PROJECT
199           
200           SOURCES = $SOURCES
201           
202           DEFINES = $DEFINES
203           
204           INCLUDES = \$(TOP) \$(TOP)/common $INCLUDES
205           
206           LIBRARIES = $LIBRARIES
207           
208           include \$(TOP)/mak/rules.mak
209           END
210           
211 mike  1.1 echo "Created GNUmakefile"

ViewCVS 0.9.2