BIN_PATH = /home/httpd/cgi-bin/network/dns_setting
SBIN_PATH = /usr/sbin
INITD_PATH = /etc/init.d

CC = ${CROSS_COMPILE}gcc
OBJFLAGS = -fPIC -Wall -c
APPCFLAGS = -s -O2
LIBS = -L${TARGET_PREFIX}/usr/lib -luLinux_Storage -luLinux_NAS -luLinux_cgi -luLinux_config -luLinux_PDC -luLinux_statistics -luLinux_quota -luLinux_Util -lpthread
INCLUDE = -I$(NAS_LIB_PATH)/hd -I$(NAS_LIB_PATH)/public_lib -I$(NAS_LIB_PATH)/NAS -I$(NAS_LIB_PATH)/config -I$(NAS_LIB_PATH)/include -I$(NAS_LIB_PATH)/uLinux -I$(NAS_LIB_PATH)/cgi -I$(NAS_LIB_PATH)/util

PROGS = dns_setting.cgi
CREATE_ZONE_PROG = create_zone_file

OBJS = dns_main.o dns_zone.o

TESTOBJS = test.o dns_zone.o

START_SHELL = named.sh
INSTALL_SHELL = install.sh
SEHLL = /bin/sh
SRCDIR = .

#DEBUG = -g -D_DEBUG

all:	$(PROGS) $(CREATE_ZONE_PROG)

%.o :			%.c
			$(CC) $(DEBUG) -c $< $(INCLUDE)

test :			$(TESTOBJS)
			$(CC) $(LIBS) $(INCLUDE) $(TESTOBJS) -o test

$(PROGS) :		$(OBJS)
			$(CC) $(DEBUG) $(APPCFLAGS) $(INCLUDE) $(OBJS) $(LIBS) -o $@

$(CREATE_ZONE_PROG) :
			$(CC) $(DEBUG) $(APPCFLAGS) $(INCLUDE) dns_zone.o $(CREATE_ZONE_PROG).c $(LIBS) -o $@

install :
	@ echo 'install file ...'
	@ $(SHELL) $(SRCDIR)/$(INSTALL_SHELL) $(ROOT_PATH)$(BIN_PATH) $(ROOT_PATH)$(BIN_PATH)/html $(ROOT_PATH)$(BIN_PATH)/inc
	install --mode=755 $(PROGS) $(ROOT_PATH)$(BIN_PATH)
	install --mode=755 $(CREATE_ZONE_PROG) $(ROOT_PATH)$(SBIN_PATH)
	install --mode=755 $(START_SHELL) $(ROOT_PATH)$(INITD_PATH)
	install --mode=644 html/*.html $(ROOT_PATH)$(BIN_PATH)/html
	install --mode=644 inc/*.js $(ROOT_PATH)$(BIN_PATH)/inc
#	install --mode=644 inc-CODEPAGE/*.js $(ROOT_PATH)$(BIN_PATH)/inc-CODEPAGE
#	/bin/ln -sf $(BIN_PATH)/inc-CODEPAGE $(ROOT_PATH)$(BIN_PATH)/inc
	#install --mode=644 named.root `getcfg "DNS" "DB path" -d "/var/named"`/named.root

clean :
	@ echo 'clear file ...'
	@ rm $(PROGS) $(CREATE_ZONE_PROG) test *.o -f

clean_test:
	@ echo 'clear test file...'
	@ rm test test.o -f
