#
# milli_httpd Makefile
#
# Copyright 2001-2003, Broadcom Corporation
# All Rights Reserved.
#
# THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
# KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
# SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
# FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
#
# $Id: Makefile,v 1.16 2003/12/25 09:30:22 honor Exp $
#

include $(TOP)/.config

ifneq ($(wildcard $(SRCBASE)/cy_conf.mak),)
  include $(SRCBASE)/cy_conf.mak
endif

CFLAGS	+= -I. -I$(TOP)/shared -I$(SRCBASE)/include -Wall -I$(SRCBASE)/
#CFLAGS	+= -I$(SRCBASE)/linux/linux/include
#CFLAGS	+= -g -DDEBUG
CFLAGS	+= -s -O1
LDFLAGS	+= -L$(TOP)/nvram -L$(INSTALLDIR)/nvram/usr/lib -lnvram -L$(TOP)/shared -L$(INSTALLDIR)/shared/usr/lib -lshared

#ifeq ($(HSIAB_SUPPORT),1)
#CFLAGS += -I$(TOP)/hsiab
#LDFLAGS += -L$(TOP)/openssl -L$(TOP)/hsiab -lcrypto -lssl -lhsiab
#OBJS += hsiab.o
#endif
#ifeq ($(HTTPS_SUPPORT),1)
#CFLAGS += -I$(TOP)/openssl/include  -I$(TOP)/openssl/include/openssl
#LDFLAGS += -L$(TOP)/openssl -L../openssl -lcrypto -lssl
#endif
#ifeq ($(BACKUP_RESTORE_SUPPORT),1)
#OBJS  += $(SRCBASE)/../tools/src/code_header.o backup_restore.o
#endif
ifeq ($(DDM_SUPPORT),1)
OBJS  += ddm.o
endif
ifeq ($(ARP_TABLE_SUPPORT),1)
OBJS  += arp.o
endif
ifeq ($(EMI_TEST),1)
OBJS  += emi_test.o
endif
ifeq ($(SETUP_WIZARD_SUPPORT),1)
OBJS  += setup_wizard.o
endif
ifeq ($(DEBUG_WEB),1)
CFLAGS += -DMY_DEBUG
endif
ifeq ($(WAKE_ON_LAN_SUPPORT),1)
OBJS  += wol.o
endif
ifeq ($(SAMBA_SUPPORT),1)
OBJS  += samba.o
endif
#ifeq ($(HW_QOS_SUPPORT),1)
#OBJS  += qos.o
#endif
ifeq ($(PERFORMANCE_SUPPORT),1)
OBJS  += performance.o
endif
#ifeq ($(WL_STA_SUPPORT),1)
OBJS  += site_suvery.o
#endif


ifeq ($(CONFIG_OPENSSL),y)
CFLAGS += -I$(TOP)/openssl/include  -I$(TOP)/openssl/include/openssl
LDFLAGS += -L$(TOP)/openssl -L../openssl -lcrypto -lssl
CFLAGS += -DHAVE_OPENSSL
endif

ifeq ($(CONFIG_MATRIXSSL),y)
CFLAGS += -I$(TOP)/matrixssl
LDFLAGS += -L$(TOP)/matrixssl/src -lmatrixssl
CFLAGS += -DHAVE_MATRIXSSL
OBJS += matrixssl_xface.o
endif

#OBJS  += common.o server.o
#OBJS  += code_header.o
OBJS  += setup_wizard.o



vpath %.c $(TOP)/shared $(SRCBASE)/../tools/src

all: httpd

clean:
	rm -f *.o *~ httpd
	#Added by Daniel(2004-07-29)
	#cp ../shared/ezc.o ./
	#rm -rf $(SRCBASE)/../tools/src/code_header.o	

install:
	install -D httpd $(INSTALLDIR)/usr/sbin/httpd
	$(STRIP) $(INSTALLDIR)/usr/sbin/httpd
	install -d $(INSTALLDIR)/etc
	install *.pem $(INSTALLDIR)/etc

cert:
	# create the key and certificate request
	openssl req -new -out cert.csr -config openssl.cnf -keyout privkey.pem -days 3650 -newkey rsa:512
	# remove the passphrase from the key:
	openssl rsa -in privkey.pem -out key.pem
	# convert the certificate request into a signed certificate
	openssl x509 -in cert.csr -out cert.pem -req -signkey key.pem
	rm -f cert.csr privkey.pem
	# Show human-readable format
	openssl x509 -in cert.pem -text -noout

httpd: cgi.o ej.o httpd.o broadcom.o \
       index.o status.o dhcp.o log.o upgrade.o filters.o forward.o dynamic_route.o static_route.o wireless.o ddns.o \
       find_pattern.o lib.o diag.o sysinfo.o wepkey.o md5c.o wl_test.o getservice.o sveaweb.o nvramsr.o $(OBJS)
	$(CC) -o $@ $^ $(LDFLAGS)
	#Modify by Daniel(2004-07-29)
	#$(CC) -o $@ $^ ezc.o $(LDFLAGS)
	
build_date.o: build_date.c
build_date:
	echo "#define BUILD_DATE \"`date \"+%b %d %Y\"`\"" > build_date.c
	echo "#define BUILD_TIME \"`date \"+%H:%M:%S\"`\"" >> build_date.c


*.o: $(CY_DEPS)
