Dan Talayco | f75360a | 2010-02-05 22:22:54 -0800 | [diff] [blame] | 1 | # |
| 2 | # Simple make file to generate OpenFlow python files |
| 3 | # |
| 4 | # Fixme: Would like pylibopenflow to be able to run remotely |
| 5 | # Currently, we have to cd to it's dir and refer back to local |
| 6 | |
| 7 | TOP_DIR = ../.. |
| 8 | TOOLS_DIR = .. |
| 9 | DOC_DIR = ${TOP_DIR}/doc |
Dan Talayco | 4837010 | 2010-03-03 15:17:33 -0800 | [diff] [blame] | 10 | TESTS_DIR = ${TOP_DIR}/tests |
Dan Talayco | f75360a | 2010-02-05 22:22:54 -0800 | [diff] [blame] | 11 | |
| 12 | PYLIBOF_DIR = ${TOOLS_DIR}/pylibopenflow |
| 13 | |
Rich Lane | 6242d9f | 2013-01-06 17:35:39 -0800 | [diff] [blame] | 14 | TARGET_DIR = ${TOP_DIR}/src/python/of10 |
Dan Talayco | f75360a | 2010-02-05 22:22:54 -0800 | [diff] [blame] | 15 | |
| 16 | # Relative to pyopenflow-pythonize exec location |
| 17 | OF_HEADER = include/openflow.h |
| 18 | |
| 19 | # Relative to here |
| 20 | ABS_OF_HEADER = ${PYLIBOF_DIR}/${OF_HEADER} |
| 21 | |
| 22 | PYTHONIZE = bin/pyopenflow-pythonize.py |
Dan Talayco | b9cb548 | 2010-02-09 15:23:12 -0800 | [diff] [blame] | 23 | CSTRUCT_GEN_CMD = (cd ${PYLIBOF_DIR} && ${PYTHONIZE} -i ${OF_HEADER} \ |
| 24 | ${TARGET_DIR}/cstruct.py) |
| 25 | CSTRUCT_AUX_INFO = ${TARGET_DIR}/class_maps.py |
Dan Talayco | f75360a | 2010-02-05 22:22:54 -0800 | [diff] [blame] | 26 | |
Dan Talayco | b9cb548 | 2010-02-09 15:23:12 -0800 | [diff] [blame] | 27 | # Dependencies for cstruct.py |
| 28 | CSTRUCT_DEP = ${ABS_OF_HEADER} $(wildcard ${PYLIBOF_DIR}/pylib/*.py) |
| 29 | CSTRUCT_DEP += $(wildcard ${PYLIBOF_DIR}/pylib/of/*.py) |
Dan Talayco | f75360a | 2010-02-05 22:22:54 -0800 | [diff] [blame] | 30 | |
Dan Talayco | ac1cb81 | 2010-02-06 20:34:18 -0800 | [diff] [blame] | 31 | # Generated and other files |
Dan Talayco | 9e11c13 | 2010-02-19 11:43:11 -0800 | [diff] [blame] | 32 | GEN_FILES := $(addprefix ${TARGET_DIR}/,cstruct.py message.py error.py \ |
| 33 | action.py) |
| 34 | # class_maps is generated as a side effect of cstruct.... |
Dan Talayco | e226eb1 | 2010-02-18 23:06:30 -0800 | [diff] [blame] | 35 | OTHER_FILES := $(addprefix ${TARGET_DIR}/,action_list.py parse.py \ |
Dan Talayco | 9e11c13 | 2010-02-19 11:43:11 -0800 | [diff] [blame] | 36 | controller.py dataplane.py class_maps.py) |
Dan Talayco | f75360a | 2010-02-05 22:22:54 -0800 | [diff] [blame] | 37 | LINT_SOURCE := ${GEN_FILES} ${OTHER_FILES} |
| 38 | LINT_FILES := $(subst .py,.log,${LINT_SOURCE}) |
| 39 | LINT_FILES := $(subst ${TARGET_DIR}/,lint/,${LINT_FILES}) |
| 40 | |
| 41 | all: ${GEN_FILES} |
Dan Talayco | f75360a | 2010-02-05 22:22:54 -0800 | [diff] [blame] | 42 | |
Rich Lane | 122ca36 | 2012-10-05 08:06:02 -0700 | [diff] [blame] | 43 | install: all |
| 44 | |
Dan Talayco | ac1cb81 | 2010-02-06 20:34:18 -0800 | [diff] [blame] | 45 | # The core OpenFlow libraries generated from openflow.h |
Dan Talayco | b9cb548 | 2010-02-09 15:23:12 -0800 | [diff] [blame] | 46 | ${TARGET_DIR}/cstruct.py: ${CSTRUCT_DEP} |
| 47 | ${CSTRUCT_GEN_CMD} > ${CSTRUCT_AUX_INFO} |
Dan Talayco | f75360a | 2010-02-05 22:22:54 -0800 | [diff] [blame] | 48 | |
| 49 | # General rule like src/message.py comes from scripts/message_gen.py |
Dan Talayco | b9cb548 | 2010-02-09 15:23:12 -0800 | [diff] [blame] | 50 | ${TARGET_DIR}/%.py: scripts/%_gen.py ${TARGET_DIR}/cstruct.py |
Dan Talayco | f75360a | 2010-02-05 22:22:54 -0800 | [diff] [blame] | 51 | python $< > $@ |
| 52 | |
Dan Talayco | ac1cb81 | 2010-02-06 20:34:18 -0800 | [diff] [blame] | 53 | # The pylint files |
Dan Talayco | f75360a | 2010-02-05 22:22:54 -0800 | [diff] [blame] | 54 | lint/%.log: ${TARGET_DIR}/%.py |
Dan Talayco | 9b59189 | 2010-02-09 15:28:29 -0800 | [diff] [blame] | 55 | mkdir -p lint |
Dan Talayco | f75360a | 2010-02-05 22:22:54 -0800 | [diff] [blame] | 56 | (cd ${TARGET_DIR} && pylint -e $(notdir $<)) > $@ |
| 57 | |
Dan Talayco | d7e2dbe | 2010-02-13 21:51:15 -0800 | [diff] [blame] | 58 | # Note that lint has issues with scapy syntax |
Dan Talayco | f75360a | 2010-02-05 22:22:54 -0800 | [diff] [blame] | 59 | lint: ${LINT_FILES} |
| 60 | |
Dan Talayco | 4837010 | 2010-03-03 15:17:33 -0800 | [diff] [blame] | 61 | ${TESTS_DIR}/oft.py: |
| 62 | ln -s oft $@ |
| 63 | |
Dan Talayco | f75360a | 2010-02-05 22:22:54 -0800 | [diff] [blame] | 64 | # For now. just local source doc generated |
Dan Talayco | 4837010 | 2010-03-03 15:17:33 -0800 | [diff] [blame] | 65 | doc: ${GEN_FILES} ${OTHER_FILES} ${DOC_DIR}/Doxyfile ${TESTS_DIR}/oft.py |
Dan Talayco | f75360a | 2010-02-05 22:22:54 -0800 | [diff] [blame] | 66 | (cd ${DOC_DIR} && doxygen) |
| 67 | |
| 68 | clean: |
| 69 | rm -rf ${GEN_FILES} ${LINT_FILES} ${DOC_DIR}/html/* |
| 70 | |
Dan Talayco | c85e97e | 2010-02-07 22:59:04 -0800 | [diff] [blame] | 71 | test: all |
| 72 | (cd tests && python msg_test.py) > tests/msg_test.log |
| 73 | |
Dan Talayco | f75360a | 2010-02-05 22:22:54 -0800 | [diff] [blame] | 74 | help: |
| 75 | @echo |
Dan Talayco | 8176c91 | 2010-02-05 22:27:55 -0800 | [diff] [blame] | 76 | @echo "Makefile for oftest source munger" |
| 77 | @echo " Default builds python files and installs in ${TARGET_DIR}" |
| 78 | @echo " make local: Generate files and put in src/" |
Dan Talayco | f75360a | 2010-02-05 22:22:54 -0800 | [diff] [blame] | 79 | @echo |
Dan Talayco | 8176c91 | 2010-02-05 22:27:55 -0800 | [diff] [blame] | 80 | @echo "Targets:" |
Dan Talayco | 673e085 | 2010-03-06 23:09:23 -0800 | [diff] [blame] | 81 | @echo " all: Puts generated .py in ${TARGET_DIR}" |
| 82 | @echo " lint: Puts error report in lint/*.log" |
| 83 | @echo " doc: Runs doxygen on generated files in ../../doc" |
Dan Talayco | 673e085 | 2010-03-06 23:09:23 -0800 | [diff] [blame] | 84 | @echo " clean: Removes generated files" |
Dan Talayco | f75360a | 2010-02-05 22:22:54 -0800 | [diff] [blame] | 85 | @echo |
Dan Talayco | 8176c91 | 2010-02-05 22:27:55 -0800 | [diff] [blame] | 86 | @echo "Debug info:" |
Dan Talayco | f75360a | 2010-02-05 22:22:54 -0800 | [diff] [blame] | 87 | @echo |
Dan Talayco | 8176c91 | 2010-02-05 22:27:55 -0800 | [diff] [blame] | 88 | @echo "Files generated GEN_FILES: ${GEN_FILES}" |
Dan Talayco | f75360a | 2010-02-05 22:22:54 -0800 | [diff] [blame] | 89 | @echo |
Dan Talayco | b9cb548 | 2010-02-09 15:23:12 -0800 | [diff] [blame] | 90 | @echo "Dependencies for cstruct.py CSTRUCT_DEP: ${CSTRUCT_DEP}" |
Dan Talayco | f75360a | 2010-02-05 22:22:54 -0800 | [diff] [blame] | 91 | @echo |
Dan Talayco | 8176c91 | 2010-02-05 22:27:55 -0800 | [diff] [blame] | 92 | @echo "Already created files OTHER_FILES: ${OTHER_FILES}" |
| 93 | @echo |
| 94 | @echo "LINT_FILES: ${LINT_FILES}" |
Dan Talayco | f75360a | 2010-02-05 22:22:54 -0800 | [diff] [blame] | 95 | |
| 96 | |
Dan Talayco | c85e97e | 2010-02-07 22:59:04 -0800 | [diff] [blame] | 97 | .PHONY: all local install help doc lint clean test |