1########################################################################
2#
3# Copyright (c) 2009, Secure Endpoints Inc.
4# All rights reserved.
5# 
6# Redistribution and use in source and binary forms, with or without
7# modification, are permitted provided that the following conditions
8# are met:
9# 
10# - Redistributions of source code must retain the above copyright
11#   notice, this list of conditions and the following disclaimer.
12# 
13# - Redistributions in binary form must reproduce the above copyright
14#   notice, this list of conditions and the following disclaimer in
15#   the documentation and/or other materials provided with the
16#   distribution.
17# 
18# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
21# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
22# COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
23# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
24# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
28# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29# POSSIBILITY OF SUCH DAMAGE.
30# 
31
32RELDIR=lib\hdb
33
34!include ../../windows/NTMakefile.w32 
35
36gen_files_hdb = $(OBJ)\asn1_hdb_asn1.x
37
38$(gen_files_hdb) $(OBJ)\hdb_asn1.hx $(OBJ)\hdb_asn1-priv.hx: $(BINDIR)\asn1_compile.exe hdb.asn1
39	cd $(OBJ)
40	$(BINDIR)\asn1_compile.exe --sequence=HDB-Ext-KeySet --sequence=Keys --one-code-file $(SRCDIR)\hdb.asn1 hdb_asn1
41	cd $(SRCDIR)
42
43$(gen_files_hdb:.x=.c): $$(@R).x
44
45!ifdef OPENLDAP_MODULE
46
47ldap_dll = $(BINDIR)\hdb_ldap.dll
48ldap_lib = $(LIBDIR)\hdb_ldap.lib
49ldap_objs = $(OBJ)\hdb-ldap.obj
50
51$(ldap_dll): $(ldap_objs)
52	$(DLLGUILINK) -implib:$(ldap_lib)
53	$(DLLPREP)
54
55clean::
56	-$(RM) $(ldap_dll)
57	-$(RM) $(ldap_lib)
58
59!else
60
61ldap = $(OBJ)\hdb-ldap.obj
62ldap_c = hdb-ldap.c
63
64!endif
65
66dist_libhdb_la_SOURCES =			\
67	common.c				\
68	db.c					\
69	db3.c					\
70	ext.c					\
71	$(ldap_c)				\
72	hdb.c					\
73	hdb-sqlite.c				\
74	hdb-keytab.c				\
75	hdb-mitdb.c				\
76	hdb_locl.h				\
77	keys.c					\
78	keytab.c				\
79	dbinfo.c				\
80	mkey.c					\
81	ndbm.c					\
82	print.c
83
84libhdb_OBJs = \
85	$(OBJ)\common.obj	\
86	$(OBJ)\db.obj		\
87	$(OBJ)\db3.obj		\
88	$(OBJ)\ext.obj		\
89	$(ldap)			\
90	$(OBJ)\hdb.obj		\
91	$(OBJ)\hdb-sqlite.obj	\
92	$(OBJ)\hdb-keytab.obj	\
93	$(OBJ)\hdb-mitdb.obj	\
94	$(OBJ)\keys.obj		\
95	$(OBJ)\keytab.obj	\
96	$(OBJ)\dbinfo.obj	\
97	$(OBJ)\mkey.obj		\
98	$(OBJ)\ndbm.obj		\
99	$(OBJ)\print.obj	\
100	$(gen_files_hdb:.x=.obj)	\
101	$(OBJ)\hdb_err.obj
102
103$(OBJ)\hdb_err.c $(OBJ)\hdb_err.h: hdb_err.et
104	cd $(OBJ)
105	$(BINDIR)\compile_et.exe $(SRCDIR)\hdb_err.et
106	cd $(SRCDIR)
107
108$(OBJ)\hdb-protos.h: $(dist_libhdb_la_SOURCES)
109	$(PERL) ../../cf/make-proto.pl -q -P remove -o $@ $(dist_libhdb_la_SOURCES) \
110		|| $(RM) $@
111
112$(OBJ)\hdb-private.h: $(dist_libhdb_la_SOURCES)
113	$(PERL) ../../cf/make-proto.pl -q -P remote -p $@ $(dist_libhdb_la_SOURCES) \
114		|| $(RM) $@
115
116INCFILES=			\
117	$(INCDIR)\hdb.h		\
118	$(INCDIR)\hdb-protos.h	\
119	$(OBJ)\hdb-private.h	\
120	$(INCDIR)\hdb_err.h	\
121	$(INCDIR)\hdb_asn1.h	\
122	$(INCDIR)\hdb_asn1-priv.h
123
124!ifndef STATICLIBS
125
126RES=$(OBJ)\libhdb-version.res
127
128$(LIBHDB): $(BINDIR)\libhdb.dll
129
130$(BINDIR)\libhdb.dll: $(libhdb_OBJs) $(ldap_lib) $(LIBHEIMDAL) $(LIBSQLITE) $(LIBCOMERR) $(LIBROKEN) $(RES)
131	$(DLLGUILINK) -def:libhdb-exports.def -implib:$(LIBHDB)
132	$(DLLPREP)
133
134clean::
135	-$(RM) $(BINDIR)\libhdb.*
136
137!else
138
139$(LIBHDB): $(libhdb_OBJs) $(ldap_lib)
140	$(LIBCON)
141
142!endif
143
144all:: $(INCFILES) $(LIBHDB)
145
146clean::
147	-$(RM) $(INCFILES)
148	-$(RM) $(LIBHDB)
149
150test:: test-binaries test-run
151
152test-binaries: $(OBJ)\test_dbinfo.exe $(OBJ)\test_hdbkeys.exe
153
154$(OBJ)\test_dbinfo.exe: $(OBJ)\test_dbinfo.obj $(LIBHDB) $(LIBHEIMDAL) $(LIBROKEN) $(LIBVERS)
155	$(EXECONLINK)
156	$(EXEPREP_NODIST)
157
158$(OBJ)\test_hdbkeys.exe: $(OBJ)\test_hdbkeys.obj $(LIBHDB) $(LIBHEIMDAL) $(LIBROKEN) $(LIBVERS)
159	$(EXECONLINK)
160	$(EXEPREP_NODIST)
161
162test-run:
163	cd $(OBJ)
164	test_dbinfo.exe
165	cd $(SRCDIR)
166
167!ifdef OPENLDAP_INC
168openldap_inc_flag=-I$(OPENLDAP_INC)
169!else
170openldap_inc_flag=
171!endif
172
173hdb_cflags=$(openldap_inc_flag) -I$(OBJ)
174
175{}.c{$(OBJ)}.obj::
176	$(C2OBJ_P) $(hdb_cflags) -DASN1_LIB
177
178{$(OBJ)}.c{$(OBJ)}.obj::
179	$(C2OBJ_P) $(hdb_cflags)
180
181test-exports:
182	$(PERL) ..\..\cf\w32-check-exported-symbols.pl --vs version-script.map --def libhdb-exports.def
183
184test:: test-exports
185