summaryrefslogtreecommitdiffstats
path: root/freebsd/dependencies/arts/files/patch-bp000-check-for-libmad.diff
blob: e4411fa43ac07da846e3199446e5cf9ed23f54b5 (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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
commit 874e171aea12ab6d699f7ea99dd23756b00d6458
Author: Slávek Banko <slavek.banko@axis.cz>
Date:   Mon Jul 11 18:16:01 2022 +0200

    Add a check for a pkg-config package named libmad next to mad,
    for detection of library libmad >= 0.16.x (Tenacity's fork).
    
    Split configuration tests into separate files.
    Fill PC_LIB_REQUIRE list during tests.
    
    Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
    (cherry picked from commit 0a2f5a792977b640e4d41f96f0523f416fac7359)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 49f69e9..775d889 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -12,6 +12,16 @@
 cmake_minimum_required( VERSION 3.1 )
 
 
+##### project settings ##########################
+
+project( arts )
+
+set( ARTS_MAJOR_VERSION 1 )
+set( ARTS_MINOR_VERSION 5 )
+set( ARTS_MICRO_VERSION 10 )
+set( ARTS_VERSION "${ARTS_MAJOR_VERSION}.${ARTS_MINOR_VERSION}.${ARTS_MICRO_VERSION}" )
+
+
 ##### include essential cmake modules ###########
 
 include( CheckCXXSourceCompiles )
@@ -28,14 +38,13 @@ set( CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules" )
 include( TDEMacros )
 
 
-##### project settings ##########################
-
-project( arts )
+##### paths setup ###############################
 
-set( ARTS_MAJOR_VERSION 1 )
-set( ARTS_MINOR_VERSION 5 )
-set( ARTS_MICRO_VERSION 10 )
-set( ARTS_VERSION "${ARTS_MAJOR_VERSION}.${ARTS_MINOR_VERSION}.${ARTS_MICRO_VERSION}" )
+tde_setup_install_path( EXEC_INSTALL_PREFIX   "${CMAKE_INSTALL_PREFIX}" )
+tde_setup_install_path( BIN_INSTALL_DIR       "${EXEC_INSTALL_PREFIX}/bin"  )
+tde_setup_install_path( LIB_INSTALL_DIR       "${EXEC_INSTALL_PREFIX}/lib${LIB_SUFFIX}" )
+tde_setup_install_path( INCLUDE_INSTALL_DIR   "${CMAKE_INSTALL_PREFIX}/include/${CMAKE_PROJECT_NAME}" )
+tde_setup_install_path( PKGCONFIG_INSTALL_DIR "${LIB_INSTALL_DIR}/pkgconfig" )
 
 
 ##### user requested options ####################
@@ -51,190 +60,30 @@ option( WITH_SNDIO "Enable SNDIO support" OFF )
 option( WITH_GCC_VISIBILITY "Enable fvisibility and fvisibility-inlines-hidden" ${WITH_ALL_OPTIONS} )
 
 
-##### paths setup ###############################
-
-tde_setup_install_path( EXEC_INSTALL_PREFIX   "${CMAKE_INSTALL_PREFIX}" )
-tde_setup_install_path( BIN_INSTALL_DIR       "${EXEC_INSTALL_PREFIX}/bin"  )
-tde_setup_install_path( LIB_INSTALL_DIR       "${EXEC_INSTALL_PREFIX}/lib${LIB_SUFFIX}" )
-tde_setup_install_path( INCLUDE_INSTALL_DIR   "${CMAKE_INSTALL_PREFIX}/include/${CMAKE_PROJECT_NAME}" )
-tde_setup_install_path( PKGCONFIG_INSTALL_DIR "${LIB_INSTALL_DIR}/pkgconfig" )
-
-
-##### setup architecture flags ##################
-
-tde_setup_architecture_flags( )
-
-include(TestBigEndian)
-test_big_endian(WORDS_BIGENDIAN)
-
-tde_setup_largefiles( )
-
-
-##### check for include files ###################
-
-check_include_file( "sys/time.h" HAVE_SYS_TIME_H )
-check_include_file( "time.h" TIME_WITH_SYS_TIME )
-check_include_file( "stdio.h" HAVE_STDIO_H )
-check_include_file( "stdlib.h" HAVE_STDLIB_H )
-check_include_file( "string.h" HAVE_STRING_H )
-check_include_file( "strings.h" HAVE_STRINGS_H )
-check_include_file( "ctype.h" HAVE_CTYPE_H )
-check_include_file( "malloc.h" HAVE_MALLOC_H )
-check_include_file( "memory.h" HAVE_MEMORY_H )
-check_include_file( "dlfcn.h" HAVE_DLFCN_H )
-check_include_file( "sys/soundcard.h" HAVE_SYS_SOUNDCARD_H )
-check_include_file( "pthread.h" HAVE_LIBPTHREAD )
-
-
-##### check for system libraries ################
-
-set( DL_LIBRARIES dl )
-check_library_exists( ${DL_LIBRARIES} dlopen /lib HAVE_LIBDL )
-if( NOT HAVE_LIBDL )
-  unset( DL_LIBRARIES )
-  check_function_exists( dlopen HAVE_DLOPEN )
-  if( HAVE_DLOPEN )
-    set( HAVE_LIBDL 1 )
-  endif( HAVE_DLOPEN )
-endif( NOT HAVE_LIBDL )
-
-find_package( Threads )
-
-
-##### check for functions #######################
-
-set( bak_CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} )
-set( CMAKE_REQUIRED_LIBRARIES ${DL_LIBRARIES} )
-check_function_exists( dlerror HAVE_DLERROR )
-check_function_exists( strcmp HAVE_STRCMP )
-check_function_exists( strchr HAVE_STRCHR )
-check_function_exists( index HAVE_INDEX )
-check_function_exists( strrchr HAVE_STRRCHR )
-check_function_exists( rindex HAVE_RINDEX )
-check_function_exists( memcpy HAVE_MEMCPY )
-check_function_exists( bcopy HAVE_BCOPY )
-set( CMAKE_REQUIRED_LIBRARIES ${bak_CMAKE_REQUIRED_LIBRARIES} )
-unset( bak_CMAKE_REQUIRED_LIBRARIES )
-check_prototype_definition( ioctl "int ioctl(int d, int request, ...)" "-1" "unistd.h;sys/ioctl.h" HAVE_IOCTL_INT_INT_DOTS )
-check_prototype_definition( ioctl "int ioctl(int d, unsigned long request, ...)" "-1" "unistd.h;sys/ioctl.h" HAVE_IOCTL_INT_ULONG_DOTS )
-
-
-##### check for audiofile #######################
-
-set( HAVE_LIBAUDIOFILE 0 )
-if( WITH_AUDIOFILE )
-
-  pkg_search_module( AUDIOFILE audiofile )
-  if( AUDIOFILE_FOUND )
-    set( HAVE_LIBAUDIOFILE 1 )
-  else( AUDIOFILE_FOUND )
-    message(FATAL_ERROR "\naudiofile (wav) support are requested, but `libaudiofile` not found" )
-  endif( AUDIOFILE_FOUND )
-
-endif( WITH_AUDIOFILE )
-
-
-##### check for alsa ############################
-
-set( HAVE_LIBASOUND2 0 )
-if( WITH_ALSA )
-
-  pkg_search_module( ALSA alsa )
-
-  if( ALSA_FOUND )
+##### configure checks
 
-    # there is support only for ALSA 1.x
+set( PC_LIB_REQUIRE "" CACHE INTERNAL "List of required packages" FORCE )
+include( ConfigureChecks.cmake )
 
-    set( HAVE_LIBASOUND2 1 )
-    set( ALSA_PCM_OLD_SW_PARAMS_API 1 )
-    set( ALSA_PCM_OLD_HW_PARAMS_API 1 )
-
-    check_include_file( "alsa/asoundlib.h" HAVE_ALSA_ASOUNDLIB_H )
-    if( NOT HAVE_ALSA_ASOUNDLIB_H )
-      check_include_file( "sys/asoundlib.h" HAVE_SYS_ASOUNDLIB_H )
-    endif( NOT HAVE_ALSA_ASOUNDLIB_H )
-
-    set( bak_CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} )
-    set( CMAKE_REQUIRED_LIBRARIES ${ALSA_LIBRARIES} )
-    check_function_exists( snd_pcm_resume HAVE_SND_PCM_RESUME )
-    set( CMAKE_REQUIRED_LIBRARIES ${bak_CMAKE_REQUIRED_LIBRARIES} )
-    unset( bak_CMAKE_REQUIRED_LIBRARIES )
-
-  else( ALSA_FOUND )
-
-    message(FATAL_ERROR "\nALSA support are requested, but not found on your system" )
-
-  endif( ALSA_FOUND )
-
-endif( WITH_ALSA )
-
-
-##### check for esound #######################
-
-set( HAVE_LIBESD 0 )
-if( WITH_ESOUND )
-
-  pkg_search_module( ESOUND esound )
-  if( ESOUND_FOUND )
-    set( HAVE_LIBESD 1 )
-  else( ESOUND_FOUND )
-    message(FATAL_ERROR "\nESOUND support is requested, but `libesd` not found" )
-  endif( ESOUND_FOUND )
-
-endif( WITH_ESOUND )
-
-
-##### check for JACK ############################
-
-set( HAVE_LIBJACK 0 )
-if( WITH_JACK )
-  pkg_search_module( LIBJACK jack )
-  if( LIBJACK_FOUND )
-    set( HAVE_LIBJACK 1 )
-  else( LIBJACK_FOUND )
-    message(FATAL_ERROR "\nJACK support is requested, but `jack.pc` was not found" )
-  endif( LIBJACK_FOUND )
-endif( WITH_JACK )
-
-
-##### check for SNDIO ###########################
-
-set( HAVE_LIBSNDIO 0 )
-if( WITH_SNDIO )
-  check_include_file( "sndio.h" HAVE_SNDIO_H )
-  if( HAVE_SNDIO_H )
-    set( HAVE_LIBSNDIO 1 )
-    set( LIBSNDIO_LIBRARIES "sndio" )
-  else( HAVE_SNDIO_H )
-    tde_message_fatal( "SNDIO support is requested, but `sndio.h` was not found" )
-  endif( HAVE_SNDIO_H )
-endif( WITH_SNDIO )
-
-
-##### check for glib/gthread modules ############
-
-pkg_search_module( GLIB2 glib-2.0 )
-
-if( GLIB2_FOUND )
-  pkg_search_module( GTHREAD2 gthread-2.0 )
-  if( NOT GTHREAD2_FOUND )
-    message(FATAL_ERROR "\ngthread-2.0 are required, but not found on your system" )
-  endif( NOT GTHREAD2_FOUND )
-else( GLIB2_FOUND )
-  message(FATAL_ERROR "\nglib-2.0 are required, but not found on your system" )
-endif( GLIB2_FOUND )
 
+##### global compiler settings ##################
 
-##### check for TQt #############################
+add_definitions( -DHAVE_CONFIG_H )
 
-find_package( TQt )
+set( CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined" )
 
 
-##### check for gcc visibility support #########
+##### project subdirectories ####################
 
-if( WITH_GCC_VISIBILITY )
-  tde_setup_gcc_visibility( )
-endif( )
+add_subdirectory( libltdl )
+add_subdirectory( mcop )
+add_subdirectory( mcopidl )
+add_subdirectory( flow )
+add_subdirectory( mcop_mt )
+add_subdirectory( soundserver )
+add_subdirectory( artsc )
+add_subdirectory( gmcop )
+add_subdirectory( qtmcop )
 
 
 ##### write config.h file #######################
@@ -244,29 +93,10 @@ configure_file( config.h.cmake config.h @ONLY )
 
 ##### write pkgconfig file ######################
 
-set( PC_LIB_REQUIRE "" )
-if( WITH_ALSA )
-  list( APPEND PC_LIB_REQUIRE "alsa" )
-endif( WITH_ALSA )
-if( WITH_AUDIOFILE )
-  list( APPEND PC_LIB_REQUIRE "audiofile" )
-endif( WITH_AUDIOFILE )
-if( WITH_VORBIS )
-  list( APPEND PC_LIB_REQUIRE "vorbis" )
-  list( APPEND PC_LIB_REQUIRE "vorbisfile" )
-endif( WITH_VORBIS )
-if( WITH_MAD )
-  list( APPEND PC_LIB_REQUIRE "mad" )
-endif( WITH_MAD )
-if( WITH_ESOUND )
-  list( APPEND PC_LIB_REQUIRE "esound" )
-endif( WITH_ESOUND )
-if( WITH_JACK )
-  list( APPEND PC_LIB_REQUIRE "jack" )
-endif( WITH_JACK )
-
 list( LENGTH PC_LIB_REQUIRE PC_LIB_REQUIRES_FOUND )
 if( PC_LIB_REQUIRES_FOUND GREATER 0 )
+  list( SORT PC_LIB_REQUIRE )
+  list( REMOVE_DUPLICATES PC_LIB_REQUIRE )
   string( REPLACE ";" " " PC_LIB_REQUIRES "Requires: ${PC_LIB_REQUIRE}" )
 else( )
   set( PC_LIB_REQUIRES "" )
@@ -277,25 +107,3 @@ string( REGEX REPLACE "^${CMAKE_INSTALL_PREFIX}" "\${prefix}" PC_INCLUDE_DIR ${I
 string( REGEX REPLACE "^${CMAKE_INSTALL_PREFIX}" "\${prefix}" PC_LIB_DIR ${LIB_INSTALL_DIR} )
 configure_file( arts.pc.cmake arts.pc @ONLY )
 install( FILES ${CMAKE_CURRENT_BINARY_DIR}/arts.pc DESTINATION ${PKGCONFIG_INSTALL_DIR} )
-
-
-##### global compiler settings ##################
-
-add_definitions(
-  -DHAVE_CONFIG_H
-)
-
-set( CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined" )
-
-
-##### project subdirectories ####################
-
-add_subdirectory( libltdl )
-add_subdirectory( mcop )
-add_subdirectory( mcopidl )
-add_subdirectory( flow )
-add_subdirectory( mcop_mt )
-add_subdirectory( soundserver )
-add_subdirectory( artsc )
-add_subdirectory( gmcop )
-add_subdirectory( qtmcop )
diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake
new file mode 100644
index 0000000..5e3fb98
--- /dev/null
+++ b/ConfigureChecks.cmake
@@ -0,0 +1,194 @@
+#################################################
+#
+#  (C) 2010 Serghei Amelian
+#  serghei (DOT) amelian (AT) gmail.com
+#
+#  Improvements and feedback are welcome
+#
+#  This file is released under GPL >= 2
+#
+#################################################
+
+
+# required stuff
+
+tde_setup_architecture_flags( )
+
+include(TestBigEndian)
+test_big_endian(WORDS_BIGENDIAN)
+
+tde_setup_largefiles( )
+
+
+##### check for TQt #############################
+
+find_package( TQt )
+
+
+##### check for gcc visibility support #########
+
+if( WITH_GCC_VISIBILITY )
+  tde_setup_gcc_visibility( )
+endif( )
+
+
+##### check for include files ###################
+
+check_include_file( "sys/time.h" HAVE_SYS_TIME_H )
+check_include_file( "time.h" TIME_WITH_SYS_TIME )
+check_include_file( "stdio.h" HAVE_STDIO_H )
+check_include_file( "stdlib.h" HAVE_STDLIB_H )
+check_include_file( "string.h" HAVE_STRING_H )
+check_include_file( "strings.h" HAVE_STRINGS_H )
+check_include_file( "ctype.h" HAVE_CTYPE_H )
+check_include_file( "malloc.h" HAVE_MALLOC_H )
+check_include_file( "memory.h" HAVE_MEMORY_H )
+check_include_file( "dlfcn.h" HAVE_DLFCN_H )
+check_include_file( "sys/soundcard.h" HAVE_SYS_SOUNDCARD_H )
+check_include_file( "pthread.h" HAVE_LIBPTHREAD )
+
+
+##### check for system libraries ################
+
+set( DL_LIBRARIES dl )
+check_library_exists( ${DL_LIBRARIES} dlopen /lib HAVE_LIBDL )
+if( NOT HAVE_LIBDL )
+  unset( DL_LIBRARIES )
+  check_function_exists( dlopen HAVE_DLOPEN )
+  if( HAVE_DLOPEN )
+    set( HAVE_LIBDL 1 )
+  endif( HAVE_DLOPEN )
+endif( NOT HAVE_LIBDL )
+
+find_package( Threads )
+
+
+##### check for functions #######################
+
+tde_save_and_set( CMAKE_REQUIRED_LIBRARIES ${DL_LIBRARIES} )
+check_function_exists( dlerror HAVE_DLERROR )
+check_function_exists( strcmp HAVE_STRCMP )
+check_function_exists( strchr HAVE_STRCHR )
+check_function_exists( index HAVE_INDEX )
+check_function_exists( strrchr HAVE_STRRCHR )
+check_function_exists( rindex HAVE_RINDEX )
+check_function_exists( memcpy HAVE_MEMCPY )
+check_function_exists( bcopy HAVE_BCOPY )
+tde_restore( CMAKE_REQUIRED_LIBRARIES )
+
+check_prototype_definition( ioctl "int ioctl(int d, int request, ...)" "-1" "unistd.h;sys/ioctl.h" HAVE_IOCTL_INT_INT_DOTS )
+check_prototype_definition( ioctl "int ioctl(int d, unsigned long request, ...)" "-1" "unistd.h;sys/ioctl.h" HAVE_IOCTL_INT_ULONG_DOTS )
+
+
+##### check for audiofile #######################
+
+set( HAVE_LIBAUDIOFILE 0 )
+if( WITH_AUDIOFILE )
+
+  pkg_search_module( AUDIOFILE audiofile )
+  if( AUDIOFILE_FOUND )
+    set( HAVE_LIBAUDIOFILE 1 )
+    list( APPEND PC_LIB_REQUIRE "audiofile" )
+  else( AUDIOFILE_FOUND )
+    tde_message_fatal( "audiofile (wav) support is requested, but `libaudiofile` not found" )
+  endif( AUDIOFILE_FOUND )
+
+endif( WITH_AUDIOFILE )
+
+
+##### check for alsa ############################
+
+set( HAVE_LIBASOUND2 0 )
+if( WITH_ALSA )
+
+  pkg_search_module( ALSA alsa )
+
+  if( ALSA_FOUND )
+
+    # there is support only for ALSA 1.x
+
+    set( HAVE_LIBASOUND2 1 )
+    set( ALSA_PCM_OLD_SW_PARAMS_API 1 )
+    set( ALSA_PCM_OLD_HW_PARAMS_API 1 )
+
+    check_include_file( "alsa/asoundlib.h" HAVE_ALSA_ASOUNDLIB_H )
+    if( NOT HAVE_ALSA_ASOUNDLIB_H )
+      check_include_file( "sys/asoundlib.h" HAVE_SYS_ASOUNDLIB_H )
+    endif( NOT HAVE_ALSA_ASOUNDLIB_H )
+
+    tde_save_and_set( CMAKE_REQUIRED_LIBRARIES ${ALSA_LIBRARIES} )
+    check_function_exists( snd_pcm_resume HAVE_SND_PCM_RESUME )
+    tde_restore( CMAKE_REQUIRED_LIBRARIES )
+
+    list( APPEND PC_LIB_REQUIRE "alsa" )
+
+  else( ALSA_FOUND )
+
+    tde_message_fatal( "ALSA support is requested, but not found on your system" )
+
+  endif( ALSA_FOUND )
+
+endif( WITH_ALSA )
+
+
+##### check for esound #######################
+
+set( HAVE_LIBESD 0 )
+if( WITH_ESOUND )
+
+  pkg_search_module( ESOUND esound )
+  if( ESOUND_FOUND )
+    set( HAVE_LIBESD 1 )
+    list( APPEND PC_LIB_REQUIRE "esound" )
+  else( ESOUND_FOUND )
+    tde_message_fatal( "ESOUND support is requested, but `libesd` not found" )
+  endif( ESOUND_FOUND )
+
+endif( WITH_ESOUND )
+
+
+##### check for JACK ############################
+
+set( HAVE_LIBJACK 0 )
+if( WITH_JACK )
+  pkg_search_module( LIBJACK jack )
+  if( LIBJACK_FOUND )
+    set( HAVE_LIBJACK 1 )
+    list( APPEND PC_LIB_REQUIRE "jack" )
+  else( LIBJACK_FOUND )
+    tde_message_fatal( "JACK support is requested, but `jack.pc` was not found" )
+  endif( LIBJACK_FOUND )
+endif( WITH_JACK )
+
+
+##### check for SNDIO ###########################
+
+set( HAVE_LIBSNDIO 0 )
+if( WITH_SNDIO )
+  check_include_file( "sndio.h" HAVE_SNDIO_H )
+  if( HAVE_SNDIO_H )
+    set( HAVE_LIBSNDIO 1 )
+    set( LIBSNDIO_LIBRARIES "sndio" )
+  else( HAVE_SNDIO_H )
+    tde_message_fatal( "SNDIO support is requested, but `sndio.h` was not found" )
+  endif( HAVE_SNDIO_H )
+endif( WITH_SNDIO )
+
+
+##### check for glib/gthread modules ############
+
+pkg_search_module( GLIB2 glib-2.0 )
+
+if( GLIB2_FOUND )
+  pkg_search_module( GTHREAD2 gthread-2.0 )
+  if( NOT GTHREAD2_FOUND )
+    tde_message_message( "gthread-2.0 is required, but not found on your system" )
+  endif( NOT GTHREAD2_FOUND )
+else( GLIB2_FOUND )
+  tde_message_fatal( "glib-2.0 is required, but not found on your system" )
+endif( GLIB2_FOUND )
+
+
+##### save cached value of required packages ####
+
+set( PC_LIB_REQUIRE "${PC_LIB_REQUIRE}" CACHE INTERNAL "List of required packages" FORCE )
diff --git a/flow/gsl/CMakeLists.txt b/flow/gsl/CMakeLists.txt
index e8e9576..b3370fd 100644
--- a/flow/gsl/CMakeLists.txt
+++ b/flow/gsl/CMakeLists.txt
@@ -9,97 +9,9 @@
 #
 #################################################
 
-include( CheckCSourceCompiles )
+##### configure checks
 
-
-##### check for ogg/vorbis ######################
-
-set( GSL_HAVE_OGGVORBIS 0 )
-if( WITH_VORBIS )
-
-  pkg_search_module( VORBIS vorbis )
-
-  if( VORBIS_FOUND )
-
-    pkg_search_module( VORBISFILE vorbisfile )
-
-    if( VORBISFILE_FOUND )
-
-      set( GSL_HAVE_OGGVORBIS 1 )
-
-      set( bak_CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} )
-      set( CMAKE_REQUIRED_LIBRARIES ${VORBISFILE_LIBRARIES} )
-      check_c_source_compiles(
-        "#include <vorbis/vorbisfile.h>
-        int main() { ov_read_float(0,0,0); return 0; } "
-        GSL_HAVE_OGGVORBIS_RC3 )
-      if( NOT GSL_HAVE_OGGVORBIS_RC3 )
-        set( GSL_HAVE_OGGVORBIS_RC3 0 )
-      endif( NOT GSL_HAVE_OGGVORBIS_RC3 )
-      set( CMAKE_REQUIRED_LIBRARIES ${bak_CMAKE_REQUIRED_LIBRARIES} )
-
-    else( VORBISFILE_FOUND )
-
-      message(FATAL_ERROR "\nOgg/Vorbis support are requested, but `libvorbisfile` not found" )
-
-    endif( VORBISFILE_FOUND )
-
-  else( VORBIS_FOUND )
-
-    message(FATAL_ERROR "\nOgg/Vorbis support are requested, but `libvorbis` but found" )
-
-  endif( VORBIS_FOUND )
-
-endif( WITH_VORBIS )
-
-
-##### check for libmad MPEG decoder #############
-
-set( GSL_HAVE_LIBMAD 0 )
-if( WITH_MAD )
-
-  pkg_search_module( MAD mad )
-
-  if( MAD_FOUND )
-    set( GSL_HAVE_LIBMAD 1 )
-  else( MAD_FOUND )
-    find_library( MAD_LIBRARIES NAMES mad )
-    find_path( MAD_INCLUDE_DIRS mad.h )
-    if( NOT MAD_LIBRARIES )
-        message(FATAL_ERROR "\nMAD support is requested, but `libmad` not found" )
-    endif( NOT MAD_LIBRARIES )
-  endif( MAD_FOUND )
-
-endif( WITH_MAD )
-
-
-##### check for some type sizes #################
-
-include( CheckTypeSize )
-
-check_type_size( pthread_mutex_t GSL_SIZEOF_PTH_MUTEX_T )
-check_type_size( pthread_cond_t GSL_SIZEOF_PTH_COND_T )
-check_type_size( intmax_t GSL_SIZEOF_STD_INTMAX_T )
-
-set( bak_CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} )
-set( CMAKE_REQUIRED_LIBRARIES ${CMAKE_THREAD_LIBS_INIT} )
-check_c_source_compiles(
-  "#define _XOPEN_SOURCE 500
-  #include <pthread.h>
-  int main()
-  {
-      int (*attr_settype) (pthread_mutexattr_t *__attr, int __kind) = pthread_mutexattr_settype;
-      int val = PTHREAD_MUTEX_RECURSIVE; attr_settype = 0; val = 0;
-      return 0;
-  }"
-  GSL_HAVE_MUTEXATTR_SETTYPE )
-  if( NOT GSL_HAVE_MUTEXATTR_SETTYPE )
-    set( GSL_HAVE_MUTEXATTR_SETTYPE 0 )
-  endif( NOT GSL_HAVE_MUTEXATTR_SETTYPE )
-set( CMAKE_REQUIRED_LIBRARIES ${bak_CMAKE_REQUIRED_LIBRARIES} )
-
-set( GSL_USE_GSL_GLIB 1 )
-set( GSL_USE_ARTS_THREADS 1 )
+include( ConfigureChecks.cmake )
 
 
 ##### write configuration #######################
@@ -152,4 +64,3 @@ tde_add_library( ${target} STATIC_PIC
   LINK ${GLIB2_LIBRARIES} ${GTHREAD2_LIBRARIES} ${VORBISFILE_LIBRARIES} ${VORBIS_LIBRARIES} ${MAD_LIBRARIES}
   DESTINATION ${LIB_INSTALL_DIR}
 )
-
diff --git a/flow/gsl/ConfigureChecks.cmake b/flow/gsl/ConfigureChecks.cmake
new file mode 100644
index 0000000..f0a9dee
--- /dev/null
+++ b/flow/gsl/ConfigureChecks.cmake
@@ -0,0 +1,112 @@
+#################################################
+#
+#  (C) 2010 Serghei Amelian
+#  serghei (DOT) amelian (AT) gmail.com
+#
+#  Improvements and feedback are welcome
+#
+#  This file is released under GPL >= 2
+#
+#################################################
+
+include( CheckCSourceCompiles )
+include( CheckTypeSize )
+
+
+##### check for ogg/vorbis ######################
+
+set( GSL_HAVE_OGGVORBIS 0 )
+if( WITH_VORBIS )
+
+  pkg_search_module( VORBIS vorbis )
+
+  if( VORBIS_FOUND )
+
+    pkg_search_module( VORBISFILE vorbisfile )
+
+    if( VORBISFILE_FOUND )
+
+      set( GSL_HAVE_OGGVORBIS 1 )
+
+      tde_save_and_set( CMAKE_REQUIRED_LIBRARIES ${VORBISFILE_LIBRARIES} )
+      check_c_source_compiles(
+        "#include <vorbis/vorbisfile.h>
+        int main() { ov_read_float(0,0,0); return 0; } "
+        GSL_HAVE_OGGVORBIS_RC3 )
+      if( NOT GSL_HAVE_OGGVORBIS_RC3 )
+        set( GSL_HAVE_OGGVORBIS_RC3 0 )
+      endif( NOT GSL_HAVE_OGGVORBIS_RC3 )
+      tde_restore( CMAKE_REQUIRED_LIBRARIES )
+
+      list( APPEND PC_LIB_REQUIRE "vorbis" "vorbisfile" )
+
+    else( VORBISFILE_FOUND )
+
+      tde_message_fatal( "Ogg/Vorbis support are requested, but `libvorbisfile` not found" )
+
+    endif( VORBISFILE_FOUND )
+
+  else( VORBIS_FOUND )
+
+    tde_message_fafal( "Ogg/Vorbis support are requested, but `libvorbis` but found" )
+
+  endif( VORBIS_FOUND )
+
+endif( WITH_VORBIS )
+
+
+##### check for libmad MPEG decoder #############
+
+set( GSL_HAVE_LIBMAD 0 )
+if( WITH_MAD )
+
+  pkg_search_module( MAD libmad )
+  set( MAD_MODULE_NAME "libmad" )
+  if( NOT MAD_FOUND )
+    pkg_search_module( MAD mad )
+    set( MAD_MODULE_NAME "mad" )
+  endif()
+
+  if( MAD_FOUND )
+    set( GSL_HAVE_LIBMAD 1 )
+    list( APPEND PC_LIB_REQUIRE ${MAD_MODULE_NAME} )
+  else( MAD_FOUND )
+    find_library( MAD_LIBRARIES NAMES mad )
+    find_path( MAD_INCLUDE_DIRS mad.h )
+    if( NOT MAD_LIBRARIES )
+        tde_message_fatal( "MAD support is requested, but `libmad` not found" )
+    endif( NOT MAD_LIBRARIES )
+  endif( MAD_FOUND )
+
+endif( WITH_MAD )
+
+
+##### check for some type sizes #################
+
+check_type_size( pthread_mutex_t GSL_SIZEOF_PTH_MUTEX_T )
+check_type_size( pthread_cond_t GSL_SIZEOF_PTH_COND_T )
+check_type_size( intmax_t GSL_SIZEOF_STD_INTMAX_T )
+
+tde_save_and_set( CMAKE_REQUIRED_LIBRARIES ${CMAKE_THREAD_LIBS_INIT} )
+check_c_source_compiles(
+  "#define _XOPEN_SOURCE 500
+  #include <pthread.h>
+  int main()
+  {
+      int (*attr_settype) (pthread_mutexattr_t *__attr, int __kind) = pthread_mutexattr_settype;
+      int val = PTHREAD_MUTEX_RECURSIVE; attr_settype = 0; val = 0;
+      return 0;
+  }"
+  GSL_HAVE_MUTEXATTR_SETTYPE )
+  if( NOT GSL_HAVE_MUTEXATTR_SETTYPE )
+    set( GSL_HAVE_MUTEXATTR_SETTYPE 0 )
+  endif( NOT GSL_HAVE_MUTEXATTR_SETTYPE )
+tde_restore( CMAKE_REQUIRED_LIBRARIES )
+
+set( GSL_USE_GSL_GLIB 1 )
+set( GSL_USE_ARTS_THREADS 1 )
+
+
+##### save cached value of required packages ####
+
+set( PC_LIB_REQUIRE "${PC_LIB_REQUIRE}" CACHE INTERNAL "List of required packages" FORCE )