blob: 31f34231d4808ef286d3004643d15434ce539406 [file] [log] [blame]
Dan Talaycof75360a2010-02-05 22:22:54 -08001#
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
7TOP_DIR = ../..
8TOOLS_DIR = ..
9DOC_DIR = ${TOP_DIR}/doc
Dan Talayco48370102010-03-03 15:17:33 -080010TESTS_DIR = ${TOP_DIR}/tests
Dan Talaycof75360a2010-02-05 22:22:54 -080011
12PYLIBOF_DIR = ${TOOLS_DIR}/pylibopenflow
13
Dan Talaycod7e2dbe2010-02-13 21:51:15 -080014TARGET_DIR = ${TOP_DIR}/src/python/oftest
Dan Talayco673e0852010-03-06 23:09:23 -080015SETUP_DIR = ${TOP_DIR}/src/python/
Dan Talaycof75360a2010-02-05 22:22:54 -080016
17# Relative to pyopenflow-pythonize exec location
18OF_HEADER = include/openflow.h
19
20# Relative to here
21ABS_OF_HEADER = ${PYLIBOF_DIR}/${OF_HEADER}
22
23PYTHONIZE = bin/pyopenflow-pythonize.py
Dan Talaycob9cb5482010-02-09 15:23:12 -080024CSTRUCT_GEN_CMD = (cd ${PYLIBOF_DIR} && ${PYTHONIZE} -i ${OF_HEADER} \
25 ${TARGET_DIR}/cstruct.py)
26CSTRUCT_AUX_INFO = ${TARGET_DIR}/class_maps.py
Dan Talaycof75360a2010-02-05 22:22:54 -080027
Dan Talaycob9cb5482010-02-09 15:23:12 -080028# Dependencies for cstruct.py
29CSTRUCT_DEP = ${ABS_OF_HEADER} $(wildcard ${PYLIBOF_DIR}/pylib/*.py)
30CSTRUCT_DEP += $(wildcard ${PYLIBOF_DIR}/pylib/of/*.py)
Dan Talaycof75360a2010-02-05 22:22:54 -080031
Dan Talaycoac1cb812010-02-06 20:34:18 -080032# Generated and other files
Dan Talayco9e11c132010-02-19 11:43:11 -080033GEN_FILES := $(addprefix ${TARGET_DIR}/,cstruct.py message.py error.py \
34 action.py)
35# class_maps is generated as a side effect of cstruct....
Dan Talaycoe226eb12010-02-18 23:06:30 -080036OTHER_FILES := $(addprefix ${TARGET_DIR}/,action_list.py parse.py \
Dan Talayco9e11c132010-02-19 11:43:11 -080037 controller.py dataplane.py class_maps.py)
Dan Talaycof75360a2010-02-05 22:22:54 -080038LINT_SOURCE := ${GEN_FILES} ${OTHER_FILES}
39LINT_FILES := $(subst .py,.log,${LINT_SOURCE})
40LINT_FILES := $(subst ${TARGET_DIR}/,lint/,${LINT_FILES})
41
42all: ${GEN_FILES}
Dan Talaycof75360a2010-02-05 22:22:54 -080043
Dan Talayco673e0852010-03-06 23:09:23 -080044install: all
45 (cd ${SETUP_DIR} && sudo python setup.py install)
46
Dan Talaycoac1cb812010-02-06 20:34:18 -080047# The core OpenFlow libraries generated from openflow.h
Dan Talaycob9cb5482010-02-09 15:23:12 -080048${TARGET_DIR}/cstruct.py: ${CSTRUCT_DEP}
49 ${CSTRUCT_GEN_CMD} > ${CSTRUCT_AUX_INFO}
Dan Talaycof75360a2010-02-05 22:22:54 -080050
51# General rule like src/message.py comes from scripts/message_gen.py
Dan Talaycob9cb5482010-02-09 15:23:12 -080052${TARGET_DIR}/%.py: scripts/%_gen.py ${TARGET_DIR}/cstruct.py
Dan Talaycof75360a2010-02-05 22:22:54 -080053 python $< > $@
54
Dan Talaycoac1cb812010-02-06 20:34:18 -080055# The pylint files
Dan Talaycof75360a2010-02-05 22:22:54 -080056lint/%.log: ${TARGET_DIR}/%.py
Dan Talayco9b591892010-02-09 15:28:29 -080057 mkdir -p lint
Dan Talaycof75360a2010-02-05 22:22:54 -080058 (cd ${TARGET_DIR} && pylint -e $(notdir $<)) > $@
59
Dan Talaycod7e2dbe2010-02-13 21:51:15 -080060# Note that lint has issues with scapy syntax
Dan Talaycof75360a2010-02-05 22:22:54 -080061lint: ${LINT_FILES}
62
Dan Talayco48370102010-03-03 15:17:33 -080063${TESTS_DIR}/oft.py:
64 ln -s oft $@
65
Dan Talaycof75360a2010-02-05 22:22:54 -080066# For now. just local source doc generated
Dan Talayco48370102010-03-03 15:17:33 -080067doc: ${GEN_FILES} ${OTHER_FILES} ${DOC_DIR}/Doxyfile ${TESTS_DIR}/oft.py
Dan Talaycof75360a2010-02-05 22:22:54 -080068 (cd ${DOC_DIR} && doxygen)
69
70clean:
71 rm -rf ${GEN_FILES} ${LINT_FILES} ${DOC_DIR}/html/*
72
Dan Talaycoc85e97e2010-02-07 22:59:04 -080073test: all
74 (cd tests && python msg_test.py) > tests/msg_test.log
75
Dan Talaycof75360a2010-02-05 22:22:54 -080076help:
77 @echo
Dan Talayco8176c912010-02-05 22:27:55 -080078 @echo "Makefile for oftest source munger"
79 @echo " Default builds python files and installs in ${TARGET_DIR}"
80 @echo " make local: Generate files and put in src/"
Dan Talaycof75360a2010-02-05 22:22:54 -080081 @echo
Dan Talayco8176c912010-02-05 22:27:55 -080082 @echo "Targets:"
Dan Talayco673e0852010-03-06 23:09:23 -080083 @echo " all: Puts generated .py in ${TARGET_DIR}"
84 @echo " lint: Puts error report in lint/*.log"
85 @echo " doc: Runs doxygen on generated files in ../../doc"
86 @echo " install: Run setup tools for generated python source"
87 @echo " clean: Removes generated files"
Dan Talaycof75360a2010-02-05 22:22:54 -080088 @echo
Dan Talayco8176c912010-02-05 22:27:55 -080089 @echo "Debug info:"
Dan Talaycof75360a2010-02-05 22:22:54 -080090 @echo
Dan Talayco8176c912010-02-05 22:27:55 -080091 @echo "Files generated GEN_FILES: ${GEN_FILES}"
Dan Talaycof75360a2010-02-05 22:22:54 -080092 @echo
Dan Talaycob9cb5482010-02-09 15:23:12 -080093 @echo "Dependencies for cstruct.py CSTRUCT_DEP: ${CSTRUCT_DEP}"
Dan Talaycof75360a2010-02-05 22:22:54 -080094 @echo
Dan Talayco8176c912010-02-05 22:27:55 -080095 @echo "Already created files OTHER_FILES: ${OTHER_FILES}"
96 @echo
97 @echo "LINT_FILES: ${LINT_FILES}"
Dan Talaycof75360a2010-02-05 22:22:54 -080098
99
Dan Talaycoc85e97e2010-02-07 22:59:04 -0800100.PHONY: all local install help doc lint clean test