blob: 9d2ad53df22c6d1c452e74994b6c5f8dfe5ebbc6 [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
10
11PYLIBOF_DIR = ${TOOLS_DIR}/pylibopenflow
12
Dan Talaycod7e2dbe2010-02-13 21:51:15 -080013TARGET_DIR = ${TOP_DIR}/src/python/oftest
Dan Talaycof75360a2010-02-05 22:22:54 -080014
15# Relative to pyopenflow-pythonize exec location
16OF_HEADER = include/openflow.h
17
18# Relative to here
19ABS_OF_HEADER = ${PYLIBOF_DIR}/${OF_HEADER}
20
21PYTHONIZE = bin/pyopenflow-pythonize.py
Dan Talaycob9cb5482010-02-09 15:23:12 -080022CSTRUCT_GEN_CMD = (cd ${PYLIBOF_DIR} && ${PYTHONIZE} -i ${OF_HEADER} \
23 ${TARGET_DIR}/cstruct.py)
24CSTRUCT_AUX_INFO = ${TARGET_DIR}/class_maps.py
Dan Talaycof75360a2010-02-05 22:22:54 -080025
Dan Talaycob9cb5482010-02-09 15:23:12 -080026# Dependencies for cstruct.py
27CSTRUCT_DEP = ${ABS_OF_HEADER} $(wildcard ${PYLIBOF_DIR}/pylib/*.py)
28CSTRUCT_DEP += $(wildcard ${PYLIBOF_DIR}/pylib/of/*.py)
Dan Talaycof75360a2010-02-05 22:22:54 -080029
Dan Talaycoac1cb812010-02-06 20:34:18 -080030# Generated and other files
Dan Talayco9e11c132010-02-19 11:43:11 -080031GEN_FILES := $(addprefix ${TARGET_DIR}/,cstruct.py message.py error.py \
32 action.py)
33# class_maps is generated as a side effect of cstruct....
Dan Talaycoe226eb12010-02-18 23:06:30 -080034OTHER_FILES := $(addprefix ${TARGET_DIR}/,action_list.py parse.py \
Dan Talayco9e11c132010-02-19 11:43:11 -080035 controller.py dataplane.py class_maps.py)
Dan Talaycof75360a2010-02-05 22:22:54 -080036LINT_SOURCE := ${GEN_FILES} ${OTHER_FILES}
37LINT_FILES := $(subst .py,.log,${LINT_SOURCE})
38LINT_FILES := $(subst ${TARGET_DIR}/,lint/,${LINT_FILES})
39
40all: ${GEN_FILES}
Dan Talaycof75360a2010-02-05 22:22:54 -080041
Dan Talaycoac1cb812010-02-06 20:34:18 -080042# The core OpenFlow libraries generated from openflow.h
Dan Talaycob9cb5482010-02-09 15:23:12 -080043${TARGET_DIR}/cstruct.py: ${CSTRUCT_DEP}
44 ${CSTRUCT_GEN_CMD} > ${CSTRUCT_AUX_INFO}
Dan Talaycof75360a2010-02-05 22:22:54 -080045
46# General rule like src/message.py comes from scripts/message_gen.py
Dan Talaycob9cb5482010-02-09 15:23:12 -080047${TARGET_DIR}/%.py: scripts/%_gen.py ${TARGET_DIR}/cstruct.py
Dan Talaycof75360a2010-02-05 22:22:54 -080048 python $< > $@
49
Dan Talaycoac1cb812010-02-06 20:34:18 -080050# The pylint files
Dan Talaycof75360a2010-02-05 22:22:54 -080051lint/%.log: ${TARGET_DIR}/%.py
Dan Talayco9b591892010-02-09 15:28:29 -080052 mkdir -p lint
Dan Talaycof75360a2010-02-05 22:22:54 -080053 (cd ${TARGET_DIR} && pylint -e $(notdir $<)) > $@
54
Dan Talaycod7e2dbe2010-02-13 21:51:15 -080055# Note that lint has issues with scapy syntax
Dan Talaycof75360a2010-02-05 22:22:54 -080056lint: ${LINT_FILES}
57
58# For now. just local source doc generated
59doc: ${GEN_FILES} ${OTHER_FILES} ${DOC_DIR}/Doxyfile
60 (cd ${DOC_DIR} && doxygen)
61
62clean:
63 rm -rf ${GEN_FILES} ${LINT_FILES} ${DOC_DIR}/html/*
64
Dan Talaycoc85e97e2010-02-07 22:59:04 -080065test: all
66 (cd tests && python msg_test.py) > tests/msg_test.log
67
Dan Talaycof75360a2010-02-05 22:22:54 -080068help:
69 @echo
Dan Talayco8176c912010-02-05 22:27:55 -080070 @echo "Makefile for oftest source munger"
71 @echo " Default builds python files and installs in ${TARGET_DIR}"
72 @echo " make local: Generate files and put in src/"
Dan Talaycof75360a2010-02-05 22:22:54 -080073 @echo
Dan Talayco8176c912010-02-05 22:27:55 -080074 @echo "Targets:"
75 @echo " all: Puts generated .py in ${TARGET_DIR}"
76 @echo " lint: Puts error report in lint/*.log"
77 @echo " doc: Runs doxygen on generated files in ../../doc"
78 @echo " clean: Removes generated files"
Dan Talaycof75360a2010-02-05 22:22:54 -080079 @echo
Dan Talayco8176c912010-02-05 22:27:55 -080080 @echo "Debug info:"
Dan Talaycof75360a2010-02-05 22:22:54 -080081 @echo
Dan Talayco8176c912010-02-05 22:27:55 -080082 @echo "Files generated GEN_FILES: ${GEN_FILES}"
Dan Talaycof75360a2010-02-05 22:22:54 -080083 @echo
Dan Talaycob9cb5482010-02-09 15:23:12 -080084 @echo "Dependencies for cstruct.py CSTRUCT_DEP: ${CSTRUCT_DEP}"
Dan Talaycof75360a2010-02-05 22:22:54 -080085 @echo
Dan Talayco8176c912010-02-05 22:27:55 -080086 @echo "Already created files OTHER_FILES: ${OTHER_FILES}"
87 @echo
88 @echo "LINT_FILES: ${LINT_FILES}"
Dan Talaycof75360a2010-02-05 22:22:54 -080089
90
Dan Talaycoc85e97e2010-02-07 22:59:04 -080091.PHONY: all local install help doc lint clean test