# BEGIN COPYRIGHT BLOCK
# Copyright (C) 2001 Sun Microsystems, Inc.  Used by permission.
# Copyright (C) 2005 Red Hat, Inc.
# All rights reserved.
#
# 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; either version 2
# of the License, or (at your option) any later version.
#
# 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
#

# END COPYRIGHT BLOCK
# The libsi18n library support for getting strings from the
# string database.

BUILD_ROOT=../..
MODULE=LibsI18N

OBJDEST=$(OBJDIR)/lib/libsi18n

include $(BUILD_ROOT)/nsconfig.mk

NSDEFS_PRODUCT = $(NS_PRODUCT)

L10NDIR = $(BUILD_ROOT)/l10n

ifeq ($(ARCH), WINNT)
CCOUT=  /Fe
LIBS=$(OBJDIR)/lib/libsi18n.lib
ifeq ($(BSCINFO), yes)
BSCS=$(OBJDIR)/lib/libsi18n.bsc
endif
else
LIBS=$(OBJDIR)/lib/libsi18n.a
CCOUT=  -o 
endif

ifeq ($(BUILD_MODULE), HTTP_ENTERPRISE)
StringDatabase = ns-httpd.properties
L10N_SERVER = httpd
DBTheaders = \
        ../../httpd/src/dbthttpd.h \
        ../../include/base/dbtbase.h \
        ../../include/frame/dbtframe.h \
        ../../include/httpdaemon/dbthttpdaemon.h \
        ../../include/libaccess/dbtlibaccess.h \
        ../../include/libadmin/dbtlibadmin.h \
        ../../include/libir/dbtlibir.h \
        gshttpd.h
endif

ifeq ($(BUILD_MODULE), HTTP_PERSONAL)
StringDatabase = ns-httpd.properties
L10N_SERVER = httpd
DBTheaders = \
        ../../httpd/src/dbthttpd.h \
        ../../include/base/dbtbase.h \
        ../../include/frame/dbtframe.h \
        ../../include/httpdaemon/dbthttpdaemon.h \
        ../../include/libaccess/dbtlibaccess.h \
        ../../include/libadmin/dbtlibadmin.h \
        gshttpd.h
endif

ifeq ($(BUILD_MODULE), HTTP_PROXY)
StringDatabase = ns-proxy.properties
DBTheaders = \
        ../../httpd/src/dbthttpd.h \
        ../../include/base/dbtbase.h \
        ../../include/frame/dbtframe.h \
        ../../include/httpdaemon/dbthttpdaemon.h \
        ../../include/libaccess/dbtlibaccess.h \
        ../../include/libadmin/dbtlibadmin.h \
        gsproxy.h
endif

ifeq ($(BUILD_MODULE), HTTP_ADMIN)
StringDatabase = ns-admin.properties
StringDatabaseEN = ns-admin_en.properties
L10N_SERVER = admserv
DBTheaders = \
        ../../admserv/src/dbtadmserv.h \
        ../../admserv/cgi-src/dbtcgiadmin.h \
        ../../admserv/user-forms/src/dbtuserforms.h \
        ../../include/base/dbtbase.h \
        ../../include/libadmin/dbtlibadmin.h \
        gsadmserv.h
endif

all: $(OBJDEST) $(LIBS) $(BSCS) $(OBJDEST)/$(StringDatabase) $(OBJDEST)/$(StringDatabaseEN)
#all: $(OBJDEST) $(LIBS) $(BSCS)

$(OBJDEST)/$(StringDatabase): makstrdb.c ../../include/i18n.h $(DBTheaders)
	@echo "Building String Database for $(BUILD_MODULE) in"
	@echo "$(OBJDEST)/$(StringDatabase)"
	$(CC) $(CFLAGS) $(MCC_INCLUDE) \
		$(CCOUT)$(OBJDEST)/makstrdb.exe \
		 makstrdb.c
	cd $(OBJDEST); ./makstrdb.exe
	rm $(OBJDEST)/makstrdb.exe

$(OBJDEST)/$(StringDatabaseEN): $(OBJDEST)/$(StringDatabase)
	-cp $(OBJDEST)/$(StringDatabase) $(OBJDEST)/$(StringDatabaseEN)

$(OBJDEST):
	mkdir -p $(OBJDEST)

OBJS = 	\
	$(OBJDEST)/acclanglist.o \
	$(OBJDEST)/getstrprop.o \
	$(OBJDEST)/getlang.o \
	$(OBJDEST)/coreres.o \
	$(OBJDEST)/txtfile.o \
	$(OBJDEST)/propset.o \
	$(OBJDEST)/reshash.o

$(LIBS): $(OBJS)
	rm -f $@
	$(AR) $(OBJS)
	$(RANLIB) $@
