summaryrefslogtreecommitdiffstats
path: root/ldap/admin/src/Makefile
blob: 8e3de153ac653d3df6b42b12c9e963febb24bc96 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
#
# BEGIN COPYRIGHT BLOCK
# This Program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation; version 2 of the License.
# 
# This Program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License along with
# this Program; if not, write to the Free Software Foundation, Inc., 59 Temple
# Place, Suite 330, Boston, MA 02111-1307 USA.
# 
# In addition, as a special exception, Red Hat, Inc. gives You the additional
# right to link the code of this Program with code not covered under the GNU
# General Public License ("Non-GPL Code") and to distribute linked combinations
# including the two, subject to the limitations in this paragraph. Non-GPL Code
# permitted under this exception must only link to the code of this Program
# through those well defined interfaces identified in the file named EXCEPTION
# found in the source code files (the "Approved Interfaces"). The files of
# Non-GPL Code may instantiate templates or use macros or inline functions from
# the Approved Interfaces without causing the resulting work to be covered by
# the GNU General Public License. Only Red Hat, Inc. may make changes or
# additions to the list of Approved Interfaces. You must obey the GNU General
# Public License in all respects for all of the Program code and other code used
# in conjunction with the Program except the Non-GPL Code covered by this
# exception. If you modify this file, you may extend this exception to your
# version of the file, but you are not obligated to do so. If you do not wish to
# provide this exception without modification, you must delete this exception
# statement from your version and license this file solely under the GPL without
# exception. 
# 
# 
# Copyright (C) 2001 Sun Microsystems, Inc. Used by permission.
# Copyright (C) 2005 Red Hat, Inc.
# All rights reserved.
# END COPYRIGHT BLOCK
#
# Source for the admin forms and CGI programs

LDAP_SRC = ../..
BUILD_ROOT = ../../..

NOSTDCLEAN=true # don't let nsconfig.mk define target clean
NOSTDSTRIP=true # don't let nsconfig.mk define target strip
NSPR20=true	# probably should be defined somewhere else (not sure where)

BINDIR=$(LDAP_ADMIN_BIN_RELDIR)
OBJDEST=$(LDAP_ADMOBJDIR)

SCRIPTSDIR=$(LDAP_BASE_RELDIR)/admin/scripts

include $(BUILD_ROOT)/nsconfig.mk
include $(LDAP_SRC)/nsldap.mk

ifeq ($(USE_ADMINSERVER), 1)
MCC_INCLUDE += $(ADMINUTIL_INCLUDE)
endif

INCLUDES += -I$(LDAP_SRC)/admin/include

DS_SERVER_DEFS = -DNS_DS

ifneq ($(ARCH), WINNT)
EXTRALDFLAGS += $(SSLLIBFLAG)
endif

ifeq ($(BUILD_DLL), yes)
DYNAMIC_DEPLIBS=$(LDAP_ADMLIB) $(LDAP_COMMON_LIBS_DEP)
ifeq ($(USE_ADMINSERVER), 1)
  DYNAMIC_DEPLIBS += $(ADMINUTIL)
endif
DYNAMIC_DEPLINK=$(DYNAMIC_DEPLIBS)
else
DYNAMIC_DEPLIBS=$(LDAP_COMMON_LIBS_DEP)
DYNAMIC_DEPLINK=$(LDAP_ADMLIB) $(LDAP_COMMON_LIBS)
endif

EXTRA_LIBS_DEP += $(NSPR_DEP) $(LDAPSDK_DEP) $(SASL_DEP)
ifeq ($(USE_ADMINSERVER), 1)
  EXTRA_LIBS_DEP += $(ADMINUTIL_DEP)
endif
EXTRA_LIBS_DEP += $(ICU_DEP)
# we don't want to build with warnings-as-errors for the admin/ stuff, because
# it's got crappy C++ code which is LITTERED with warnings, most of which we
# can't fix because it comes from files in dist/, etc.
ifeq ($(ARCH), Linux)
CFLAGS := $(subst -Werror,,$(CFLAGS))
endif

OLD_EXTRA_LIBS := $(EXTRA_LIBS)
EXTRA_LIBS = $(DYNAMIC_DEPLINK) $(LDAP_NOSSL_LINK)
ifeq ($(USE_ADMINSERVER), 1)
  EXTRA_LIBS += $(ADMINUTIL_LINK)
endif
EXTRA_LIBS += $(SECURITYLINK) $(NSPRLINK)
ifeq ($(USE_SETUPUTIL), 1)
  EXTRA_LIBS += $(SETUPUTIL_S_LINK)
endif
EXTRA_LIBS += $(ICULINK) $(SASL_LINK) $(OLD_EXTRA_LIBS)

# these are the libraries to use when building the installer for the open source version
OPENSOURCE_LIBS = $(LDAP_ADMLIB) $(LDAP_NOSSL_LINK) $(SECURITYLINK) $(NSPRLINK)

ifeq ($(ARCH), WINNT)
PLATFORM_INCLUDE = -I$(BUILD_ROOT)/include/nt
SUBSYSTEM=console
EXTRA_LIBS+=comctl32.lib $(LDAP_LIBUTIL)
OPENSOURCE_LIBS += comctl32.lib $(LDAP_LIBUTIL)
EXTRA_LIBS_DEP+=$(LDAP_LIBUTIL_DEP)

ifeq ($(DEBUG), optimize)
#NT_NOLIBS = /NODEFAULTLIB:LIBCMT /NODEFAULTLIB:MSVCRT
else
NT_NOLIBS = /NODEFAULTLIB:LIBCMTD /NODEFAULTLIB:MSVCRTD
endif

else
ifeq ($(ARCH), IRIX)
EXCEPTIONS=-exceptions
else
ifeq ($(ARCH),SOLARIS)
ifeq ($(USE_64), 1)
EXTRALDFLAGS += -xarch=v9
endif
EXTRA_LIBS += -lsocket -lnsl -lgen -lm -lposix4 -lthread
OPENSOURCE_LIBS += -lsocket -lnsl -lgen -lm -lposix4 -lthread
else
ifeq ($(ARCH),SOLARISx86)
EXTRA_LIBS += -lsocket -lnsl -lgen -lm -lposix4 -lthread
OPENSOURCE_LIBS += -lsocket -lnsl -lgen -lm -lposix4 -lthread
else
ifeq ($(ARCH),HPUX)
  ifeq ($(NSOS_RELEASE),B.11.23)
    ifeq ($(USE_64), 1)
      EXTRALDFLAGS += +DD64
    endif
  else
    ifeq ($(USE_64), 1)
      EXTRALDFLAGS += +DA2.0W +DS2.0 +Z
    endif
  endif
else
ifeq ($(ARCH),OSF1)
#CC += -E
#CXX += -Wl,-ymain
else
ifeq ($(ARCH),ReliantUNIX)
else
ifeq ($(ARCH), AIX)
EXTRA_LIBS += -lcurses
else
ifeq ($(ARCH), UnixWare)
# rgc:
EXTRA_LIBS += -lsocket -lnsl -lgen -lm
else 
ifeq ($(ARCH), Linux)
EXTRA_LIBS += -lcrypt
else
#this will help with porting other platforms
EXTRA_LIBS+="you need to define EXTRA_LIBS for $(ARCH) in ldap/admin/src/Makefile"
endif # Linux
endif # UnixWare
endif # AIX
endif # ReliantUNIX
endif # OSF1
endif # HPUX
endif # SOLARISx86
endif # SOLARIS
endif # IRIX
endif # WINNT

ifneq ($(ARCH), WINNT)
TEMP_EXTRALDFLAGS:=$(EXTRALDFLAGS)
EXTRALDFLAGS = -lpthread $(TEMP_EXTRALDFLAGS)
endif

ifeq ($(SECURITY),domestic)
SECUS_BINS=
MODULE_CFLAGS += -DUS_VERSION -DEXPORT_VERSION
endif

ifeq ($(SECURITY),export)
MODULE_CFLAGS += -DEXPORT_VERSION
endif

ifneq ($(SECURITY),none)
SECURE_BINS=
SECLIB=$(LIBSECURITY)
endif

ifeq ($(USE_ADMINSERVER), 1)
  ADMIN_DLLGLUEOBJ=$(BUILD_ROOT)/built/$(ARCH)-$(SECURITY)-$(DEBUG)-admin/admin-lib/dllglue.o
endif

ifeq ($(ARCH),AIX)
DLLGLUEOBJ=
GLUEOBJS=
endif

$(OBJDEST)/key.res: key.rc
	$(RC) $(OFFLAG)$(OBJDEST)/key.res ey.rc

PROGS = ds_newinst
ifeq ($(USE_ADMINSERVER), 1)
PROGS += start   restart  shutdown   ds_ldif2db \
	ds_db2ldif   ds_db2bak   ds_listdb  \
	ds_bak2db ds_rmdb ds_create \
	ds_remove ds_snmpctrl vlvindex addindex
endif

ifeq ($(ARCH), WINNT)
SERVER_PROGS = namegen latest_file
endif

ifeq ($(USE_ADMINSERVER), 1)
OBJECTS= init_ds_env.o
endif

ifeq ($(ARCH), WINNT)
OBJECTS += namegen.o latest_file.o
ifeq ($(USE_SETUPUTIL), 1)
  OBJECTS += ds_remove_uninst.o
endif
endif

ifeq ($(ARCH), WINNT)
BINS = $(addprefix $(BINDIR)/, $(addsuffix .exe, $(PROGS))) $(addprefix $(LDAP_SERVER_RELDIR)/, $(addsuffix .exe, $(SERVER_PROGS)))
else
BINS = $(addprefix $(BINDIR)/, $(PROGS))
endif
ALLOBJS = $(addprefix $(OBJDEST)/, $(OBJECTS))

PERL_SCRIPTS = migrateTo4 uname.lib Cgi.pm migrateInstance getConfigInfo migrateLocalDB migratePwdFile ds_viewlog.pl upgradeServer updatedsgw logconv.pl ds_newinst.pl

PERL_SCRIPTS_DEST = $(addprefix $(BINDIR)/, $(PERL_SCRIPTS))

INST_INCLUDES = $(OBJDIR)/install_keywords.h

TEMPLATE_SCRIPTS_SRC = $(wildcard scripts/template-*)
TEMPLATE_SCRIPTS_DEST = $(subst scripts/,$(SCRIPTSDIR)/,$(TEMPLATE_SCRIPTS_SRC))

# we wrap the security tools with a shell script wrapper for their ld libpath
PACKAGE_SEC_TOOLS = $(addprefix $(RELDIR)/shared/bin/,$(SECURITY_TOOLS))

# We only need to do this if we have to ship 32 bit binaries in our 64 bit packages
# Right now, on rhel/linux, we ship all native 64 bit apps so we don't have to do
# this.  We still may need to do this on solaris/hpux, but hopefully not for very
# much longer
ifeq ($(USE_64), 1)
  ifeq ($(ARCH), RHEL)
    FIX_SECMOD_DEP =
  else
  ifeq ($(ARCH), Linux)
    FIX_SECMOD_DEP =
  else
    FIX_SECMOD_DEP = $(BINDIR)/fix_secmod_db_64
  endif
  endif
endif

# gmake 3.74 will remove "intermediate" files if generated via a pattern match rule
# this is annoying for debugging since it tries to find the .o file
# if you're debugging and you want to make sure your file does not get removed
# by gmake, just uncomment the precious target and put your object files there
# or FIX IT! if you can figure out how . . .
#.PRECIOUS: $(OBJDEST)/ds_db2bak.o

all: $(BINDIR) $(OBJDEST) $(INST_INCLUDES) $(ALLOBJS) $(BINS) \
	installPerlFiles $(SCRIPTSDIR) $(TEMPLATE_SCRIPTS_DEST) \
	$(FIX_SECMOD_DEP) $(PACKAGE_SEC_TOOLS)

$(SCRIPTSDIR):
	$(MKDIR) $@

.PHONY: installPerlFiles

clean:
	-@echo $(BINS)
	-$(RM) $(BINS)
	-$(RM) $(OBJDEST)/*.o

strip:
	$(STRIP) $(BINS)

# if $(DLLGLUEOBJ) isn't available, use $(ADMIN_DLLGLUEOBJ) as a substitute:
$(DLLGLUEOBJ): $(ADMIN_DLLGLUEOBJ)
	cp $(ADMIN_DLLGLUEOBJ) $(DLLGLUEOBJ)

# if $(SECGLUEOBJ) isn't available, use $(ADMIN_SECGLUEOBJ) as a substitute:
$(SECGLUEOBJ): $(ADMIN_SECGLUEOBJ)
	cp $(ADMIN_SECGLUEOBJ) $(SECGLUEOBJ)

# Special objects
$(BINDIR)/ds_newinst:	$(OBJDEST)/ds_newinst.o $(OBJDEST)/cfg_sspt.o \
    $(OBJDEST)/create_instance.o $(OBJDEST)/script-gen.o
	$(LINK_EXE_NOLIBSOBJS) $(SHARED) $(EXTRALDFLAGS) \
	$(OBJDEST)/ds_newinst.o $(OBJDEST)/cfg_sspt.o \
    $(OBJDEST)/create_instance.o $(OBJDEST)/script-gen.o $(EXTRA_LIBS)

$(BINDIR)/ds_newinst.exe:	$(OBJDEST)/ds_newinst.o $(OBJDEST)/cfg_sspt.o \
    $(OBJDEST)/create_instance.o $(OBJDEST)/script-gen.o
	$(LINK_EXE) $(NT_NOLIBS) $(OBJDEST)/ds_newinst.o $(OBJDEST)/cfg_sspt.o \
    $(OBJDEST)/create_instance.o $(OBJDEST)/script-gen.o \
		$(LIBNT) $(NSPRLINK) $(EXTRA_LIBS) $(DB_LIB)
# linking this file causes a .exp and a .lib file to be generated which don't seem
# to be required while running, so I get rid of them
	$(RM) $(subst .exe,.exp,$@) $(subst .exe,.lib,$@)

$(BINDIR)/ds_create:	$(OBJDEST)/instindex.o $(OBJDEST)/cfg_sspt.o \
    $(OBJDEST)/create_instance.o $(OBJDEST)/configure_instance.o \
	$(OBJDEST)/script-gen.o $(DEPLIBS)
	$(LINK_EXE_NOLIBSOBJS) $(SHARED) $(EXTRALDFLAGS) \
		$(OBJDEST)/instindex.o $(OBJDEST)/script-gen.o \
		$(OBJDEST)/create_instance.o $(OBJDEST)/cfg_sspt.o \
		$(OBJDEST)/configure_instance.o \
		$(GLUEOBJ) $(EXTRA_LIBS)

$(BINDIR)/ds_create.exe:	$(OBJDEST)/instindex.o $(OBJDEST)/cfg_sspt.o \
    $(OBJDEST)/create_instance.o $(OBJDEST)/configure_instance.o \
	$(OBJDEST)/script-gen.o $(LIBNT_DEP) $(DEPLIBS)
	$(LINK_EXE) $(NT_NOLIBS) $(OBJDEST)/instindex.o \
		$(OBJDEST)/create_instance.o $(OBJDEST)/cfg_sspt.o \
		$(OBJDEST)/configure_instance.o $(OBJDEST)/script-gen.o \
		$(SETUPUTIL_S_LINK) $(LDAP_SDK_LIBS) $(LIBNT) \
		$(NSPRLINK) $(EXTRA_LIBS) $(DB_LIB)
# linking this file causes a .exp and a .lib file to be generated which don't seem
# to be required while running, so I get rid of them
	$(RM) $(subst .exe,.exp,$@) $(subst .exe,.lib,$@)

$(BINDIR)/ds_remove:  $(OBJDEST)/ds_remove.o $(OBJDEST)/ds_remove_uninst.o $(DEPLIBS) $(EXTRA_LIBS_DEP)
	$(LINK_EXE_NOLIBSOBJS)  $(SHARED) $(EXTRALDFLAGS) \
		$(OBJDEST)/ds_remove.o $(OBJDEST)/ds_remove_uninst.o $(OBJDEST)/init_ds_env.o \
		$(SETUPUTIL_S_LINK) $(GLUEOBJ) $(EXTRA_LIBS)

$(BINDIR)/ds_remove.exe:  $(OBJDEST)/ds_remove.o $(OBJDEST)/ds_remove_uninst.o $(DEPLIBS) $(EXTRA_LIBS_DEP)
	$(LINK_EXE) $(OBJDEST)/ds_remove_uninst.o $(OBJDEST)/ds_remove.o $(OBJDEST)/init_ds_env.o $(LDAP_SDK_LIBS) $(NSPRLINK) $(SETUPUTIL_S_LINK) $(NT_NOLIBS)
# linking this file causes a .exp and a .lib file to be generated which don't seem
# to be required while running, so I get rid of them
	$(RM) $(subst .exe,.exp,$@) $(subst .exe,.lib,$@)

$(OBJDEST)/%.o: %.c
	$(CC) -c $(CFLAGS) $(MCC_INCLUDE) $< $(OFFLAG)$@

$(OBJDEST)/%.o: %.cpp
ifeq ($(ARCH), WINNT)
	$(CC) -c $(CFLAGS) $(MCC_INCLUDE) $(SETUPUTIL_INCLUDE) $< $(OFFLAG)$@
else
	$(CXX) $(EXCEPTIONS) -c $(CFLAGS) $(MCC_INCLUDE) $(SETUPUTIL_INCLUDE) $< $(OFFLAG)$@
endif

ifneq ($(ARCH), WINNT)
$(BINDIR)/%: $(OBJDEST)/%.o  $(DEPLIBS) $(EXTRA_LIBS_DEP) $(GLUEOBJ)
	$(LINK_EXE_NOLIBSOBJS) $< $(OBJDEST)/init_ds_env.o $(GLUEOBJ) $(EXTRA_LIBS)
else
$(BINDIR)/%.exe:  $(OBJDEST)/%.o $(DEPLIBS) $(EXTRA_LIBS_DEP) 
	$(LINK_EXE) $(OBJDEST)/$*.o $(OBJDEST)/init_ds_env.o $(NSPRLINK) 
endif

$(LDAP_SERVER_RELDIR)/namegen.exe:  $(OBJDEST)/namegen.o
	$(LINK_EXE_NOLIBSOBJS) $^

$(LDAP_SERVER_RELDIR)/latest_file.exe:  $(OBJDEST)/latest_file.o
	$(LINK_EXE_NOLIBSOBJS) $^

installPerlFiles:  $(BINDIR) $(PERL_SCRIPTS_DEST)

$(BINDIR)/%: %
	-@$(RM) $@
	$(CP) $< $@
	chmod +x $@

$(LDAP_SERVER_RELDIR)/%: % $(LDAP_SERVER_RELDIR)
	-@$(RM) $@
	$(CP) $< $@
	chmod +x $@

$(INST_INCLUDES): install_keywords.h
	-@$(RM) $@
	$(CP) $< $@

$(SCRIPTSDIR)/template-%: scripts/template-% $(SCRIPTSDIR)
	-@$(RM) $@
	$(CP) $< $@
	chmod +x $@

$(RELDIR)/shared/bin/%: sec_tools_wrapper $(RELDIR)/shared/bin
	-@$(RM) $@
	$(CP) $< $@
	chmod +x $@