1# ***** BEGIN LICENSE BLOCK *****
2# Version: MPL 1.1/GPL 2.0/LGPL 2.1
3#
4# The contents of this file are subject to the Mozilla Public License Version
5# 1.1 (the "License"); you may not use this file except in compliance with
6# the License. You may obtain a copy of the License at
7# http://www.mozilla.org/MPL/
8#
9# Software distributed under the License is distributed on an "AS IS" basis,
10# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11# for the specific language governing rights and limitations under the
12# License.
13#
14# The Original Code is libical code.
15#
16# The Initial Developer of the Original Code is
17#  Eric Busboom
18# Portions created by the Initial Developer are Copyright (C) 2000
19# the Initial Developer. All Rights Reserved.
20#
21# Contributor(s):
22#   Michiel van Leeuwen <mvl@exedo.nl>
23#
24# Alternatively, the contents of this file may be used under the terms of
25# either the GNU General Public License Version 2 or later (the "GPL"), or
26# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27# in which case the provisions of the GPL or the LGPL are applicable instead
28# of those above. If you wish to allow use of your version of this file only
29# under the terms of either the GPL or the LGPL, and not to allow others to
30# use your version of this file under the terms of the MPL, indicate your
31# decision by deleting the provisions above and replace them with the notice
32# and other provisions required by the GPL or the LGPL. If you do not delete
33# the provisions above, a recipient may use your version of this file under
34# the terms of any one of the MPL, the GPL or the LGPL.
35#
36# ***** END LICENSE BLOCK *****
37
38include $(moztopsrcdir)/config/rules.mk
39
40######################################################################
41#
42# Generate files that are automatically generated (*.h.in and *.c.in)
43# and ical.h
44#
45
46DESIGNDATA = $(srcdir)/../../design-data
47ICALSCRIPTS = $(srcdir)/../../scripts
48
49# ORDERING OF HEADERS IS SIGNIFICANT. Don't change this ordering. It
50# is required to make the combined header ical.h properly
51COMBINEDHEADERS =                        \
52        $(srcdir)/../../config.h         \
53   $(srcdir)/icalversion.h               \
54   $(srcdir)/icaltime.h                  \
55   $(srcdir)/icalduration.h              \
56   $(srcdir)/icalperiod.h                \
57   $(srcdir)/icalenums.h                 \
58   $(srcdir)/icaltypes.h                 \
59   $(srcdir)/icalrecur.h                 \
60   $(srcdir)/icalattach.h                \
61   icalderivedvalue.h                    \
62   icalderivedparameter.h                \
63   $(srcdir)/icalvalue.h                 \
64   $(srcdir)/icalparameter.h             \
65   icalderivedproperty.h                 \
66   $(srcdir)/icalproperty.h              \
67   $(srcdir)/pvl.h                       \
68   $(srcdir)/icalarray.h                 \
69   $(srcdir)/icalcomponent.h             \
70   $(srcdir)/icaltimezone.h              \
71   $(srcdir)/icalparser.h                \
72   $(srcdir)/icalmemory.h                \
73   $(srcdir)/icalerror.h                 \
74   $(srcdir)/icalrestriction.h           \
75   $(srcdir)/sspm.h                      \
76   $(srcdir)/icalmime.h                  \
77   $(srcdir)/icallangbind.h              \
78   $(NULL)
79
80BUILT_COMBINEDHEADERS = 	\
81	icalderivedparameter.h	\
82	icalderivedproperty.h	\
83	icalderivedvalue.h
84
85BUILT_SOURCES =			\
86	$(BUILT_COMBINEDHEADERS)\
87	icalderivedparameter.c	\
88	icalderivedproperty.c	\
89	icalrestriction.c	\
90	icalderivedvalue.c
91
92GARBAGE += $(BUILT_SOURCES)
93
94ical.h: $(COMBINEDHEADERS)
95	echo '#ifndef LIBICAL_ICAL_H'     >  ical.h
96	echo '#define LIBICAL_ICAL_H'     >> ical.h
97	echo '#ifdef __cplusplus'         >> ical.h
98	echo 'extern "C" {'               >> ical.h
99	echo '#endif'                     >> ical.h
100	echo '/*'                         >> ical.h
101	echo ' $$''Id''$$'                >> ical.h
102	echo '*/'                         >> ical.h
103	cat $(COMBINEDHEADERS)				\
104	| egrep -v "#include.*\"ical"			\
105	| egrep -v "#include.*\"config"			\
106	| egrep -v "#include.*\"pvl\.h\""		\
107	| egrep -v '\$$(Id|Locker): .+\$$'>> ical.h
108	echo '#ifdef __cplusplus'         >> ical.h
109	echo '}'                          >> ical.h
110	echo '#endif'                     >> ical.h
111	echo '#endif'                     >> ical.h
112
113GARBAGE += ical.h
114
115# parameters
116
117PARAMETERDEPS =	\
118	$(ICALSCRIPTS)/mkderivedparameters.pl \
119	$(DESIGNDATA)/parameters.csv	\
120	$(srcdir)/icalderivedparameter.c.in \
121	$(srcdir)/icalderivedparameter.h.in
122
123icalderivedparameter.h: $(PARAMETERDEPS)
124	$(PERL) -I$(ICALSCRIPTS) $(ICALSCRIPTS)/mkderivedparameters.pl -i $(srcdir)/icalderivedparameter.h.in -h $(DESIGNDATA)/parameters.csv > icalderivedparameter.h
125
126icalderivedparameter.c: $(PARAMETERDEPS) $(BUILT_COMBINEDHEADERS)
127	$(PERL) -I$(ICALSCRIPTS) $(ICALSCRIPTS)/mkderivedparameters.pl -i $(srcdir)/icalderivedparameter.c.in -c $(DESIGNDATA)/parameters.csv > icalderivedparameter.c
128
129# properties
130
131PROPERTYDEPS =					\
132	$(ICALSCRIPTS)/mkderivedproperties.pl	\
133	$(DESIGNDATA)/properties.csv		\
134	$(DESIGNDATA)/value-types.csv		\
135	$(srcdir)/icalderivedproperty.c.in		\
136	$(srcdir)/icalderivedproperty.h.in
137
138
139icalderivedproperty.h: $(PROPERTYDEPS)
140	$(PERL) -I$(ICALSCRIPTS) $(ICALSCRIPTS)/mkderivedproperties.pl \
141		-i $(srcdir)/icalderivedproperty.h.in -h $(DESIGNDATA)/properties.csv\
142		${DESIGNDATA}/value-types.csv > icalderivedproperty.h
143
144icalderivedproperty.c: $(PROPERTYDEPS) $(BUILT_COMBINEDHEADERS)
145	$(PERL) -I$(ICALSCRIPTS) $(ICALSCRIPTS)/mkderivedproperties.pl \
146		-i $(srcdir)/icalderivedproperty.c.in -c $(DESIGNDATA)/properties.csv \
147		${DESIGNDATA}/value-types.csv > icalderivedproperty.c
148
149# restrictions
150
151RESTRICTIONDEPS =				\
152	$(ICALSCRIPTS)/mkrestrictiontable.pl	\
153	$(DESIGNDATA)/restrictions.csv		\
154	$(srcdir)/icalrestriction.c.in
155
156icalrestriction.c: $(RESTRICTIONDEPS)
157	$(PERL) $(ICALSCRIPTS)/mkrestrictiontable.pl  -i $(srcdir)/icalrestriction.c.in \
158		$(DESIGNDATA)/restrictions.csv > icalrestriction.c
159
160# values
161
162VALUEDEPS =					\
163	$(ICALSCRIPTS)/mkderivedvalues.pl  	\
164	$(DESIGNDATA)/value-types.csv		\
165	$(srcdir)/icalderivedvalue.c.in				\
166	$(srcdir)/icalderivedvalue.h.in
167
168icalderivedvalue.h: $(VALUEDEPS)
169	$(PERL) -I$(ICALSCRIPTS)  $(ICALSCRIPTS)/mkderivedvalues.pl \
170	         -i $(srcdir)/icalderivedvalue.h.in -h $(DESIGNDATA)/value-types.csv > icalderivedvalue.h
171
172icalderivedvalue.c: $(VALUEDEPS) $(BUILT_COMBINEDHEADERS)
173	$(PERL)  -I$(ICALSCRIPTS) $(ICALSCRIPTS)/mkderivedvalues.pl \
174		-i $(srcdir)/icalderivedvalue.c.in -c $(DESIGNDATA)/value-types.csv > icalderivedvalue.c
175