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 |
| 10 | |
| 11 | PYLIBOF_DIR = ${TOOLS_DIR}/pylibopenflow |
| 12 | |
| 13 | TARGET_DIR = ${TOP_DIR}/src/python/oftest/ofmsg |
| 14 | |
| 15 | # Relative to pyopenflow-pythonize exec location |
| 16 | OF_HEADER = include/openflow.h |
| 17 | |
| 18 | # Relative to here |
| 19 | ABS_OF_HEADER = ${PYLIBOF_DIR}/${OF_HEADER} |
| 20 | |
| 21 | PYTHONIZE = bin/pyopenflow-pythonize.py |
| 22 | OFP_GEN_CMD = (cd ${PYLIBOF_DIR} && ${PYTHONIZE} -i ${OF_HEADER} \ |
| 23 | ${TARGET_DIR}/ofp.py) |
| 24 | |
| 25 | # Dependencies for ofp.py |
| 26 | OFP_DEP = ${ABS_OF_HEADER} $(wildcard ${PYLIBOF_DIR}/pylib/*.py) |
| 27 | OFP_DEP = $(wildcard ${PYLIBOF_DIR}/pylib/of/*.py) |
| 28 | |
| 29 | # FIXME: There are three types of .py files: |
| 30 | # ofp.py from pylibopenflow output |
| 31 | # %.py generated from %_gen.py |
| 32 | # of_message.py and action_list.py -- hand built, already in src dir |
| 33 | |
| 34 | GEN_FILES := $(addprefix ${TARGET_DIR}/,ofp.py message.py error.py action.py) |
| 35 | OTHER_FILES := $(addprefix ${TARGET_DIR}/,action_list.py of_message.py) |
| 36 | LINT_SOURCE := ${GEN_FILES} ${OTHER_FILES} |
| 37 | LINT_FILES := $(subst .py,.log,${LINT_SOURCE}) |
| 38 | LINT_FILES := $(subst ${TARGET_DIR}/,lint/,${LINT_FILES}) |
| 39 | |
| 40 | all: ${GEN_FILES} |
| 41 | @echo "Generated files" |
| 42 | |
| 43 | ${TARGET_DIR}/ofp.py: ${OFP_DEP} |
| 44 | ${OFP_GEN_CMD} |
| 45 | |
| 46 | # General rule like src/message.py comes from scripts/message_gen.py |
| 47 | ${TARGET_DIR}/%.py: scripts/%_gen.py ${TARGET_DIR}/ofp.py |
| 48 | python $< > $@ |
| 49 | |
| 50 | lint/%.log: ${TARGET_DIR}/%.py |
| 51 | (cd ${TARGET_DIR} && pylint -e $(notdir $<)) > $@ |
| 52 | |
| 53 | lint: ${LINT_FILES} |
| 54 | |
| 55 | # For now. just local source doc generated |
| 56 | doc: ${GEN_FILES} ${OTHER_FILES} ${DOC_DIR}/Doxyfile |
| 57 | (cd ${DOC_DIR} && doxygen) |
| 58 | |
| 59 | clean: |
| 60 | rm -rf ${GEN_FILES} ${LINT_FILES} ${DOC_DIR}/html/* |
| 61 | |
| 62 | help: |
| 63 | @echo |
| 64 | @echo Makefile for oftest source munger |
| 65 | @echo Default builds python files and installs in ${TARGET_DIR} |
| 66 | @echo make local: Generate files and put in src/ |
| 67 | @echo |
| 68 | @echo Debug info: |
| 69 | @echo |
| 70 | @echo Files generated GEN_FILES: ${GEN_FILES} |
| 71 | @echo |
| 72 | @echo Dependencies for ofp.py OFP_DEP: ${OFP_DEP} |
| 73 | @echo |
| 74 | @echo Already created files OTHER_FILES: ${OTHER_FILES} |
| 75 | @echo |
| 76 | @echo LINT_FILES: ${LINT_FILES} |
| 77 | |
| 78 | |
| 79 | .PHONY: all local install help doc lint clean |