Auto-generate headers from dictionarty.freeradius.internal
[freeradius.git] / src / include / all.mk
1 #
2 # Version:      $Id$
3 #
4
5 HEADERS = \
6         attributes.h \
7         build.h \
8         conf.h \
9         conffile.h \
10         detail.h \
11         event.h \
12         features.h \
13         hash.h \
14         heap.h \
15         libradius.h \
16         md4.h \
17         md5.h \
18         missing.h \
19         modcall.h \
20         modules.h \
21         packet.h \
22         rad_assert.h \
23         radius.h \
24         radiusd.h \
25         radpaths.h \
26         radutmp.h \
27         realms.h \
28         sha1.h \
29         stats.h \
30         sysutmp.h \
31         token.h \
32         udpfromto.h \
33         base64.h \
34         map.h
35
36 #
37 #  Build dynamic headers by substituting various values from autoconf.h, these
38 #  get installed with the library files, so external programs can tell what
39 #  the server library was built with.
40 #
41
42 HEADERS_DY = src/include/features.h src/include/missing.h src/include/tls.h \
43         src/include/radpaths.h src/include/attributes.h
44
45 src/include/autoconf.sed: src/include/autoconf.h
46         @grep ^#define $< | sed 's,/\*\*/,1,;' | awk '{print "\
47         s,#[[:blank:]]*ifdef[[:blank:]]*" $$2 ",#if "$$3 ",g;\
48         s,#[[:blank:]]*ifndef[[:blank:]]*" $$2 ",#if !"$$3 ",g;\
49         s,defined(" $$2 ")," $$3 ",g;\
50         s," $$2 ","$$3 ",g;"}' > $@
51
52 src/include/radius.h: | src/include/attributes.h
53
54 src/include/attributes.h: share/dictionary.freeradius.internal
55         @$(ECHO) HEADER $@
56         @./scripts/dict2h.pl $< > $@
57
58 src/freeradius-devel/features.h: src/include/features.h src/freeradius-devel
59
60 src/include/features.h: src/include/features-h src/include/autoconf.h
61         @$(ECHO) HEADER $@
62         @cp $< $@
63         @grep "^#define[[:blank:]]\{1,\}WITH_" src/include/autoconf.h >> $@
64         @grep "^#define[[:blank:]]\{1,\}RADIUSD_VERSION" src/include/autoconf.h >> $@
65
66 src/freeradius-devel/missing.h: src/include/missing.h src/freeradius-devel
67
68 src/include/missing.h: src/include/missing-h src/include/autoconf.sed
69         @$(ECHO) HEADER $@
70         @sed -f src/include/autoconf.sed < $< > $@
71
72 src/freeradius-devel/tls.h: src/include/tls.h src/freeradius-devel
73
74 src/include/tls.h: src/include/tls-h src/include/autoconf.sed
75         @$(ECHO) HEADER $@
76         @sed -f src/include/autoconf.sed < $< > $@
77
78 src/freeradius-devel/radpaths.h: src/include/radpaths.h src/freeradius-devel
79
80 src/include/radpaths.h: src/include/build-radpaths-h
81         @$(ECHO) HEADER $@
82         @cd src/include && /bin/sh build-radpaths-h
83
84 ${BUILD_DIR}/make/jlibtool: $(HEADERS_DY)
85
86 #
87 #  Installation
88 #
89 # define the installation directory
90 SRC_INCLUDE_DIR := ${R}${includedir}/freeradius
91
92 $(SRC_INCLUDE_DIR):
93         @$(INSTALL) -d -m 755 ${SRC_INCLUDE_DIR}
94
95 # install the headers by re-writing the local files
96 #
97 # install-sh function for creating directories gets confused
98 # if there's a trailing slash, tries to create a directory
99 # it already created, and fails...
100 ${SRC_INCLUDE_DIR}/%.h: ${top_srcdir}/src/include/%.h | $(SRC_INCLUDE_DIR)
101         @echo INSTALL $(notdir $<)
102         @$(INSTALL) -d -m 755 `echo $(dir $@) | sed 's/\/$$//'`
103         @sed 's/^#include <freeradius-devel/#include <freeradius/' < $< > $@
104         @chmod 644 $@
105
106 install.src.include: $(addprefix ${SRC_INCLUDE_DIR}/,${HEADERS})
107 install: install.src.include
108
109 #
110 #  Cleaning
111 #
112 .PHONY: clean.src.include distclean.src.include
113 clean.src.include:
114         @rm -f $(HEADERS_DY)
115
116 clean: clean.src.include
117
118 distclean.src.include: clean.src.include
119         @rm -f autoconf.sed
120
121 distclean: distclean.src.include