# BEGIN COPYRIGHT BLOCK
# Copyright (C) 2001 Sun Microsystems, Inc. Used by permission.
# Copyright (C) 2005 Red Hat, Inc.
# All rights reserved.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation version
# 2.1 of the License.
#  
# This library 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
# Lesser General Public License for more details.
#  
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
# END COPYRIGHT BLOCK
#
#
.SUFFIXES: .cc

BUILD_ROOT=../../..

include $(BUILD_ROOT)/nsdefs.mk

NOSTDCLEAN=true
NOSTDSTRIP=true

override BUILD_MODULE=SetupSDK

# Build artifacts
LIBDEST=$(OBJDIR)/lib
OBJDEST=$(LIBDEST)/libinstall

STAGE=$(OBJDIR)/$(DIR)

OBJS=$(addprefix $(OBJDEST)/,ux-util.o ux-curse.o dialog.o ux-wrapper.o)
INCS=ux-util.h dialog.h

LIBS=$(LIBDEST)/libinstall.a

include $(BUILD_ROOT)/nsconfig.mk

# For staging
DISTINC=$(OBJDIR)/include
DISTLIB=$(LIBS)

MCC_INCLUDE = -I$(LDAP_INCLUDE) -I../../include

ifeq ($(ARCH), BSDI)
CFLAGS += -DNO_DOMAINNAME
endif

ifeq ($(ARCH), HPUX)
ifeq ($(NSOS_RELEASE),B.11.00)
MODERNHP=1
endif
ifeq ($(NSOS_RELEASE), B.11.11)
MODERNHP=1
endif

ifdef MODERNHP
ifeq ($(USE_64), 1)
CURSES=-lHcurses
else
CFLAGS += -D__HP_CURSES
CURSES=-lHcurses
EXTRA_LIBS+= -ld4r
endif
else
CURSES=/usr/lib/libcurses.a
endif
else
CURSES=-lcurses -ltermcap
endif

all: $(LIBDEST) $(OBJDEST) $(OBJS) $(LIBS) $(STAGE)

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

$(LIBDEST):
	mkdir -p $(LIBDEST)

$(DISTINC):
	mkdir -p $(DISTINC)

$(LIBS): $(OBJS) $(CURSES)
	$(AR) $?
	$(RANLIB) $@

$(STAGE): $(DISTINC)
	cp $(INCS) $(DISTINC)

clean:
	$(RM) -f $(OBJS) $(LIBS) *.o $(PUREFILES)
	@echo
	cd $(DISTINC); $(RM) -f $(INCS);

$(OBJDEST)/%.o: %.cc
	@echo
	$(CXX) $(NONSHARED) -c $(CFLAGS) $(MCC_INCLUDE) $< -o $(OBJDEST)/$*.o

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

