srikanth | 116e6e8 | 2014-08-19 07:22:37 -0700 | [diff] [blame] | 1 | # |
| 2 | # Copyright (c) 2013 Big Switch Networks, Inc. |
| 3 | # |
| 4 | # Licensed under the Eclipse Public License, Version 1.0 (the |
| 5 | # "License"); you may not use this file except in compliance with the |
| 6 | # License. You may obtain a copy of the License at |
| 7 | # |
| 8 | # http://www.eclipse.org/legal/epl-v10.html |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or |
| 13 | # implied. See the License for the specific language governing |
| 14 | # permissions and limitations under the License. |
| 15 | |
| 16 | SOURCE = $(shell pwd) |
| 17 | WORKSPACE = $(SOURCE)/workspace |
| 18 | VIRTUALENV = $(WORKSPACE)/ve |
| 19 | TOOLS = $(WORKSPACE)/tools |
| 20 | BUILD_DIR = $(SOURCE)/build |
srikanth | de50b09 | 2014-08-19 08:31:46 -0700 | [diff] [blame] | 21 | #FL_DIR = $(SOURCE)/sdnplatform |
srikanth | 116e6e8 | 2014-08-19 07:22:37 -0700 | [diff] [blame] | 22 | |
| 23 | all: build-sdnplatform |
| 24 | |
| 25 | clean-python: |
srikanth | de50b09 | 2014-08-19 08:31:46 -0700 | [diff] [blame] | 26 | # printf 'import setuptools\nsetuptools.setup(name="django_cassandra", version="0.1", packages=["django_cassandra", "django_cassandra.db"])' >$(SOURCE)/django_cassandra_backend/setup.py |
srikanth | 116e6e8 | 2014-08-19 07:22:37 -0700 | [diff] [blame] | 27 | echo '$(SOURCE)' >$$(python -c 'import distutils; print distutils.sysconfig.get_python_lib()')/sdnplatform.pth |
| 28 | set -e; \ |
| 29 | cd $(SOURCE); \ |
srikanth | de50b09 | 2014-08-19 08:31:46 -0700 | [diff] [blame] | 30 | # for p in django_cassandra_backend/setup.py sdncon/setup.py cli/setup.py; do |
| 31 | for p in sdncon/setup.py cli/setup.py; do \ |
srikanth | 116e6e8 | 2014-08-19 07:22:37 -0700 | [diff] [blame] | 32 | echo "+++ Preparing Python virtualenv for $$p"; \ |
| 33 | ( cd $$(dirname $$p); rm -rf *.egg-info; ARCHFLAGS="-arch i386 -arch x86_64" python $$(basename $$p) develop ); \ |
| 34 | done |
| 35 | ( cd $(SOURCE)/cli ; tools/rebuild_model.sh ) |
| 36 | |
| 37 | clean-sdnplatform: |
srikanth | de50b09 | 2014-08-19 08:31:46 -0700 | [diff] [blame] | 38 | # cd $(FL_DIR); ant clean |
srikanth | 116e6e8 | 2014-08-19 07:22:37 -0700 | [diff] [blame] | 39 | |
| 40 | clean: reset-cassandra clean-sdnplatform clean-python |
| 41 | |
| 42 | stop-cassandra: |
srikanth | de50b09 | 2014-08-19 08:31:46 -0700 | [diff] [blame] | 43 | # $(BUILD_DIR)/kill-port-wait.sh -p 9160 |
| 44 | # @echo "+++ Cassandra stopped" |
srikanth | 116e6e8 | 2014-08-19 07:22:37 -0700 | [diff] [blame] | 45 | |
| 46 | reset-cassandra: stop-cassandra |
srikanth | de50b09 | 2014-08-19 08:31:46 -0700 | [diff] [blame] | 47 | # rm -rf $(VIRTUALENV)/cassandra |
| 48 | # @echo "+++ Cassandra db deleted" |
srikanth | 116e6e8 | 2014-08-19 07:22:37 -0700 | [diff] [blame] | 49 | |
| 50 | cassandra: start-cassandra |
| 51 | start-cassandra: |
srikanth | de50b09 | 2014-08-19 08:31:46 -0700 | [diff] [blame] | 52 | # $(BUILD_DIR)/start-and-wait-for-port.sh -p 9160 -l $(VIRTUALENV)/log/cassandra.log $(TOOLS)/cassandra/bin/cassandra |
| 53 | # @echo "+++ Cassandra running" |
srikanth | 116e6e8 | 2014-08-19 07:22:37 -0700 | [diff] [blame] | 54 | |
| 55 | stop-sdncon: |
| 56 | $(BUILD_DIR)/kill-port-wait.sh -p 8000 |
| 57 | @echo "+++ sdncon stopped" |
| 58 | |
| 59 | reset-sdncon: stop-sdncon reset-cassandra start-cassandra |
| 60 | |
| 61 | start-sdncon: start-cassandra |
| 62 | if ! lsof -iTCP:8000 -sTCP:LISTEN >/dev/null; then \ |
| 63 | ( \ |
| 64 | cd $(SOURCE)/sdncon; \ |
| 65 | [ -d $(VIRTUALENV)/cassandra/data/sdncon ] || python manage.py syncdb --noinput; \ |
| 66 | $(BUILD_DIR)/start-and-wait-for-port.sh -p 8000 -l $(VIRTUALENV)/log/sdncon.log python manage.py runserver 0.0.0.0:8000; \ |
| 67 | ); \ |
| 68 | fi |
| 69 | @echo "+++ sdncon running" |
| 70 | |
| 71 | stop-sdnplatform: |
srikanth | de50b09 | 2014-08-19 08:31:46 -0700 | [diff] [blame] | 72 | # while pid=$$(lsof -t -iTCP:6633 -sTCP:LISTEN); do kill $${pid}; sleep 1; done |
| 73 | # @echo "+++ SDN Platform stopped" |
srikanth | 116e6e8 | 2014-08-19 07:22:37 -0700 | [diff] [blame] | 74 | |
| 75 | start-sdnplatform: start-cassandra |
srikanth | de50b09 | 2014-08-19 08:31:46 -0700 | [diff] [blame] | 76 | # if ! lsof -iTCP:6633 -sTCP:LISTEN >/dev/null; then \ |
| 77 | # ( cd $(SOURCE)/sdnplatform; ant run &>$(VIRTUALENV)/log/sdnplatform.log & ); \ |
| 78 | # fi |
| 79 | # while ! nc -z localhost 6633; do sleep 1; done |
| 80 | # @echo "+++ SDN Platform running" |
srikanth | 116e6e8 | 2014-08-19 07:22:37 -0700 | [diff] [blame] | 81 | |
| 82 | eclipse: |
srikanth | de50b09 | 2014-08-19 08:31:46 -0700 | [diff] [blame] | 83 | # cd $(FL_DIR); ant eclipse |
srikanth | 116e6e8 | 2014-08-19 07:22:37 -0700 | [diff] [blame] | 84 | |
| 85 | build-sdnplatform: |
srikanth | de50b09 | 2014-08-19 08:31:46 -0700 | [diff] [blame] | 86 | # cd $(FL_DIR); ant dist |