6 # Build dynamic headers by substituting various values from autoconf.h, these
7 # get installed with the library files, so external programs can tell what
8 # the server library was built with.
10 # The RFC headers are dynamic, too.
12 # The rest of the headers are static.
15 HEADERS_DY = attributes.h features.h missing.h radpaths.h tls.h
46 # Solaris awk doesn't recognise [[:blank:]] hence [\t ]
48 src/include/autoconf.sed: src/include/autoconf.h
49 @grep ^#define $< | sed 's,/\*\*/,1,;' | awk '{print "'\
50 's,#[\\t ]*ifdef[\\t ]*" $$2 "$$,#if "$$3 ",g;'\
51 's,#[\\t ]*ifndef[\\t ]*" $$2 "$$,#if !"$$3 ",g;'\
52 's,defined(" $$2 ")," $$3 ",g;"}' > $@
53 @grep -o '#undef [^ ]*' $< | sed 's,/#undef /,,;' | awk '{print "'\
54 's,#[\\t ]*ifdef[\\t ]*" $$2 "$$,#if 0,g;'\
55 's,#[\\t ]*ifndef[\\t ]*" $$2 "$$,#if 1,g;'\
56 's,defined(" $$2 "),0,g;"}' >> $@
59 ######################################################################
61 # Create the header files from the dictionaries.
64 RFC_DICTS := $(filter-out %~,$(wildcard share/dictionary.rfc*)) share/dictionary.vqp share/dictionary.freeradius
65 HEADERS_RFC := $(patsubst share/dictionary.%,src/include/%.h,$(RFC_DICTS))
66 HEADERS += $(notdir ${HEADERS_RFC})
68 .PRECIOUS: $(HEADERS_RFC)
70 src/include/attributes.h: share/dictionary.freeradius.internal
72 @echo "/* AUTO-GENERATED HEADER FILE. DO NOT EDIT. */" > $@
73 @grep ^ATTRIBUTE $< | awk '{print "PW_"$$2 " " $$3 }' | tr '[:lower:]' '[:upper:]' | tr -- - _ | sed 's/^/#define /' >> $@
75 @grep -- 'Auth-Type' $< | grep ^VALUE | awk '{print "PW_"$$2 "_" $$3 " " $$4 }' | tr '[:lower:]' '[:upper:]' | tr -- - _ | sed 's/^/#define /' >> $@
77 src/include/%.h: share/dictionary.% share/dictionary.vqp
79 @echo "/* AUTO-GENERATED HEADER FILE. DO NOT EDIT. */" > $@
80 @grep ^ATTRIBUTE $< | awk '{print "PW_"$$2 " " $$3 } ' | tr '[:lower:]' '[:upper:]' | tr -- - _ | sed 's/^/#define /' >> $@
83 # Build features.h by copying over WITH_* and RADIUSD_VERSION_*
84 # preprocessor macros from autoconf.h
85 # This means we don't need to include autoconf.h in installed headers.
87 # We use simple patterns here to work with the lowest common
88 # denominator's grep (Solaris).
90 src/include/features.h: src/include/features-h src/include/autoconf.h
93 @grep "^#define[ ]*WITH_" src/include/autoconf.h >> $@
94 @grep "^#define[ ]*RADIUSD_VERSION" src/include/autoconf.h >> $@
97 # Use the SED script we built earlier to make permanent substitutions
98 # of definitions in missing-h to build missing.h
100 src/include/missing.h: src/include/missing-h src/include/autoconf.sed
102 @sed -f src/include/autoconf.sed < $< > $@
104 src/include/tls.h: src/include/tls-h src/include/autoconf.sed
106 @sed -f src/include/autoconf.sed < $< > $@
108 src/include/radpaths.h: src/include/build-radpaths-h
110 @cd src/include && /bin/sh build-radpaths-h
113 # Create the soft link for the fake include file path.
115 src/freeradius-devel:
116 @[ -e $@ ] || ln -s include $@
119 # Ensure we set up the build environment
121 BOOTSTRAP_BUILD += src/freeradius-devel $(addprefix src/include/,$(HEADERS_DY)) $(HEADERS_RFC)
122 scan: $(BOOTSTRAP_BUILD)
124 ######################################################################
128 # define the installation directory
129 SRC_INCLUDE_DIR := ${R}${includedir}/freeradius
132 @$(INSTALL) -d -m 755 ${SRC_INCLUDE_DIR}
135 # install the headers by re-writing the local files
137 # install-sh function for creating directories gets confused
138 # if there's a trailing slash, tries to create a directory
139 # it already created, and fails...
141 ${SRC_INCLUDE_DIR}/%.h: src/include/%.h | $(SRC_INCLUDE_DIR)
142 @echo INSTALL $(notdir $<)
143 @$(INSTALL) -d -m 755 `echo $(dir $@) | sed 's/\/$$//'`
144 # Expression must deal with indentation after the hash and copy it to the substitution string.
145 # Hash not anchored to allow substitution in function documentation.
146 @sed -e 's/#\([\\t ]*\)include <freeradius-devel\/\([^>]*\)>/#\1include <freeradius\/\2>/g' < $< > $@
149 install.src.include: $(addprefix ${SRC_INCLUDE_DIR}/,${HEADERS})
150 install: install.src.include
155 .PHONY: clean.src.include distclean.src.include
157 @rm -f $(addprefix src/include/,$(HEADERS_DY)) $(HEADERS_RFC)
159 clean: clean.src.include
161 distclean.src.include: clean.src.include
164 distclean: distclean.src.include