Merge branch 'development' into ptrkrysik/trx

# Conflicts:
#	lib/CMakeLists.txt
diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt
index 7804e07..c6bba6e 100644
--- a/lib/CMakeLists.txt
+++ b/lib/CMakeLists.txt
@@ -17,13 +17,30 @@
 # the Free Software Foundation, Inc., 51 Franklin Street,
 # Boston, MA 02110-1301, USA.
 
-########################################################################
-# Setup library
-########################################################################
 include(GrPlatform) #define LIB_SUFFIX
 include(GrMiscUtils)
 
 ########################################################################
+# Add sources macro
+########################################################################
+set(grgsm_sources "")
+
+macro (add_sources)
+    file (RELATIVE_PATH _relPath "${PROJECT_SOURCE_DIR}/lib" "${CMAKE_CURRENT_SOURCE_DIR}")
+    foreach (_src ${ARGN})
+        if (_relPath)
+            list (APPEND grgsm_sources "${_relPath}/${_src}")
+        else()
+            list (APPEND grgsm_sources "${_src}")
+        endif()
+    endforeach()
+    if (_relPath)
+        # propagate grgsm_sources to parent directory
+        set (grgsm_sources ${grgsm_sources} PARENT_SCOPE)
+    endif()
+endmacro()
+
+########################################################################
 # Handle the generated constants
 ########################################################################
 execute_process(COMMAND ${PYTHON_EXECUTABLE} -c
@@ -42,64 +59,25 @@
     ESCAPE_QUOTES
 @ONLY)
 
-list(APPEND grgsm_sources ${CMAKE_CURRENT_BINARY_DIR}/constants.cc)
+add_sources(constants.cc)
 #########################################################################
+# Subdirecories
+#########################################################################
+add_subdirectory(decoding)
+add_subdirectory(decryption)
+add_subdirectory(demapping)
+add_subdirectory(flow_control)
+add_subdirectory(misc_utils)
+add_subdirectory(qa_utils)
+add_subdirectory(receiver)
+add_subdirectory(transmitter)
+add_subdirectory(trx_interface)
 
+########################################################################
+# Setup library
+########################################################################
 include_directories(${Boost_INCLUDE_DIR} receiver)
 link_directories(${Boost_LIBRARY_DIRS})
-list(APPEND grgsm_sources
-    receiver/receiver_impl.cc
-    receiver/receiver_config.cc
-    receiver/viterbi_detector.cc
-    decoding/sch.c
-    receiver/clock_offset_control_impl.cc
-    receiver/cx_channel_hopper_impl.cc
-    demapping/universal_ctrl_chans_demapper_impl.cc
-    demapping/tch_f_chans_demapper_impl.cc
-    decoding/control_channels_decoder_impl.cc
-    decoding/tch_f_decoder_impl.cc
-    decoding/openbts/AmrCoder.cpp
-    decoding/openbts/BitVector.cpp
-    decoding/openbts/GSM610Tables.cpp
-    decoding/openbts/GSM660Tables.cpp
-    decoding/openbts/GSM503Tables.cpp
-    decoding/openbts/ViterbiR204.cpp
-    decoding/osmocom/coding/gsm0503_conv.c
-    decoding/osmocom/coding/gsm0503_coding.c
-    decoding/osmocom/coding/gsm0503_interleaving.c
-    decoding/osmocom/coding/gsm0503_mapping.c
-    decoding/osmocom/coding/gsm0503_parity.c
-    decoding/osmocom/coding/gsm0503_tables.c
-    flow_control/burst_timeslot_splitter_impl.cc
-    flow_control/burst_sdcch_subslot_splitter_impl.cc
-    flow_control/burst_timeslot_filter_impl.cc
-    flow_control/burst_sdcch_subslot_filter_impl.cc
-    flow_control/burst_fnr_filter_impl.cc
-    flow_control/dummy_burst_filter_impl.cc
-    flow_control/uplink_downlink_splitter_impl.cc
-    misc_utils/collect_system_info_impl.cc
-    misc_utils/controlled_rotator_cc_impl.cc
-    misc_utils/controlled_fractional_resampler_cc_impl.cc
-    misc_utils/msg_to_tag_impl.cc
-    misc_utils/message_printer_impl.cc
-    misc_utils/tmsi_dumper_impl.cc
-    misc_utils/burst_file_sink_impl.cc
-    misc_utils/burst_file_source_impl.cc
-    misc_utils/message_file_sink_impl.cc
-    misc_utils/message_file_source_impl.cc
-    misc_utils/bursts_printer_impl.cc
-    misc_utils/extract_system_info_impl.cc
-    misc_utils/extract_immediate_assignment_impl.cc
-    misc_utils/extract_cmc_impl.cc
-    qa_utils/burst_sink_impl.cc
-    qa_utils/burst_source_impl.cc
-    qa_utils/message_source_impl.cc
-    qa_utils/message_sink_impl.cc
-    decryption/decryption_impl.cc
-    trx_interface/udp_socket.cc
-    trx_interface/trx_impl.cc
-)
-
 
 add_library(grgsm SHARED ${grgsm_sources})
 target_link_libraries(grgsm ${Boost_LIBRARIES} ${GNURADIO_ALL_LIBRARIES} ${VOLK_LIBRARIES} ${LIBOSMOCODEC_LIBRARIES} ${LIBOSMOCORE_LIBRARIES} 
diff --git a/lib/decoding/CMakeLists.txt b/lib/decoding/CMakeLists.txt
new file mode 100644
index 0000000..0305a07
--- /dev/null
+++ b/lib/decoding/CMakeLists.txt
@@ -0,0 +1,28 @@
+# Copyright 2011,2012 Free Software Foundation, Inc.
+#
+# This file is part of GNU Radio
+#
+# GNU Radio is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# GNU Radio is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Radio; see the file COPYING.  If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street,
+# Boston, MA 02110-1301, USA.
+
+
+add_sources(
+    control_channels_decoder_impl.cc
+    tch_f_decoder_impl.cc
+    sch.c
+)
+
+add_subdirectory(osmocom/coding)
+add_subdirectory(openbts)
diff --git a/lib/decoding/openbts/CMakeLists.txt b/lib/decoding/openbts/CMakeLists.txt
new file mode 100644
index 0000000..eb857bf
--- /dev/null
+++ b/lib/decoding/openbts/CMakeLists.txt
@@ -0,0 +1,28 @@
+# Copyright 2011,2012 Free Software Foundation, Inc.
+#
+# This file is part of GNU Radio
+#
+# GNU Radio is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# GNU Radio is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Radio; see the file COPYING.  If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street,
+# Boston, MA 02110-1301, USA.
+
+add_sources(
+    AmrCoder.cpp
+    BitVector.cpp
+    GSM610Tables.cpp
+    GSM660Tables.cpp
+    GSM503Tables.cpp
+    ViterbiR204.cpp
+)
+
diff --git a/lib/decoding/osmocom/coding/CMakeLists.txt b/lib/decoding/osmocom/coding/CMakeLists.txt
new file mode 100644
index 0000000..615a2f6
--- /dev/null
+++ b/lib/decoding/osmocom/coding/CMakeLists.txt
@@ -0,0 +1,28 @@
+# Copyright 2011,2012 Free Software Foundation, Inc.
+#
+# This file is part of GNU Radio
+#
+# GNU Radio is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# GNU Radio is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Radio; see the file COPYING.  If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street,
+# Boston, MA 02110-1301, USA.
+
+add_sources(APPEND grgsm_sources
+    gsm0503_conv.c
+    gsm0503_coding.c
+    gsm0503_interleaving.c
+    gsm0503_mapping.c
+    gsm0503_parity.c
+    gsm0503_tables.c
+)
+
diff --git a/lib/decryption/CMakeLists.txt b/lib/decryption/CMakeLists.txt
new file mode 100644
index 0000000..7ccd99a
--- /dev/null
+++ b/lib/decryption/CMakeLists.txt
@@ -0,0 +1,22 @@
+# Copyright 2011,2012 Free Software Foundation, Inc.
+#
+# This file is part of GNU Radio
+#
+# GNU Radio is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# GNU Radio is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Radio; see the file COPYING.  If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street,
+# Boston, MA 02110-1301, USA.
+
+add_sources(
+    decryption_impl.cc
+)
diff --git a/lib/demapping/CMakeLists.txt b/lib/demapping/CMakeLists.txt
new file mode 100644
index 0000000..57d2d1a
--- /dev/null
+++ b/lib/demapping/CMakeLists.txt
@@ -0,0 +1,24 @@
+# Copyright 2011,2012 Free Software Foundation, Inc.
+#
+# This file is part of GNU Radio
+#
+# GNU Radio is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# GNU Radio is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Radio; see the file COPYING.  If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street,
+# Boston, MA 02110-1301, USA.
+
+add_sources(
+    tch_f_chans_demapper_impl.cc
+    universal_ctrl_chans_demapper_impl.cc
+)
+
diff --git a/lib/flow_control/CMakeLists.txt b/lib/flow_control/CMakeLists.txt
new file mode 100644
index 0000000..30a5f50
--- /dev/null
+++ b/lib/flow_control/CMakeLists.txt
@@ -0,0 +1,29 @@
+# Copyright 2011,2012 Free Software Foundation, Inc.
+#
+# This file is part of GNU Radio
+#
+# GNU Radio is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# GNU Radio is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Radio; see the file COPYING.  If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street,
+# Boston, MA 02110-1301, USA.
+
+add_sources(
+    burst_fnr_filter_impl.cc
+    burst_sdcch_subslot_filter_impl.cc
+    burst_sdcch_subslot_splitter_impl.cc
+    burst_timeslot_filter_impl.cc
+    burst_timeslot_splitter_impl.cc
+    dummy_burst_filter_impl.cc
+    uplink_downlink_splitter_impl.cc
+)
+
diff --git a/lib/misc_utils/CMakeLists.txt b/lib/misc_utils/CMakeLists.txt
new file mode 100644
index 0000000..1c51fb6
--- /dev/null
+++ b/lib/misc_utils/CMakeLists.txt
@@ -0,0 +1,36 @@
+# Copyright 2011,2012 Free Software Foundation, Inc.
+#
+# This file is part of GNU Radio
+#
+# GNU Radio is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# GNU Radio is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Radio; see the file COPYING.  If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street,
+# Boston, MA 02110-1301, USA.
+
+add_sources(
+    burst_file_sink_impl.cc
+    burst_file_source_impl.cc
+    bursts_printer_impl.cc
+    collect_system_info_impl.cc
+    controlled_fractional_resampler_cc_impl.cc
+    controlled_rotator_cc_impl.cc
+    extract_cmc_impl.cc
+    extract_immediate_assignment_impl.cc
+    extract_system_info_impl.cc
+    message_file_sink_impl.cc
+    message_file_source_impl.cc
+    message_printer_impl.cc
+    msg_to_tag_impl.cc
+    tmsi_dumper_impl.cc
+)
+
diff --git a/lib/qa_utils/CMakeLists.txt b/lib/qa_utils/CMakeLists.txt
new file mode 100644
index 0000000..a70967b
--- /dev/null
+++ b/lib/qa_utils/CMakeLists.txt
@@ -0,0 +1,25 @@
+# Copyright 2011,2012 Free Software Foundation, Inc.
+#
+# This file is part of GNU Radio
+#
+# GNU Radio is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# GNU Radio is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Radio; see the file COPYING.  If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street,
+# Boston, MA 02110-1301, USA.
+
+add_sources(
+    burst_sink_impl.cc
+    burst_source_impl.cc
+    message_sink_impl.cc
+    message_source_impl.cc
+)
diff --git a/lib/receiver/CMakeLists.txt b/lib/receiver/CMakeLists.txt
new file mode 100644
index 0000000..343d2f8
--- /dev/null
+++ b/lib/receiver/CMakeLists.txt
@@ -0,0 +1,26 @@
+# Copyright 2011,2012 Free Software Foundation, Inc.
+#
+# This file is part of GNU Radio
+#
+# GNU Radio is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# GNU Radio is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Radio; see the file COPYING.  If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street,
+# Boston, MA 02110-1301, USA.
+
+add_sources(
+    clock_offset_control_impl.cc
+    cx_channel_hopper_impl.cc
+    receiver_config.cc
+    receiver_impl.cc
+    viterbi_detector.cc
+)
diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt
index df11c10..6947d8f 100644
--- a/python/CMakeLists.txt
+++ b/python/CMakeLists.txt
@@ -28,20 +28,13 @@
 ########################################################################
 # Install python sources
 ########################################################################
+add_subdirectory(misc_utils)
+add_subdirectory(receiver)
+add_subdirectory(demapping)
+
 GR_PYTHON_INSTALL(
     FILES
-    __init__.py
-    demapping/gsm_bcch_ccch_demapper.py
-    demapping/gsm_bcch_ccch_sdcch4_demapper.py
-    demapping/gsm_sdcch8_demapper.py
-    receiver/gsm_input.py
-    receiver/fcch_burst_tagger.py
-    receiver/sch_detector.py
-    receiver/fcch_detector.py
-    receiver/chirpz.py
-    misc_utils/arfcn.py
-    misc_utils/clock_offset_corrector_tagged.py
-    misc_utils/hier_block.py DESTINATION ${GR_PYTHON_DIR}/grgsm
+    __init__.py DESTINATION ${GR_PYTHON_DIR}/grgsm
 )
 
 ########################################################################
diff --git a/python/demapping/CMakeLists.txt b/python/demapping/CMakeLists.txt
new file mode 100644
index 0000000..fd6e112
--- /dev/null
+++ b/python/demapping/CMakeLists.txt
@@ -0,0 +1,24 @@
+# Copyright 2011,2012 Free Software Foundation, Inc.
+#
+# This file is part of GNU Radio
+#
+# GNU Radio is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# GNU Radio is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Radio; see the file COPYING.  If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street,
+# Boston, MA 02110-1301, USA.
+
+install(FILES
+    gsm_bcch_ccch_demapper.py
+    gsm_bcch_ccch_sdcch4_demapper.py
+    gsm_sdcch8_demapper.py DESTINATION ${GR_PYTHON_DIR}/grgsm
+)
diff --git a/python/misc_utils/CMakeLists.txt b/python/misc_utils/CMakeLists.txt
new file mode 100644
index 0000000..ffba1b7
--- /dev/null
+++ b/python/misc_utils/CMakeLists.txt
@@ -0,0 +1,24 @@
+# Copyright 2011,2012 Free Software Foundation, Inc.
+#
+# This file is part of GNU Radio
+#
+# GNU Radio is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# GNU Radio is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Radio; see the file COPYING.  If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street,
+# Boston, MA 02110-1301, USA.
+
+install(FILES
+    arfcn.py
+    clock_offset_corrector_tagged.py
+    hier_block.py DESTINATION ${GR_PYTHON_DIR}/grgsm
+)
diff --git a/python/receiver/CMakeLists.txt b/python/receiver/CMakeLists.txt
new file mode 100644
index 0000000..07fe2a4
--- /dev/null
+++ b/python/receiver/CMakeLists.txt
@@ -0,0 +1,26 @@
+# Copyright 2011,2012 Free Software Foundation, Inc.
+#
+# This file is part of GNU Radio
+#
+# GNU Radio is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# GNU Radio is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Radio; see the file COPYING.  If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street,
+# Boston, MA 02110-1301, USA.
+
+install(FILES
+    gsm_input.py
+    fcch_burst_tagger.py
+    sch_detector.py
+    fcch_detector.py
+    chirpz.py DESTINATION ${GR_PYTHON_DIR}/grgsm
+)