#
# The contents of this file are subject to the Netscape Public License
# Version 1.0 (the "NPL"); you may not use this file except in
# compliance with the NPL.  You may obtain a copy of the NPL at
# http://www.mozilla.org/NPL/
#
# Software distributed under the NPL is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
# for the specific language governing rights and limitations under the
# NPL.
#
# The Initial Developer of this code under the NPL is Netscape
# Communications Corporation.  Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation.  All Rights
# Reserved.
# 

DEPTH		= ../../..
topsrcdir	= @top_srcdir@
srcdir		= @srcdir@
VPATH		= @srcdir@

include $(DEPTH)/config/autoconf.mk

MODULE		= pref
LIBRARY_NAME	= pref

REQUIRES	= js pref dbm security ldap img layer xpcom util

ifneq ($(subst /,_,$(shell uname -s)),OS2)
CSRCS		= unix/unixpref.c
else
CSRCS		= prefldap.c
LIBRARY		= xppref32.$(LIB_SUFFIX)
EXPORTS		= initpref.js init/all.js init/config.js win/winpref.js os2/os2pref.js
OS2_IMPLIB	= 1
DEF_FILE	= xpOS2.def
EXTRA_LIBS	= $(DIST)/lib/js$(MOZ_BITS)$(VERSION_NUMBER).lib \
		  $(LIBNSPR) \
		  $(DIST)/lib/libldap.lib $(DIST)/lib/liblber.lib \
		  $(DIST)/lib/libldap.lib $(DIST)/lib/libhash.lib \
		  $(NULL)
endif

CSRCS		+= prefapi.c

CPPSRCS		+= nsPref.cpp

include $(topsrcdir)/config/rules.mk

INCLUDES	+= -I$(topsrcdir)/cmd/xfe/icons -I$(srcdir)/unix -Iunix

DEFINES		+= -DB1M

GARBAGE		+= unix/jsbuffer.h

CONFIG_FILES	= initpref.js \
		  init/all.js \
		  $(NULL)

ifdef MOZ_MAIL_NEWS
CONFIG_FILES	+= \
		  init/mailnews.js \
		  $(NULL)
endif

ifdef MOZ_SECURITY
CONFIG_FILES	+= \
		  init/security.js \
		  $(NULL)
endif

ifdef MOZ_EDITOR
CONFIG_FILES	+= \
		  init/editor.js \
		  $(NULL)
endif

ifndef MOZ_MAIL_NEWS
CONFIG_FILES	+= \
		  init/configr.js \
		  $(NULL)
else
CONFIG_FILES	+= \
		  init/config.js \
		  $(NULL)
endif

CONFIG_FILES	+= \
		  unix/unix.js \
		  $(NULL)

CONFIG_FILES	:= $(addprefix $(srcdir)/, $(CONFIG_FILES))

$(LIBRARY): $(OBJS)

unix/unixpref.c: unix/jsbuffer.h
	@if test ! -d unix; then rm -f unix && mkdir -p unix; fi
	@if test ! -f $@; then $(INSTALL) $(srcdir)/unix/unixpref.c unix/; fi

unix/jsbuffer.h: Makefile $(CONFIG_FILES)
	@if test ! -d unix; then rm -f unix && mkdir -p unix; fi
	@(echo "/* This is an automatically generated file */" > $@; \
	 echo >> $@; \
	 echo "static char* pref_init_buffer = " >> $@; \
	 cat $(CONFIG_FILES) | sed 's/\\/\\\\/g' | sed 's/\\r/\\n/' | sed 's/\"/\\\"/g' | sed 's/^M//g' | sed 's/^/"/' | sed 's/$$/\\n"/' >> $@; \
	echo \; >> $@; \
	)
