gdritter repos GRUtils / 6938423
Added mk-cabal scripts Getty Ritter 8 years ago
2 changed file(s) with 106 addition(s) and 0 deletion(s). Collapse all Expand all
1 #!/bin/bash -e
2
3 if [ $# -eq 0 ]; then
4 EXENAME="$(basename $(pwd))"
5 TGT="-"
6 elif [ $# -eq 1 ]; then
7 EXENAME="$1"
8 TGT='-'
9 elif [ $# -eq 2 ]; then
10 EXENAME="$1"
11 TGT="$2"
12 else
13 echo "USAGE: $0 [library name]" >&2
14 exit 99
15 fi
16
17 NAME=$(git config user.name)
18 EMAIL=$(git config user.email)
19 USER="${NAME} <${EMAIL}>"
20 YEAR=$(date '+%Y')
21
22 if [ "${CATEGORY}x" = "x" ]; then
23 CAT_LINE="-- category:"
24 else
25 CAT_LINE="category: ${CATEGORY}"
26 fi
27
28 function cabal_file {
29 cat <<EOF
30 name: ${EXENAME}
31 version: 0.1.0.0
32 -- synopsis:
33 -- description:
34 license: BSD3
35 license-file: LICENSE
36 author: ${USER}
37 maintainer: ${USER}
38 copyright: ©${YEAR} ${NAME}
39 ${CAT_LINE}
40 build-type: Simple
41 cabal-version: >= 1.12
42
43 executable ${EXENAME}
44 hs-source-dirs: src
45 main-is: Main.hs
46 default-extensions: OverloadedStrings,
47 ScopedTypeVariables
48 ghc-options: -Wall
49 build-depends: base >=4.7 && <4.9
50 default-language: Haskell2010
51 EOF
52 }
53
54 if [ "x${TGT}" = "x-" ]; then
55 cabal_file
56 else
57 cabal_file >${TGT}
58 fi
1 #!/bin/bash -e
2
3 if [ $# -lt 1 ]; then
4 echo "USAGE: $0 [library name]" >&2
5 exit 99
6 elif [ $# -eq 1 ]; then
7 LIBNAME="$1"
8 TGT='-'
9 elif [ $# -eq 2 ]; then
10 LIBNAME="$1"
11 TGT="$2"
12 fi
13
14 NAME=$(git config user.name)
15 EMAIL=$(git config user.email)
16 USER="${NAME} <${EMAIL}>"
17 YEAR=$(date '+%Y')
18
19 function cabal_file {
20 cat <<EOF
21 name: ${LIBNAME}
22 version: 0.1.0.0
23 -- synopsis:
24 -- description:
25 license: BSD3
26 license-file: LICENSE
27 author: ${USER}
28 maintainer: ${USER}
29 copyright: ©${YEAR} ${NAME}
30 -- category:
31 build-type: Simple
32 cabal-version: >= 1.12
33
34 library
35 -- exposed-modules:
36 ghc-options: -Wall
37 build-depends: base >=4.7 && <4.9
38 default-language: Haskell2010
39 default-extensions: OverloadedStrings,
40 ScopedTypeVariables
41 EOF
42 }
43
44 if [ "x${TGT}" = "x-" ]; then
45 cabal_file
46 else
47 cabal_file >${TGT}
48 fi