1 # SPDX-License-Identifier: GPL-2.0
2 # this make file is simply to help autogenerate these files:
5 # in order to do this, we are also generating a python representation (using
6 # ctypesgen) of ../../comedi.h.
7 # This allows us to sort NI signal/terminal names numerically to use a binary
8 # search through the device_routes tables to find valid routes.
11 @echo Typical targets:
12 @echo "\`make csv-files\`"
13 @echo " Creates new csv-files using content of c-files of existing"
14 @echo " ni_routing/* content. New csv files are placed in csv"
15 @echo " sub-directory."
16 @echo "\`make c-files\`"
17 @echo " Creates new c-files using content of csv sub-directory. These"
18 @echo " new c-files can be compared to the active content in the"
19 @echo " ni_routing directory."
20 @echo "\`make csv-blank\`"
21 @echo " Create a new blank csv file. This is useful for establishing a"
22 @echo " new data table for either a device family \(less likely\) or a"
23 @echo " specific board of an existing device family \(more likely\)."
24 @echo "\`make clean-partial\`"
25 @echo " Remove all generated files/directories EXCEPT for csv/c files."
26 @echo "\`make clean\`"
27 @echo " Remove all generated files/directories."
28 @echo "\`make everything\`"
29 @echo " Build all csv-files, then all new c-files."
31 everything : csv-files c-files csv-blank
33 CPPFLAGS=-D"BIT(x)=(1UL<<(x))" -D__user=
35 comedi_h.py : ../../../comedi.h
36 ctypesgen $< --include "sys/ioctl.h" --cpp 'gcc -E $(CPPFLAGS)' -o $@
38 convert_c_to_py: all_cfiles.c
39 gcc -g convert_c_to_py.c -o convert_c_to_py -std=c99
41 ni_values.py: convert_c_to_py
44 csv-files : ni_values.py comedi_h.py
45 ./convert_py_to_csv.py
49 @echo New blank csv signal table in csv/blank_route_table.csv
52 ./convert_csv_to_c.py --route_values --device_routes
54 ROUTE_VALUES_SRC=$(wildcard ../ni_route_values/*.c)
55 DEVICE_ROUTES_SRC=$(wildcard ../ni_device_routes/*.c)
56 all_cfiles.c : $(DEVICE_ROUTES_SRC) $(ROUTE_VALUES_SRC)
57 @for i in $(DEVICE_ROUTES_SRC) $(ROUTE_VALUES_SRC); do \
58 echo "#include \"$$i\"" >> all_cfiles.c; \
62 $(RM) -rf comedi_h.py ni_values.py convert_c_to_py all_cfiles.c *.pyc \
68 # Note: One could also use ctypeslib in order to generate these files. The
69 # caveat is that ctypeslib does not do a great job at handling macro functions.
70 # The make rules are as follows:
71 # comedi.h.xml : ../../comedi.h
72 # # note that we have to use PWD here to avoid h2xml finding a system
73 # # installed version of the comedilib/comedi.h file
74 # h2xml ${PWD}/../../comedi.h -c -D__user="" -D"BIT(x)=(1<<(x))" \
77 # comedi_h.py : comedi.h.xml
78 # xml2py ./comedi.h.xml -o comedi_h.py
80 # rm -f comedi.h.xml comedi_h.py comedi_h.pyc