summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: d3e2a3094bf21fa5c87ab020b5b1af0da3006140 (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
# Maintainer:  Michael Stergianis <michaelstergianis at gmail dot com>
#
# A thanks to Daniel Bermond for some inspiration (code) in the PKGBUILD
pkgname=caffe-cmake-git
pkgver=1.0.r134.g04ab089db
pkgrel=1
epoch=
pkgdesc="A deep learning framework made with expression, speed, and modularity in mind. Uses cmake to build giving great flexibility."
arch=('x86_64')
url="http://caffe.berkeleyvision.org/"
license=('BSD')
depends=(
    # official repositories:
        'boost-libs' 'protobuf' 'google-glog' 'gflags' 'hdf5' 'opencv' 'leveldb'
        'lmdb' 'cuda' 'cudnn' 'python' 'boost' 'cython' 'python-numpy' 'python-scipy'
        'python-matplotlib' 'ipython' 'python-h5py' 'python-networkx' 'python-nose'
        'python-pandas' 'python-dateutil' 'python-protobuf' 'python-gflags'
        'python-yaml' 'python-pillow' 'python-six'
    # AUR:
        # required:
            'blas-openblas'
        # not required:
            # 'nccl'
        #python:
            'python-leveldb' 'python-scikit-image' 'python-pydotplus'
    # NOTE:
    # python-pydotplus (or python-pydot) is required by python executable draw_net.py
    # https://github.com/BVLC/caffe/blob/691febcb83d6a3147be8e9583c77aefaac9945f8/python/caffe/draw.py#L7-L22
)
makedepends=('git' 'gcc' 'doxygen' 'texlive-core' 'cmake')
provides=('caffe')
conflicts=('caffe' 'caffe-cpu' 'caffe-cpu-git' 'caffe-dr-git' 'caffe-mnc-dr-git'
           'caffe2' 'caffe2-git' 'caffe2-cpu' 'caffe2-cpu-git')
source=("${pkgname}"::"git+https://github.com/BVLC/caffe.git"
       "caffe-1.0-opencv4-fix.patch")
md5sums=('SKIP'
         '07001b22dd7f2133af0a4149bbcb96a5')

pkgver() {
    cd "$pkgname"
    
    # git, tags available
    git describe --long --tags | sed 's/\([^-]*-g\)/r\1/;s/-/./g'
}

prepare() {
  cd "$pkgname"

  # give the user options as to how they will install
  # COMMENT if you do not wish to edit the configuration
  $EDITOR CMakeLists.txt

  patch -Np1 -i "${srcdir}/caffe-1.0-opencv4-fix.patch"
}

build() {
  cd "${srcdir}/$pkgname"
  mkdir -p "build"
  cd build
  cmake -DBLAS=open ..
  ## UNCOMMENT if you wish to have a parallelized build. Race conditions may arise.
  # make -j4 all
  make all
}

# uncomment this block if you want to run the checks/tests
#check() {
#    cd "$pkgname"
#    msg2 "Building target 'test'..."
#    make test
#    msg2 "Making target 'runtest'..."
#    make runtest
#}

package() {
  cd "${srcdir}/$pkgname/build"
  make install

  # move python files over
  cd "${srcdir}/$pkgname/build/install"
  mkdir -p usr
  mkdir -p "${pkgdir}/usr/lib/python3.8/site-packages/"

  cd "${srcdir}/$pkgname/build/install/python"
  mv caffe/ "${pkgdir}/usr/lib/python3.8/site-packages/"

  mkdir -p "${pkgdir}/usr/share/Caffe/python/examples/"
  mv *.py "${pkgdir}/usr/share/Caffe/python/examples/"

  # remove python folder
  cd "${srcdir}/$pkgname/build/install"
  /usr/bin/rm -rf python

  # move everything else over
  cd "${srcdir}/$pkgname/build/install"
  mv share/ usr/
  mv bin/ usr/
  mv lib usr/lib
  mv include/ usr/
  cp * -r "${pkgdir}"
}

# vim:set ts=2 sw=2 et: