|
| 1 | +SUBDIRS = . |
| 2 | + |
| 3 | +simple_switch_thrift_py_files = \ |
| 4 | +gen-py/sswitch_runtime/constants.py \ |
| 5 | +gen-py/sswitch_runtime/__init__.py \ |
| 6 | +gen-py/sswitch_runtime/SimpleSwitch.py \ |
| 7 | +gen-py/sswitch_runtime/ttypes.py |
| 8 | +simple_switch_thrift_files = \ |
| 9 | +gen-cpp/bm/simple_switch_constants.cpp \ |
| 10 | +gen-cpp/bm/simple_switch_constants.h \ |
| 11 | +gen-cpp/bm/SimpleSwitch.cpp \ |
| 12 | +gen-cpp/bm/SimpleSwitch.h \ |
| 13 | +gen-cpp/bm/simple_switch_types.cpp \ |
| 14 | +gen-cpp/bm/simple_switch_types.h |
| 15 | + |
| 16 | +BUILT_SOURCES = $(simple_switch_thrift_files) $(simple_switch_thrift_py_files) |
| 17 | + |
| 18 | +sswitchpydir = $(pythondir)/sswitch_runtime |
| 19 | +nodist_sswitchpy_PYTHON = $(simple_switch_thrift_py_files) |
| 20 | + |
| 21 | +python_PYTHON = sswitch_CLI.py |
| 22 | + |
| 23 | +# See |
| 24 | +# http://www.gnu.org/software/autoconf/manual/autoconf-2.69/html_node/Installation-Directory-Variables.html |
| 25 | +edit = sed \ |
| 26 | + -e 's|@pythondir[@]|$(pythondir)|g' |
| 27 | + |
| 28 | +simple_switch_CLI: Makefile |
| 29 | + rm -f $@ $@.tmp |
| 30 | + $(edit) $(srcdir)/$@.in >$@.tmp |
| 31 | + chmod +x $@.tmp |
| 32 | + chmod a-w $@.tmp |
| 33 | + mv $@.tmp $@ |
| 34 | + |
| 35 | +simple_switch_CLI: simple_switch_CLI.in |
| 36 | + |
| 37 | +EXTRA_DIST = \ |
| 38 | +simple_switch_CLI.in \ |
| 39 | +sswitch_CLI |
| 40 | + |
| 41 | +bin_SCRIPTS = \ |
| 42 | +simple_switch_CLI |
| 43 | + |
| 44 | +AM_CPPFLAGS += \ |
| 45 | +-I$(srcdir)/thrift/src/ \ |
| 46 | +-I$(builddir)/gen-cpp |
| 47 | + |
| 48 | +libsimpleswitch_la_LIBADD = \ |
| 49 | +$(top_builddir)/src/bm_sim/libbmsim.la \ |
| 50 | +$(top_builddir)/src/bf_lpm_trie/libbflpmtrie.la \ |
| 51 | +$(top_builddir)/src/BMI/libbmi.la \ |
| 52 | +$(top_builddir)/third_party/jsoncpp/libjson.la \ |
| 53 | +-lboost_system $(THRIFT_LIB) -lboost_program_options |
| 54 | + |
| 55 | +noinst_LTLIBRARIES = libsimpleswitch.la |
| 56 | + |
| 57 | +libsimpleswitch_la_SOURCES = \ |
| 58 | +simple_switch.cpp simple_switch.h primitives.cpp \ |
| 59 | +thrift/src/SimpleSwitch_server.cpp |
| 60 | + |
| 61 | +bin_PROGRAMS = simple_switch |
| 62 | + |
| 63 | +simple_switch_LDADD = \ |
| 64 | +$(top_builddir)/src/bm_runtime/libbmruntime.la \ |
| 65 | +$(top_builddir)/thrift_src/libruntimestubs.la \ |
| 66 | +libsimpleswitch.la \ |
| 67 | +libsimpleswitch_thrift.la |
| 68 | + |
| 69 | +simple_switch_SOURCES = main.cpp |
| 70 | + |
| 71 | +lib_LTLIBRARIES = libsimpleswitch_thrift.la |
| 72 | + |
| 73 | +nodist_libsimpleswitch_thrift_la_SOURCES = \ |
| 74 | +$(simple_switch_thrift_files) |
| 75 | + |
| 76 | +# See http://www.gnu.org/software/automake/manual/html_node/Multiple-Outputs.html |
| 77 | + |
| 78 | +THRIFT_IDL = $(srcdir)/thrift/simple_switch.thrift |
| 79 | + |
| 80 | +EXTRA_DIST += $(THRIFT_IDL) |
| 81 | + |
| 82 | +# We copy the generated Python code to srcdir/ if we have permissions (i.e. not |
| 83 | +# for 'make distcheck'). This is to ensure we can run the CLI easily. Maybe I |
| 84 | +# will think of a better solution later. |
| 85 | +thrift_files.ts: $(THRIFT_IDL) |
| 86 | + @rm -f thrift_files.tmp |
| 87 | + @touch thrift_files.tmp |
| 88 | + @mkdir -p $(builddir)/gen-cpp/bm |
| 89 | + $(THRIFT) -out $(builddir)/gen-cpp/bm --gen cpp -r $(THRIFT_IDL) |
| 90 | + $(THRIFT) -o $(builddir) --gen py -r $(THRIFT_IDL) |
| 91 | + if mkdir $(srcdir)/sswitch_runtime.test 2>/dev/null; then \ |
| 92 | + rm -rf $(srcdir)/sswitch_runtime/; \ |
| 93 | + cp -r $(builddir)/gen-py/sswitch_runtime/ $(srcdir)/; \ |
| 94 | + rm -rf $(srcdir)/sswitch_runtime.test; else :; \ |
| 95 | + fi |
| 96 | + @mv -f thrift_files.tmp $@ |
| 97 | + |
| 98 | +$(BUILT_SOURCES): thrift_files.ts |
| 99 | +## Recover from the removal of $@ |
| 100 | + @if test -f $@; then :; else \ |
| 101 | + trap 'rm -rf thrift_files.lock thrift_files.ts' 1 2 13 15; \ |
| 102 | +## mkdir is a portable test-and-set |
| 103 | + if mkdir thrift_files.lock 2>/dev/null; then \ |
| 104 | +## This code is being executed by the first process. |
| 105 | + rm -f thrift_files.ts; \ |
| 106 | + $(MAKE) $(AM_MAKEFLAGS) thrift_files.ts; \ |
| 107 | + result=$$?; rm -rf thrift_files.lock; exit $$result; \ |
| 108 | + else \ |
| 109 | +## This code is being executed by the follower processes. |
| 110 | +## Wait until the first process is done. |
| 111 | + while test -d thrift_files.lock; do sleep 1; done; \ |
| 112 | +## Succeed if and only if the first process succeeded. |
| 113 | + test -f thrift_files.ts; \ |
| 114 | + fi; \ |
| 115 | + fi |
| 116 | + |
| 117 | +nodist_pkginclude_HEADERS = \ |
| 118 | +gen-cpp/bm/simple_switch_constants.h \ |
| 119 | +gen-cpp/bm/SimpleSwitch.h \ |
| 120 | +gen-cpp/bm/simple_switch_types.h |
| 121 | + |
| 122 | + |
| 123 | +CLEANFILES = $(BUILT_SOURCES) \ |
| 124 | +thrift_files.ts \ |
| 125 | +gen-cpp/bm/SimpleSwitch_server.skeleton.cpp \ |
| 126 | +$(bin_SCRIPTS) |
| 127 | + |
| 128 | +# I used to do a rm on gen-cpp, but it was removing a .deps directory, instead I |
| 129 | +# am adding the skeleton file to CLEANFILES |
| 130 | +clean-local: |
| 131 | + rm -rf gen-py |
0 commit comments