blob: 0e40e4ee8628be77f5ef9713682bcb4ab048e3d7 [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 Talaycob9cb5482010-02-09 15:23:12 -080013TARGET_DIR = ${TOP_DIR}/src/python/oftest/protocol
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 Talaycob9cb5482010-02-09 15:23:12 -080031GEN_FILES := $(addprefix ${TARGET_DIR}/,cstruct.py message.py error.py action.py)
32OTHER_FILES := $(addprefix ${TARGET_DIR}/,action_list.py parse.py)
Dan Talaycof75360a2010-02-05 22:22:54 -080033LINT_SOURCE := ${GEN_FILES} ${OTHER_FILES}
34LINT_FILES := $(subst .py,.log,${LINT_SOURCE})
35LINT_FILES := $(subst ${TARGET_DIR}/,lint/,${LINT_FILES})
36
37all: ${GEN_FILES}
Dan Talaycof75360a2010-02-05 22:22:54 -080038
Dan Talaycoac1cb812010-02-06 20:34:18 -080039# The core OpenFlow libraries generated from openflow.h
Dan Talaycob9cb5482010-02-09 15:23:12 -080040${TARGET_DIR}/cstruct.py: ${CSTRUCT_DEP}
41 ${CSTRUCT_GEN_CMD} > ${CSTRUCT_AUX_INFO}
Dan Talaycof75360a2010-02-05 22:22:54 -080042
43# General rule like src/message.py comes from scripts/message_gen.py
Dan Talaycob9cb5482010-02-09 15:23:12 -080044${TARGET_DIR}/%.py: scripts/%_gen.py ${TARGET_DIR}/cstruct.py
Dan Talaycof75360a2010-02-05 22:22:54 -080045 python $< > $@
46
Dan Talaycoac1cb812010-02-06 20:34:18 -080047# The pylint files
Dan Talaycof75360a2010-02-05 22:22:54 -080048lint/%.log: ${TARGET_DIR}/%.py
49 (cd ${TARGET_DIR} && pylint -e $(notdir $<)) > $@
50
51lint: ${LINT_FILES}
52
53# For now. just local source doc generated
54doc: ${GEN_FILES} ${OTHER_FILES} ${DOC_DIR}/Doxyfile
55 (cd ${DOC_DIR} && doxygen)
56
57clean:
58 rm -rf ${GEN_FILES} ${LINT_FILES} ${DOC_DIR}/html/*
59
Dan Talaycoc85e97e2010-02-07 22:59:04 -080060test: all
61 (cd tests && python msg_test.py) > tests/msg_test.log
62
Dan Talaycof75360a2010-02-05 22:22:54 -080063help:
64 @echo
Dan Talayco8176c912010-02-05 22:27:55 -080065 @echo "Makefile for oftest source munger"
66 @echo " Default builds python files and installs in ${TARGET_DIR}"
67 @echo " make local: Generate files and put in src/"
Dan Talaycof75360a2010-02-05 22:22:54 -080068 @echo
Dan Talayco8176c912010-02-05 22:27:55 -080069 @echo "Targets:"
70 @echo " all: Puts generated .py in ${TARGET_DIR}"
71 @echo " lint: Puts error report in lint/*.log"
72 @echo " doc: Runs doxygen on generated files in ../../doc"
73 @echo " clean: Removes generated files"
Dan Talaycof75360a2010-02-05 22:22:54 -080074 @echo
Dan Talayco8176c912010-02-05 22:27:55 -080075 @echo "Debug info:"
Dan Talaycof75360a2010-02-05 22:22:54 -080076 @echo
Dan Talayco8176c912010-02-05 22:27:55 -080077 @echo "Files generated GEN_FILES: ${GEN_FILES}"
Dan Talaycof75360a2010-02-05 22:22:54 -080078 @echo
Dan Talaycob9cb5482010-02-09 15:23:12 -080079 @echo "Dependencies for cstruct.py CSTRUCT_DEP: ${CSTRUCT_DEP}"
Dan Talaycof75360a2010-02-05 22:22:54 -080080 @echo
Dan Talayco8176c912010-02-05 22:27:55 -080081 @echo "Already created files OTHER_FILES: ${OTHER_FILES}"
82 @echo
83 @echo "LINT_FILES: ${LINT_FILES}"
Dan Talaycof75360a2010-02-05 22:22:54 -080084
85
Dan Talaycoc85e97e2010-02-07 22:59:04 -080086.PHONY: all local install help doc lint clean test