Fix for ticket:236, parallel makes are indeterminate.
[debian/gnuradio] / gr-trellis / src / lib / Makefile.am
1 #
2 # Copyright 2004,2005,2006,2007,2008 Free Software Foundation, Inc.
3
4 # This file is part of GNU Radio
5
6 # GNU Radio is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 3, or (at your option)
9 # any later version.
10
11 # GNU Radio is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 # GNU General Public License for more details.
15
16 # You should have received a copy of the GNU General Public License
17 # along with GNU Radio; see the file COPYING.  If not, write to
18 # the Free Software Foundation, Inc., 51 Franklin Street,
19 # Boston, MA 02110-1301, USA.
20
21
22 include $(top_srcdir)/Makefile.common
23
24 # Install this stuff so that it ends up as the gnuradio.trellis module
25 # This usually ends up at:
26 #   ${prefix}/lib/python${python_version}/site-packages/gnuradio
27
28 ourpythondir = $(grpythondir)
29 ourlibdir    = $(grpyexecdir)
30
31 AM_CPPFLAGS = $(STD_DEFINES_AND_INCLUDES) $(PYTHON_CPPFLAGS) $(WITH_INCLUDES)
32
33 SWIGPYTHONARGS = $(SWIGPYTHONFLAGS) $(STD_DEFINES_AND_INCLUDES) \
34         $(WITH_SWIG_INCLUDES) $(WITH_INCLUDES)
35
36 # ----------------------------------------------------------------
37 # these scripts generate trellis codes from template files
38
39 CODE_GENERATOR =                                \
40         generate_all.py                         \
41         generate_trellis.py                     \
42         trellis_encoder_XX.cc.t                 \
43         trellis_encoder_XX.h.t                  \
44         trellis_encoder_XX.i.t                  \
45         trellis_metrics_X.cc.t                  \
46         trellis_metrics_X.h.t                   \
47         trellis_metrics_X.i.t                   \
48         trellis_viterbi_combined_XX.cc.t                \
49         trellis_viterbi_combined_XX.h.t         \
50         trellis_viterbi_combined_XX.i.t         \
51         trellis_viterbi_X.cc.t                  \
52         trellis_viterbi_X.h.t                   \
53         trellis_viterbi_X.i.t
54
55 include $(srcdir)/Makefile.gen
56
57
58 # Ensure parallel does the right thing.
59 # http://sources.redhat.com/automake/automake.html#Multiple-Outputs
60
61 generate-stamp: $(CODE_GENERATOR)
62         @rm -f generate-tmp
63         @touch generate-tmp
64         PYTHONPATH=$(top_srcdir)/gnuradio-core/src/python srcdir=$(srcdir) $(PYTHON) $(srcdir)/generate_all.py
65         touch $(srcdir)/Makefile.in
66         @mv -f generate-tmp $@
67
68 $(srcdir)/Makefile.gen $(GENERATED_H) $(GENERATED_I) $(GENERATED_CC): generate-stamp
69 ## Recover from the removal of $@
70         @if test -f $@; then :; else \
71                trap 'rm -rf generate-lock generate-stamp' 1 2 13 15; \
72                if mkdir generate-lock 2>/dev/null; then \
73 ## This code is being executed by the first process.
74                  rm -f generate-stamp; \
75                  $(MAKE) $(AM_MAKEFLAGS) generate-stamp; \
76                  rmdir generate-lock; \
77                else \
78 ## This code is being executed by the follower processes.
79 ## Wait until the first process is done.
80                  while test -d generate-lock; do sleep 1; done; \
81 ## Succeed if and only if the first process succeeded.
82                  test -f generate-stamp; exit $$?; \
83                fi; \
84              fi
85
86
87 # These files are built by SWIG.  The first is the C++ glue.
88 # The second is the python wrapper that loads the _trellis shared library
89 # and knows how to call our extensions.
90
91 swig_built_sources =            \
92         trellis.cc              \
93         trellis.py                              
94
95 BUILT_SOURCES = \
96         $(GENERATED_H)          \
97         $(GENERATED_I)          \
98         $(GENERATED_CC)         \
99         $(swig_built_sources)
100
101 ALL_IFILES =                    \
102         $(LOCAL_IFILES)         \
103         $(NON_LOCAL_IFILES)     
104
105 NON_LOCAL_IFILES =              \
106         $(GNURADIO_I)   
107
108 LOCAL_IFILES =                  \
109         $(top_srcdir)/gr-trellis/src/lib/trellis.i                      
110
111 EXTRA_DIST =                    \
112         $(CODE_GENERATOR)
113
114 # This gets trellis.py installed in the right place
115 ourpython_PYTHON =              \
116         trellis.py
117
118 ourlib_LTLIBRARIES = _trellis.la
119
120 # These are the source files that go into the shared library
121 _trellis_la_SOURCES =                   \
122         trellis.cc                      \
123         fsm.cc                          \
124         quicksort_index.cc              \
125         base.cc                         \
126         interleaver.cc                  \
127         trellis_calc_metric.cc          \
128         trellis_permutation.cc          \
129         trellis_siso_f.cc               \
130         trellis_siso_combined_f.cc      \
131         $(GENERATED_CC)                 
132
133 # magic flags
134 _trellis_la_LDFLAGS = $(NO_UNDEFINED) -module -avoid-version
135
136 # link the library against some comon swig runtime code and the 
137 # c++ standard library
138 _trellis_la_LIBADD =                    \
139         $(PYTHON_LDFLAGS)               \
140         $(GNURADIO_CORE_LA)             \
141         -lstdc++
142
143 trellis.cc trellis.py: $(ALL_IFILES) $(grinclude_HEADERS)
144         $(SWIG) $(SWIGPYTHONARGS) -module trellis -o trellis.cc $(LOCAL_IFILES)
145
146 # These headers get installed in ${prefix}/include/gnuradio
147 grinclude_HEADERS =                     \
148         fsm.h                           \
149         quicksort_index.h               \
150         base.h                          \
151         interleaver.h                   \
152         trellis_metric_type.h           \
153         trellis_calc_metric.h           \
154         trellis_permutation.h           \
155         trellis_siso_type.h             \
156         trellis_siso_f.h                \
157         trellis_siso_combined_f.h       \
158         $(GENERATED_H)
159
160 # These swig headers get installed in ${prefix}/include/gnuradio/swig
161 swiginclude_HEADERS =                   \
162         $(LOCAL_IFILES)                 \
163         $(GENERATED_I)                  \
164         fsm.i                           \
165         interleaver.i                   \
166         trellis_permutation.i           \
167         trellis_siso_f.i                \
168         trellis_siso_combined_f.i       \
169         trellis_generated.i
170
171 CLEANFILES = $(BUILT_SOURCES) *.pyc
172
173 # Don't distribute output of swig
174 dist-hook:
175         @for file in $(swig_built_sources); do echo $(RM) $(distdir)/$$file; done
176         @for file in $(swig_built_sources); do $(RM) $(distdir)/$$file; done