source: trunk/CMakeLists.txt@ 1182

Last change on this file since 1182 was 1182, checked in by dingo35, 12 years ago

Move Coolstream Reset and Getstatus to ifd_cool.c

File size: 13.3 KB
Line 
1project (OSCam C)
2
3#----------------------- minimum version of cmake to use ------------
4
5# if you want to switch to 2.6 min, please look at the escaped definitions
6# later in this file (the add_definitions in 2.6 don't need to be escaped),
7# and remove the CMP0005 policy.
8# the CMP0003 could also be removed for cmake 2.6
9cmake_minimum_required (VERSION 2.4)
10if(COMMAND cmake_policy)
11 cmake_policy(SET CMP0005 OLD)
12 cmake_policy(SET CMP0003 NEW)
13endif(COMMAND cmake_policy)
14
15#----------------------- detect system ------------------------------
16
17if (CMAKE_CROSSCOMPILING)
18 if (OSCAM_SYSTEM_NAME MATCHES "Tuxbox")
19 set (OSCamOperatingSystem "Tuxbox")
20 set (CS_OS_HW "tuxbox")
21 set (CS_OS_SYS "linux")
22 elseif (OSCAM_SYSTEM_NAME MATCHES "Coolstream")
23 set (OSCamOperatingSystem "NeutrinoHD")
24 set (CS_OS_HW "coolstream")
25 set (CS_OS_SYS "linux")
26 elseif (OSCAM_SYSTEM_NAME MATCHES "NSLU2")
27 set (OSCamOperatingSystem "SlugOS")
28 set (CS_OS_HW "nslu2")
29 set (CS_OS_SYS "linux")
30 elseif (OSCAM_SYSTEM_NAME MATCHES "Fonera2")
31 set (OSCamOperatingSystem "Fonera2")
32 set (CS_OS_HW "fonera2")
33 set (CS_OS_SYS "linux")
34 elseif (OSCAM_SYSTEM_NAME MATCHES "WRT54G")
35 set (OSCamOperatingSystem "WRT54G")
36 set (CS_OS_HW "wrt54g")
37 set (CS_OS_SYS "linux")
38 elseif (OSCAM_SYSTEM_NAME MATCHES "Amino")
39 set (OSCamOperatingSystem "Amino")
40 set (CS_OS_HW "amino")
41 set (CS_OS_SYS "linux")
42 else (OSCAM_SYSTEM_NAME MATCHES "Tuxbox")
43 message (STATUS "Unknown cross system name: <${CMAKE_SYSTEM_NAME}>")
44 set (OSCamOperatingSystem "Unknown")
45 set (CS_OS_HW "unknown")
46 set (CS_OS_SYS "unknown")
47 endif (OSCAM_SYSTEM_NAME MATCHES "Tuxbox")
48else (CMAKE_CROSSCOMPILING)
49 if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
50 set (OSCamOperatingSystem "Linux")
51 set (CS_OS_HW "pc")
52 set (CS_OS_SYS "linux")
53 elseif (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
54 set (OSCamOperatingSystem "Mac OS X")
55 set (CS_OS_HW "mac")
56 set (CS_OS_SYS "macosx")
57 elseif (${CYGWIN})
58 set (OSCamOperatingSystem "Windows/Cygwin")
59 set (CS_OS_HW "pc")
60 set (CS_OS_SYS "cygwin")
61 set (CMAKE_SYSTEM_PROCESSOR "i386")
62 else (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
63 message (STATUS "Unknown system name: <${CMAKE_SYSTEM_NAME}>")
64 set (OSCamOperatingSystem "Unknown")
65 set (CS_OS_HW "unknown")
66 set (CS_OS_SYS "unknown")
67 endif (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
68endif (CMAKE_CROSSCOMPILING)
69
70#----------------------- some paths ------------------------------
71
72set (OPTIONAL_LINK_DIR "" CACHE STRING "Some optional link directories")
73set (OPTIONAL_INCLUDE_DIR "" CACHE STRING "Some optional include directories")
74
75include_directories (
76 ${CMAKE_CURRENT_SOURCE_DIR}/csctapi
77 ${CMAKE_CURRENT_SOURCE_DIR}/cscrypt
78 ${OPTIONAL_INCLUDE_DIR}
79 )
80link_directories (${OPTIONAL_LINK_DIR})
81
82#----------------------- global options ------------------------------
83
84if (OSCamOperatingSystem MATCHES "Linux")
85 add_definitions ("-DOS_LINUX")
86 set (DEFAULT_CS_CONFDIR "/usr/local/etc")
87elseif (OSCamOperatingSystem MATCHES "Mac OS X")
88 add_definitions ("-DOS_MACOSX -DHAVE_PCSC -DNEED_DAEMON -DCS_NOSHM -DHAVE_PTHREAD_H -DUSE_PTHREAD")
89 set (DEFAULT_CS_CONFDIR "/usr/local/etc")
90elseif (OSCamOperatingSystem MATCHES "Tuxbox")
91 add_definitions ("-DOS_LINUX -DTUXBOX -DPPC")
92 set (DEFAULT_CS_CONFDIR "/var/tuxbox/config")
93elseif (OSCamOperatingSystem MATCHES "NeutrinoHD")
94 add_definitions ("-DOS_LINUX -DTUXBOX -DCOOL")
95 set (DEFAULT_CS_CONFDIR "/var/tuxbox/config")
96elseif (OSCamOperatingSystem MATCHES "SlugOS")
97 add_definitions ("-DOS_LINUX")
98 set (DEFAULT_CS_CONFDIR "/var/etc")
99elseif (OSCamOperatingSystem MATCHES "Fonera2")
100 add_definitions ("-DOS_LINUX -DMIPSEL -DUCLIBC")
101 set (DEFAULT_CS_CONFDIR "/var/etc")
102elseif (OSCamOperatingSystem MATCHES "WRT54G")
103 add_definitions ("-DOS_LINUX -DMIPSEL -DUCLIBC -DUSE_GPIO")
104 set (DEFAULT_CS_CONFDIR "/jffs/etc/config/oscam")
105elseif (OSCamOperatingSystem MATCHES "Amino")
106 add_definitions ("-DOS_LINUX")
107 set (DEFAULT_CS_CONFDIR "/usr/local/etc")
108elseif (OSCamOperatingSystem MATCHES "Windows/Cygwin")
109 add_definitions ("-DOS_CYGWIN32 -static")
110 set (DEFAULT_CS_CONFDIR ".")
111endif (OSCamOperatingSystem MATCHES "Linux")
112
113set (CS_CONFDIR ${DEFAULT_CS_CONFDIR} CACHE STRING "Default path for the config files")
114add_definitions ("-DCS_CONFDIR=\\\"${CS_CONFDIR}\\\"")
115
116set (CS_OS_CPU ${CMAKE_SYSTEM_PROCESSOR})
117set (CS_OSTYPE ${CS_OS_CPU}-${CS_OS_HW}-${CS_OS_SYS})
118
119add_definitions ("-DUSE_CMAKE")
120add_definitions ("-DCS_OSTYPE=\\\"${CS_OSTYPE}\\\"")
121add_definitions ("-DCS_OS_CPU=\\\"${CS_OS_CPU}\\\"")
122add_definitions ("-DCS_OS_HW=\\\"${CS_OS_HW}\\\"")
123add_definitions ("-DCS_OS_SYS=\\\"${CS_OS_SYS}\\\"")
124
125#----------------------- subdirectories ------------------------------
126
127include (CheckIncludeFile)
128check_include_file ("openssl/aes.h" HAVE_AES)
129if (HAVE_AES)
130 add_definitions ("-DHAVE_AES")
131endif (HAVE_AES)
132
133check_include_file ("openssl/sha.h" HAVE_SHA)
134if (HAVE_SHA)
135 add_definitions ("-DHAVE_SHA")
136endif (HAVE_SHA)
137
138check_include_file ("PCSC/wintypes.h" HAVE_PCSC)
139if (HAVE_PCSC)
140 add_definitions ("-DHAVE_PCSC")
141if (OSCamOperatingSystem MATCHES "Linux")
142 add_definitions ("-I/usr/include/PCSC")
143endif (OSCamOperatingSystem MATCHES "Linux")
144endif (HAVE_PCSC)
145
146#----------------------- subdirectories ------------------------------
147
148add_subdirectory (csctapi)
149add_subdirectory (cscrypt)
150
151#----------------------- file groups ------------------------------
152
153file (GLOB csmodules_srcs "module-*.c")
154file (GLOB csmodules_hdrs "module-*.h")
155file (GLOB csreaders_srcs "reader-*.c")
156file (GLOB csreaders_hdrs "reader-*.h")
157file (GLOB csoscam_srcs "oscam-*.c")
158file (GLOB csoscam_hdrs "oscam-*.h")
159file (GLOB exe_srcs "oscam.c")
160file (GLOB exe_hdrs "globals.h")
161file (GLOB all_srcs ${csmodules_srcs} ${csreaders_srcs} ${csoscam_srcs} ${exe_srcs})
162
163#----------------------- modules ------------------------------
164
165set (csmodules "csmodules")
166add_library (${csmodules} STATIC ${csmodules_srcs} ${csmodules_hdrs})
167
168#----------------------- readers ------------------------------
169
170set (csreaders "csreaders")
171add_library (${csreaders} STATIC ${csreaders_srcs} ${csreaders_hdrs})
172
173#----------------------- other oscam files ------------------------------
174
175set (csoscam "csoscam")
176add_library (${csoscam} STATIC ${csoscam_srcs} ${csoscam_hdrs})
177
178#----------------------- the executable ------------------------------
179
180set (exe_name "oscam")
181add_executable (${exe_name} ${exe_srcs} ${exe_hdrs})
182target_link_libraries (${exe_name} ${csoscam} ${csmodules} ${csreaders} csctapi cscrypt pthread)
183if (HAVE_AES)
184 target_link_libraries (${exe_name} crypto)
185endif (HAVE_AES)
186if (HAVE_PCSC)
187if (NOT OSCamOperatingSystem MATCHES "Mac OS X")
188 target_link_libraries (${exe_name} pcsclite)
189endif (NOT OSCamOperatingSystem MATCHES "Mac OS X")
190endif (HAVE_PCSC)
191
192add_dependencies (${exe_name} ${csoscam} ${csreaders} ${csmodules})
193
194#----------------------- specific options ------------------------------
195
196if (OSCamOperatingSystem MATCHES "Linux")
197elseif (OSCamOperatingSystem MATCHES "Mac OS X")
198 FIND_LIBRARY (PCSC_LIBRARY PCSC)
199 message (STATUS "OS X system PCSC : ${PCSC_LIBRARY}")
200 target_link_libraries ( ${exe_name} ${PCSC_LIBRARY})
201 set (HAVE_PCSC "1")
202elseif (OSCamOperatingSystem MATCHES "Tuxbox")
203 target_link_libraries ( ${exe_name} dl)
204elseif (OSCamOperatingSystem MATCHES "SlugOS")
205elseif (OSCamOperatingSystem MATCHES "Fonera2")
206elseif (OSCamOperatingSystem MATCHES "WRT54G")
207elseif (OSCamOperatingSystem MATCHES "Amino")
208elseif (OSCamOperatingSystem MATCHES "Windows/cygwin")
209elseif (OSCamOperatingSystem MATCHES "NeutrinoHD")
210 target_link_libraries ( ${exe_name} rt nxp )
211endif (OSCamOperatingSystem MATCHES "Linux")
212
213#----------------------- put svnversion in the build ------------------------------
214# at every target rebuild, we re-build the oscam.c compilation...
215
216# add the needed dependency
217add_dependencies (${exe_name} svnversion)
218add_dependencies (${csoscam} svnversion-log)
219
220# how to re-build the files which printout the version
221add_custom_target (
222 svnversion
223 ALL
224 touch ${CMAKE_CURRENT_SOURCE_DIR}/oscam.c
225)
226add_custom_target (
227 svnversion-log
228 ALL
229 touch ${CMAKE_CURRENT_SOURCE_DIR}/oscam-log.c
230)
231
232#if the svnversion program is absent, this will leave the SVN_REVISION string empty,
233#but won't stop CMake.
234execute_process (COMMAND "svnversion" "-n" "${CMAKE_CURRENT_SOURCE_DIR}" OUTPUT_VARIABLE OSCAM_SVN_REVISION)
235
236if (OSCAM_SVN_REVISION)
237 string (REGEX REPLACE "[0-9]+:" "" OSCAM_SVN_REVISION "${OSCAM_SVN_REVISION}")
238 string (REPLACE "M" "" OSCAM_SVN_REVISION "${OSCAM_SVN_REVISION}")
239 string (REPLACE "exported" "0" OSCAM_SVN_REVISION "${OSCAM_SVN_REVISION}")
240else (OSCAM_SVN_REVISION)
241 set (OSCAM_SVN_REVISION "0")
242endif (OSCAM_SVN_REVISION)
243
244# pass the version to the compilations as a define
245add_definitions ("-D'CS_SVN_VERSION=\"${OSCAM_SVN_REVISION}\"'")
246
247#----------------------- global compile and link options ------------------------------
248
249# some optimisations
250if (OSCamOperatingSystem MATCHES "Mac OS X")
251add_definitions ("-O2 -Winline -Wall -Wextra -finline-functions -fomit-frame-pointer -m32")
252else (OSCamOperatingSystem MATCHES "Mac OS X")
253add_definitions ("-O2 -Winline -Wall -Wextra -finline-functions -fomit-frame-pointer")
254endif (OSCamOperatingSystem MATCHES "Mac OS X")
255
256# we don't want the '-rdynamic' in the link command
257set (CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
258
259# we want to strip
260if (OSCamOperatingSystem MATCHES "Mac OS X")
261set (CMAKE_EXE_LINKER_FLAGS "-s -m32")
262else (OSCamOperatingSystem MATCHES "Mac OS X")
263set (CMAKE_EXE_LINKER_FLAGS "-s")
264endif (OSCamOperatingSystem MATCHES "Mac OS X")
265#----------------------- installation -----------------------------
266
267file (GLOB config_files "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/oscam.*")
268file (GLOB doc_files "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/doc/txt/*.txt")
269file (GLOB man1_files "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/doc/man/*.1")
270file (GLOB man5_files "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/doc/man/*.5")
271file (GLOB example_files "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/doc/example/oscam.ac"
272 "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/doc/example/oscam.cert"
273 "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/doc/example/oscam.conf"
274 "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/doc/example/oscam.guess"
275 "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/doc/example/oscam.ird"
276 "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/doc/example/oscam.server"
277 "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/doc/example/oscam.services"
278 "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/doc/example/oscam.srvid"
279 "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/doc/example/oscam.user")
280file (GLOB monitor_files "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/monitor/mpcs*.sh"
281 "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/monitor/mpcs*.tar")
282
283install (PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${exe_name}${CMAKE_EXECUTABLE_SUFFIX} DESTINATION bin COMPONENT bin)
284install (FILES ${config_files} DESTINATION etc COMPONENT config)
285install (FILES ${doc_files} DESTINATION share/doc/oscam COMPONENT doc)
286install (FILES ${man1_files} DESTINATION share/man/man1 COMPONENT doc)
287install (FILES ${man5_files} DESTINATION share/man/man5 COMPONENT doc)
288install (FILES ${example_files} DESTINATION share/doc/oscam/example COMPONENT doc)
289install (FILES ${monitor_files} DESTINATION share/doc/oscam/monitor COMPONENT doc)
290
291#----------------------- we can use CPack to build pacakges --------------------------
292
293# get version from source file
294execute_process (COMMAND grep CS_VERSION ${CMAKE_CURRENT_SOURCE_DIR}/globals.h
295 OUTPUT_VARIABLE CS_VERSION)
296string (REGEX REPLACE ".*\"\(.*\)\".*" "\\1" CS_VERSION ${CS_VERSION})
297string (REGEX REPLACE "\(.*\)\\..*\\..*" "\\1" CPACK_PACKAGE_VERSION_MAJOR ${CS_VERSION})
298string (REGEX REPLACE ".*\\.\(.*\)\\..*" "\\1" CPACK_PACKAGE_VERSION_MINOR ${CS_VERSION})
299string (REGEX REPLACE ".*\\..*\\.\(.*\)" "\\1" CPACK_PACKAGE_VERSION_PATCH ${CS_VERSION})
300set (CPACK_PACKAGE_VERSION
301 "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
302
303# compute my filename
304set (CPACK_PACKAGE_FILE_NAME
305 "${PROJECT_NAME}-${CPACK_PACKAGE_VERSION}-${CS_OSTYPE}")
306
307# wich archive we want to generate
308set (CPACK_GENERATOR "TGZ")
309
310# what to put in the archive
311set (CPACK_STRIP_FILES TRUE)
312set (CPACK_COMPONENTS_ALL bin)# config doc)
313
314# ok, we can now use CPack
315include (CPack)
316
317#----------------------- printout resume -----------------------------
318
319message (STATUS "")
320message (STATUS " operating system: ${OSCamOperatingSystem}")
321message (STATUS " system type: ${CS_OSTYPE}")
322message (STATUS " system: ${CS_OS_SYS}")
323message (STATUS " cpu: ${CS_OS_CPU}")
324message (STATUS " hw: ${CS_OS_HW}")
325if (HAVE_AES)
326 message (STATUS " use system aes functions")
327else (HAVE_AES)
328 message (STATUS " use built-in aes functions")
329endif (HAVE_AES)
330if (HAVE_SHA)
331 message (STATUS " use system sha functions")
332else (HAVE_SHA)
333 message (STATUS " use built-in sha functions")
334endif (HAVE_SHA)
335if (HAVE_PCSC)
336 message (STATUS " use system pcsc functions")
337endif (HAVE_PCSC)
338message (STATUS "")
Note: See TracBrowser for help on using the repository browser.