Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
*.log
.svn/
*.o
cmakebuild

64 changes: 64 additions & 0 deletions BUILD-HOWTO
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
INTRODUCTION
------------
This file describes what tools you need to build this experimental Pi specific version of motion, and how to perform the build.

The current version of the cmake script does not perform full configuration of the build, nor does it check for dependencies.

Hopefully this document should give you the information you need to get those dependencies; at some time in the future the build script should be made more capable to address this.

REQUIRED TOOLS
--------------
* cmake 2.8.x.
* Either native gcc and build essentials on Pi, or Pi-compatible ARM gcc cross compiler.
* git (to obtain some Pi specific files).

DEPENDENCIES
------------
The following libraries are required - either natively installed on the Pi, or in a Pi root file system copy on a cross-compilation machine.
They should be installable using packages from the Raspbian repositories. Make sure you install the actual package and the "dev" package.
You can use http://www.debian.org/distrib/packages to search for the package names, or use the suggested ones below:

* libjpeg (libjpeg62, libjpeg62-dev)
* libavformat (libavformat53, libavformat-dev)
* libavcodec (libavcodec53, libavcodec-dev)
* libavutil (libavutil51, libavutil-dev)
* libm (libc6-dev)
* libz (zlib1g-dev)
* libmysqlclient (libmysqlclient18, libmysqlclient-dev)
* libpq (libpq5, libpq-dev)

The Pi's VideoCore libraries are also required - these can be acquired (under /opt/vc/lib) by updating a Raspbian install, or from the Pi GitHub firmware repository (https://github.com/raspberrypi/firmware)

The Pi userland source files are also needed - these can be obtained from the Pi GitHub (https://github.com/raspberrypi/userland)

BUILDING ON A PI
----------------
In this package's source directory, run the following:

USERLANDPATH=<path-to-pi-userland-source-files> cmake .
make

For example, assuming that the userland source files have been cloned via git into the default user's home directory:

USERLANDPATH=/home/pi/userland cmake .
make

CROSS-COMPILING
---------------
You'll need an ARM cross compilation toolchain that supports the Pi's ARM architecture - you could get that from the Pi GitHub (https://github.com/raspberrypi/tools) into the local folder /opt/cross/Pi.

You'll also need a copy of /lib, /opt and /usr from the Pi's Raspbian root file system with the above dependencies installed - rsync is good to use for copying these, but may take some time.

Cross-compilation requires some additional environment variables to be provided when cmake is run:

TOOLPREFIX ARM cross-compiler tool name prefixes - e.g. arm-linux-gnueabi-hf-
TOOLPATH Path to cross compiler root - e.g. /opt/cross/Pi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian
ROOTFSPATH Path to copy of Pi root file system on cross compilation system, e.g. /opt/cross/Pi/rootfs

So an example execution might be:

USERLANDPATH=/home/pi/userland TOOLPREFIX=arm-linux-gnueabi-hf- TOOLPATH=/opt/cross/Pi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian ROOTFSPATH=/opt/cross/Pi/rootfs cmake .
make



2,331 changes: 0 additions & 2,331 deletions CHANGELOG

This file was deleted.

158 changes: 158 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
#
# For compilation, the following environment vars should be defined before running cmake:
# USERLANDPATH - path to the root of the Pi userland files (from https://github.com/raspberrypi/userland.git)
#
# For cross-compilation, the following environment vars should be defined before running cmake:
# ROOTFSPATH - path to the root of the Pi file system (for include and library file paths)
# TOOLPATH - path to the root of the cross-compiler (e.g. a path ending in "tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian" for the Linaro toolchain)
# TOOLPREFIX - platform specific prefix for compiler tool names (e.g. arm-linux-gnueabihf-)
#
# Optional environment vars:
# DEBUG - if set to any value, will build debug version (no optimisation, full symbol information).
#

project(motion)
cmake_minimum_required(VERSION 2.8)

#set(TOOLPATH ~/RPi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian)
#set(ROOTFSPATH ~/RPi/rootfs-2013-05)
#set(USERLANDPATH ~/RPi/userland)
#set(TOOLPREFIX arm-linux-gnueabihf-)

set(ROOTFSPATH $ENV{ROOTFSPATH})
set(USERLANDPATH $ENV{USERLANDPATH})

execute_process(COMMAND uname -m OUTPUT_VARIABLE MACHINE)

if(NOT MACHINE MATCHES "arm*")
set(TOOLPATH $ENV{TOOLPATH})
set(TOOLPREFIX $ENV{TOOLPREFIX})
set(CMAKE_C_COMPILER ${TOOLPATH}/bin/${TOOLPREFIX}gcc)
set(CMAKE_ASM_COMPILER ${TOOLPATH}/bin/${TOOLPREFIX}gcc)
set(CMAKE_SYSTEM_NAME Linux)

include_directories(
${TOOLPATH}/arm-linux-gnueabihf/include
${TOOLPATH}/arm-linux-gnueabihf/libc/usr/include/arm-linux-gnueabihf
${TOOLPATH}/arm-linux-gnueabihf/libc/usr/include
${TOOLPATH}/lib/gcc/arm-linux-gnueabihf/4.7.2/include-fixed
${TOOLPATH}/lib/gcc/arm-linux-gnueabihf/4.7.2/include
${TOOLPATH}/lib/gcc/arm-linux-gnueabihf/4.7.2/finclude
${ROOTFSPATH}/usr/include/arm-linux-gnueabihf
${ROOTFSPATH}/usr/include
${ROOTFSPATH}/usr/local/include
)

add_definitions(
-march=armv6zk
-mfpu=vfp
-mfloat-abi=hard
)

link_directories(
${TOOLPATH}/arm-linux-gnueabihf/lib
${TOOLPATH}/arm-linux-gnueabihf/libc/lib
${TOOLPATH}/arm-linux-gnueabihf/libc/lib/arm-linux-gnueabihf
${TOOLPATH}/lib/gcc/arm-linux-gnueabihf/4.7.2
${TOOLPATH}/libexec/gcc/arm-linux-gnueabihf/4.7.2
${ROOTFSPATH}/lib/arm-linux-gnueabihf
${ROOTFSPATH}/lib
${ROOTFSPATH}/usr/lib/arm-linux-gnueabihf
${ROOTFSPATH}/usr/lib
${ROOTFSPATH}/usr/local/lib
)
endif()

enable_language(ASM)

set(CMAKE_INCLUDE_CURRENT_DIR ON)
include_directories(
${ROOTFSPATH}/usr/include/mysql
${ROOTFSPATH}/usr/include/postgresql
${USERLANDPATH}
${USERLANDPATH}/interface/vcos
${USERLANDPATH}/interface/vcos/pthreads
${USERLANDPATH}/interface/vmcs_host/linux
${USERLANDPATH}/interface/vmcs_host
${USERLANDPATH}/host_applications/linux/libs/bcm_host/include
)

add_definitions( -DVERSION="mmaltest"
-Dsysconfdir="/etc"
-D_REENTRANT
-DHAVE_FFMPEG
-DFFMPEG_NEW_INCLUDES
-DHAVE_FFMPEG_NEW
-DMOTION_V4L2
-DMOTION_V4L2_OLD
-DTYPE_32BIT=int
-DHAVE_BSWAP
-Wall
-fmessage-length=0
-std=gnu99
)

if ($ENV{DEBUG})
add_definitions(-O0 -g3 -D_DEBUG)
else()
add_definitions(-O3)
endif()

link_directories(
${ROOTFSPATH}/opt/vc/lib
)

add_executable(motion
alg.c
alg_arm.s
conf.c
draw.c
event.c
ffmpeg.c
filecam.c
jpegutils.c
logger.c
md5.c
mmalcam.c
mmaloutput.c
motion.c
netcam.c
netcam_ftp.c
netcam_jpeg.c
netcam_wget.c
metrics.c
picture.c
rotate.c
stream.c
track.c
utils.c
video2.c
video.c
video_common.c
videosourceplugin.c
vloopback_motion.c
webhttpd.c
raspicam/RaspiCamControl.c
raspicam/RaspiCLI.c
)

target_link_libraries(motion
pthread
m
jpeg
avformat
avcodec
avutil
z
mysqlclient
pq
rt
bcm_host
vcos
vchiq_arm
mmal_core
mmal_util
mmal_vc_client
-Xlinker -rpath-link=${ROOTFSPATH}/usr/lib/arm-linux-gnueabihf -Xlinker -rpath-link=${ROOTFSPATH}/lib/arm-linux-gnueabihf
)

Loading