blob: aa7394c279c01b7e4df90ee172ac77dd6fa8805b [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
13TARGET_DIR = ${TOP_DIR}/src/python/oftest/ofmsg
14
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
22OFP_GEN_CMD = (cd ${PYLIBOF_DIR} && ${PYTHONIZE} -i ${OF_HEADER} \
23 ${TARGET_DIR}/ofp.py)
24
25# Dependencies for ofp.py
26OFP_DEP = ${ABS_OF_HEADER} $(wildcard ${PYLIBOF_DIR}/pylib/*.py)
27OFP_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
34GEN_FILES := $(addprefix ${TARGET_DIR}/,ofp.py message.py error.py action.py)
35OTHER_FILES := $(addprefix ${TARGET_DIR}/,action_list.py of_message.py)
36LINT_SOURCE := ${GEN_FILES} ${OTHER_FILES}
37LINT_FILES := $(subst .py,.log,${LINT_SOURCE})
38LINT_FILES := $(subst ${TARGET_DIR}/,lint/,${LINT_FILES})
39
40all: ${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
50lint/%.log: ${TARGET_DIR}/%.py
51 (cd ${TARGET_DIR} && pylint -e $(notdir $<)) > $@
52
53lint: ${LINT_FILES}
54
55# For now. just local source doc generated
56doc: ${GEN_FILES} ${OTHER_FILES} ${DOC_DIR}/Doxyfile
57 (cd ${DOC_DIR} && doxygen)
58
59clean:
60 rm -rf ${GEN_FILES} ${LINT_FILES} ${DOC_DIR}/html/*
61
62help:
63 @echo
Dan Talayco8176c912010-02-05 22:27:55 -080064 @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/"
Dan Talaycof75360a2010-02-05 22:22:54 -080067 @echo
Dan Talayco8176c912010-02-05 22:27:55 -080068 @echo "Targets:"
69 @echo " all: Puts generated .py in ${TARGET_DIR}"
70 @echo " lint: Puts error report in lint/*.log"
71 @echo " doc: Runs doxygen on generated files in ../../doc"
72 @echo " clean: Removes generated files"
Dan Talaycof75360a2010-02-05 22:22:54 -080073 @echo
Dan Talayco8176c912010-02-05 22:27:55 -080074 @echo "Debug info:"
Dan Talaycof75360a2010-02-05 22:22:54 -080075 @echo
Dan Talayco8176c912010-02-05 22:27:55 -080076 @echo "Files generated GEN_FILES: ${GEN_FILES}"
Dan Talaycof75360a2010-02-05 22:22:54 -080077 @echo
Dan Talayco8176c912010-02-05 22:27:55 -080078 @echo "Dependencies for ofp.py OFP_DEP: ${OFP_DEP}"
Dan Talaycof75360a2010-02-05 22:22:54 -080079 @echo
Dan Talayco8176c912010-02-05 22:27:55 -080080 @echo "Already created files OTHER_FILES: ${OTHER_FILES}"
81 @echo
82 @echo "LINT_FILES: ${LINT_FILES}"
Dan Talaycof75360a2010-02-05 22:22:54 -080083
84
85.PHONY: all local install help doc lint clean