4 # Copyright 2015-2018 Nest Labs Inc. All Rights Reserved.
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
10 # http://www.apache.org/licenses/LICENSE-2.0
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
21 # This file is a convenience script that will create a skeleton
22 # build layout using the nlbuild-autotools package.
35 # Display program usage.
40 echo "Usage: ${name} [ options ]"
43 echo "Try '${name} -h' for more information."
48 echo " -h, --help Print this help, then exit."
49 echo " -I DIR Specify directory DIR as the root of the "
50 echo " nlbuild-autotools repository."
51 echo " -v, --verbose Verbosely report mkskeleton progress (default: yes)."
52 echo " --package-description DESC Specify description DESC as a the "
53 echo " package description."
54 echo " --package-name NAME Specify name NAME as the package name."
55 echo " --package-version VERSION Specify version VERSION as the initial "
56 echo " version for the package (default: ${VERSION})."
57 echo " --package-year YEAR Specify year YEAR as the creation "
58 echo " year for the package (default: ${YEAR})."
59 echo " -q, --quiet Do not verbosely report mkskeleton progress (default: no)."
71 if [ ! -z ${verbose} ] && [ ${verbose} -eq 1 ]; then
81 -e "s,\@NLBUILD_AUTOTOOLS_STEM\@,${DIR},g" \
82 -e "s,\@PACKAGE_DESCRIPTION\@,${DESCRIPTION},g" \
83 -e "s,\@PACKAGE_SHORT_LOWER\@,${LOWER},g" \
84 -e "s,\@PACKAGE_SHORT_UPPER\@,${UPPER},g" \
85 -e "s,\@PACKAGE_YEAR\@,${YEAR},g" \
93 local directory="${4}"
94 local stem="${file%.*}"
95 local extension="${file##*.}"
99 if [ -r "${nlbuild}/examples/${file}" ]; then
100 from="${nlbuild}/examples/${file}"
102 elif [ -r "${nlbuild}/examples/${stem}-${directory}.${extension}" ]; then
103 from="${nlbuild}/examples/${stem}-${directory}.${extension}"
105 elif [ "${directory}" = "." ] && [ -r "${nlbuild}/examples/${stem}-toplevel.${extension}" ]; then
106 from="${nlbuild}/examples/${stem}-toplevel.${extension}"
109 echo "Cannot find an example file \"${file}\" for directory \"${directory}\"."
114 to="${directory}/${file}"
116 log "Creating \"${to}\"..."
118 transform "${from}" "${to}"
121 chmod ${perm} "${to}"
132 local directory="${4}"
133 local from="${nlbuild}/scripts/${source}"
134 local to="${directory}/${source}"
136 log "Creating \"${to}\"..."
138 ln -sf "${from}" "${to}"
141 # Parse out any command line options
143 while [ ${#} -gt 0 ]; do
144 if [ ${1} == "-h" ] || [ ${1} == "--help" ]; then
147 elif [ ${1} == "-I" ]; then
151 elif [ ${1} == "--package-description" ]; then
155 elif [ ${1} == "--package-name" ]; then
159 UPPER="`echo ${NAME} | tr '[[:lower:]]' '[[:upper:]]'`"
160 LOWER="`echo ${NAME} | tr '[[:upper:]]' '[[:lower:]]'`"
162 elif [ ${1} == "--package-version" ]; then
166 elif [ ${1} == "--package-year" ]; then
170 elif [ ${1} == "-q" ] || [ ${1} == "--quiet" ]; then
174 elif [ ${1} == "-v" ] || [ ${1} == "--verbose" ]; then
184 # Sanity check the command line arguments
186 if [ -z "${DIR}" ]; then
187 echo "$0: No -I option specified. Please provide the location of the nlbuild-autotools directory."
192 if [ -z "${DESCRIPTION}" ]; then
193 echo "$0: Please provide a package description via --package-description."
197 if [ -z "${NAME}" ]; then
198 echo "$0: Please provide a package name via --package-name."
202 if [ -z "${VERSION}" ]; then
203 echo "$0: Please provide a package default version via --package-version."
207 if [ -z "${YEAR}" ]; then
208 echo "$0: Please provide a package creation year via --package-year."
212 # Create the skeleton directories
214 DIRS="doc third_party include src tests"
216 for dir in ${DIRS}; do
217 log "Creating \"${dir}\"..."
221 # Populate the skeleton directories
223 populate "${DIR}" 664 configure.ac .
224 populate "${DIR}" 775 bootstrap .
225 populate "${DIR}" 664 repos.conf .
226 populate "${DIR}" 664 Makefile.am .
227 populate "${DIR}" 664 Makefile-bootstrap .
228 populate "${DIR}" 664 Makefile.am doc
229 populate "${DIR}" 664 Doxyfile.in doc
230 populate "${DIR}" 664 Makefile.am third_party
231 populate "${DIR}" 664 Makefile.am src
232 populate "${DIR}" 664 Makefile.am tests
233 link "${DIR}" 775 bootstrap-configure .
235 # Create the default package version
237 log "Creating default version ${VERSION}..."
239 echo "${VERSION}" > ".default-version"