libblkid-tiny: add support for UBI superblock
[project/fstools.git] / CMakeLists.txt
1 cmake_minimum_required(VERSION 2.6)
2
3 PROJECT(fs-tools C)
4 ADD_DEFINITIONS(-Os -ggdb -Wall -Werror --std=gnu99 -Wmissing-declarations -Wno-format-truncation)
5
6 SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
7
8 ADD_LIBRARY(fstools SHARED
9                 libfstools/snapshot.c
10                 libfstools/extroot.c
11                 libfstools/overlay.c
12                 libfstools/volume.c
13                 libfstools/mtd.c
14                 libfstools/mount.c
15                 libfstools/ubi.c
16                 libfstools/rootdisk.c
17                 libfstools/find.c)
18 TARGET_LINK_LIBRARIES(fstools ubox)
19 INSTALL(TARGETS fstools LIBRARY DESTINATION lib)
20
21 ADD_LIBRARY(blkid-tiny SHARED
22                 libblkid-tiny/libblkid-tiny.c
23                 libblkid-tiny/mkdev.c
24                 libblkid-tiny/ext.c
25                 libblkid-tiny/jffs2.c
26                 libblkid-tiny/vfat.c
27                 libblkid-tiny/hfs.c
28                 libblkid-tiny/swap.c
29                 libblkid-tiny/ubi.c
30                 libblkid-tiny/ubifs.c
31                 libblkid-tiny/squashfs.c
32                 libblkid-tiny/btrfs.c
33                 libblkid-tiny/f2fs.c
34                 )
35 INSTALL(TARGETS blkid-tiny LIBRARY DESTINATION lib)
36
37 ADD_LIBRARY(ubi-utils STATIC
38                 libubi/libubi.c
39                 libubi/libubi-tiny.c
40                 libubi/ubiutils-common.c)
41 INSTALL(TARGETS ubi-utils ARCHIVE DESTINATION lib)
42
43 FIND_PATH(ubox_include_dir libubox/ulog.h)
44 INCLUDE_DIRECTORIES(${ubox_include_dir})
45
46 SET_TARGET_PROPERTIES(ubi-utils PROPERTIES COMPILE_FLAGS
47                 "-ffunction-sections -fdata-sections")
48
49 INSTALL(FILES libubi/libubi-tiny.h libubi/libubi.h libubi/ubi-media.h
50                 libubi/ubi-user.h libubi/ubi-media.h
51         DESTINATION include
52 )
53
54 ADD_EXECUTABLE(mount_root mount_root.c)
55 TARGET_LINK_LIBRARIES(mount_root fstools)
56 INSTALL(TARGETS mount_root RUNTIME DESTINATION sbin)
57
58 find_library(json NAMES json-c json)
59
60 ADD_EXECUTABLE(blockd blockd.c)
61 TARGET_LINK_LIBRARIES(blockd fstools ubus blobmsg_json ${json})
62 INSTALL(TARGETS blockd RUNTIME DESTINATION sbin)
63
64 ADD_EXECUTABLE(block block.c probe.c probe-libblkid.c)
65 IF(DEFINED CMAKE_UBIFS_EXTROOT)
66         ADD_DEFINITIONS(-DUBIFS_EXTROOT)
67         TARGET_LINK_LIBRARIES(block blkid-tiny dl uci ubox ubus blobmsg_json ubi-utils ${json})
68 ELSE(DEFINED CMAKE_UBIFS_EXTROOT)
69         TARGET_LINK_LIBRARIES(block blkid-tiny dl uci ubox ubus blobmsg_json ${json})
70 ENDIF(DEFINED CMAKE_UBIFS_EXTROOT)
71 INSTALL(TARGETS block RUNTIME DESTINATION sbin)
72
73 ADD_EXECUTABLE(jffs2reset jffs2reset.c)
74 TARGET_LINK_LIBRARIES(jffs2reset fstools)
75 INSTALL(TARGETS jffs2reset RUNTIME DESTINATION sbin)
76
77 ADD_EXECUTABLE(snapshot_tool snapshot.c)
78 TARGET_LINK_LIBRARIES(snapshot_tool fstools)
79 INSTALL(TARGETS snapshot_tool RUNTIME DESTINATION sbin)
80
81 ADD_EXECUTABLE(ubi ubi.c)
82 TARGET_LINK_LIBRARIES(ubi ubi-utils ubox)
83 INSTALL(TARGETS ubi RUNTIME DESTINATION sbin)