# Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
#  This software is the proprietary information of Sun Microsystems, Inc.
#  Use is subject to license terms.
#  
#  Copyright 2004 Sun Microsystems, Inc.  Tous droits rservs.
#  Ce logiciel est proprit de Sun Microsystems, Inc.
#  Distribu par des licences qui en restreignent l'utilisation.
# 
# ident        "@(#)Makefile.distrib 1.5     04/08/05 SMI"
# 

# include any conf files
ROOT_DIR= ../../../..
OS := $(shell uname -s)
MKDIR=mkdir
RM=rm


# Compiled library name:
LIBNAME=libhttpd.so
#Short library name
LIBSHORTNAME=${LIBNAME:.so=}

# Define the libinstrum stucture from the BUILD_DEST location 

#Fix for bugID 5072867
MFWK_LIB_SUNOS_PATH=/opt/SUNWmfwk/lib
MFWK_LIB_LINUX_PATH=/opt/sun/mfwk/lib
NSPR_LIB_SUNOS_PATH=/usr/lib/mps
NSPR_LIB_LINUX_PATH=/opt/sun/private/lib
RT_LINKER_PATH_SUNOS=$(MFWK_LIB_SUNOS_PATH):$(NSPR_LIB_SUNOS_PATH)
RT_LINKER_PATH_LINUX=$(MFWK_LIB_LINUX_PATH):$(NSPR_LIB_LINUX_PATH)



#INCLUDE_DIR=$(ROOT_DIR)/include
LIB_DIR=$(ROOT_DIR)/lib

CFLAGS+=-I$(INCLUDE_DIR)   -I/usr/include
LIB_LDFLAGS+= 
# Here, XXX in fact nspr should be installed in a standard place
# ie. we now have a dependency on nspr, so our
# library should know where to find it.
ifeq ($(OS), SunOS)
LIB_LDFLAGS+=-L$(NSPR_LIB_SUNOS_PATH) -L$(MFWK_LIB_SUNOS_PATH) -G -z defs -z nodelete -z now  -lsocket -R $(RT_LINKER_PATH_SUNOS)
CC=cc
endif
ifeq (${OS}, Linux)
LIB_LDFLAGS+=-L$(NSPR_LIB_LINUX_PATH) -L$(MFWK_LIB_LINUX_PATH) -shared -Wl,-rpath,$(RT_LINKER_PATH_LINUX) -Wl,-h$(LIBNAME)
CC=gcc
endif
LIBS+=-lc -lpthread -lnsl -lrt -lplds4 -lmfRserver -lmfTransaction 


# List of .c files to compile:
CFILES= alog.c      circfile.c  httpd.c

#INCLUDES=$(INCLUDE_DIR)/mfCserver.h

# List of .o object files to generate:
OFILES=${CFILES:.c=.o}
OBJS = $(addprefix $(OBJDEST)/, $(OFILES))



all:$(LIBNAME) 

%.o: %.c
	$(CC) $(CFLAGS) -c $<

$(LIBNAME):$(OFILES) \
	$(INCLUDES) Makefile
	$(CC) $(LIB_LDFLAGS) $(LIBS) -o $@ $(OFILES)



clean:
	-$(RM) -rf *.o
	-$(RM) -rf *.a *.so
