include ../nessus.tmpl

GTKLIBS= $(GTKCONFIG_LIBS)
INCLUDE = ${include} $(GTKCONFIG_CFLAGS) -Igdchart0.94b -Igdchart0.94b/gd1.3
LIBS = $(X_LIBS) $(X_CFLAGS) $(GTKLIBS) \
	$(RUN_LIBS) $(C_R_LIB) gdchart0.94b/gd1.3/libgd.a -lm  -L../libnessus -lnessus-client -lssl -lcrypto $(DL_LIB) -lz $(SOCKET_LIB)

NESSUS_INCLUDE=`sh ./cflags`	

OBJS = auth.o \
       nessus_plugin.o \
       comm.o \
       sighand.o \
       xstuff.o \
       cli.o \
       parser.o \
       plugin_infos.o \
       context.o \
       preferences.o \
       families.o \
       attack.o \
       report.o \
       report_save.o \
       report_utils.o \
       nsr_output.o  \
       nbe_output.o \
       html_output.o \
       latex_output.o \
       text_output.o \
       xml_output.o \
       xml_output_ng.o \
       html_graph_output.o \
       error_dialog.o \
       password_dialog.o \
       monitor_dialog.o \
       backend.o \
       data_mining.o \
       prefs_dialog.o \
       prefs_scope_tree.o \
       prefs_dialog_misc.o \
       prefs_dialog_scan_opt.o \
       prefs_dialog_user.o \
       prefs_dialog_auth.o \
       prefs_dialog_plugins_prefs.o \
       prefs_plugins.o \
       prefs_plugins_tree.o \
       prefs_target.o \
       prefs_about.o \
       prefs_kb.o \
       listnotebook.o \
       read_target_file.o \
       gdchart0.94b/gdc.o \
       gdchart0.94b/price_conv.o \
       gdchart0.94b/gdc_pie.o \
       gdchart0.94b/gdchart.o \
       regex.o \
       filter.o \
       dirutils.o \
       sslui.o \
       nessus.o 

GTK_OBJS = prefs_comment.o prefs_context.o prefs_options.o prefs_report.o \
           prefs_dialog_prefs.o prefs_scan_assistant.o pdf_output.o

all : cflags ${make_bindir}/NessusClient


${make_bindir}/NessusClient : cflags NessusClient
	test -d ${make_bindir} || mkdir ${make_bindir}
	cp NessusClient ${make_bindir}

        
cflags : 
	@echo "$(NESSUS_CFLAGS) $(NESSUS_DEFS) -DPACKAGE=\"NessusClient\" $(INCLUDE)"  | sed 's/\"/\\\"/g' > cflags.tmp
	@echo "echo \"`cat cflags.tmp`\"" > cflags
	@rm cflags.tmp
	@chmod +x cflags

NessusClient : cflags $(OBJS) $(if $(USE_GTK),$(GTK_OBJS)) \
   ../libnessus/libnessus-client.a
	$(CC) $(LDFLAGS) $(OBJS) $(if $(USE_GTK),$(GTK_OBJS)) -o NessusClient $(LIBS) 


context.o : cflags context.c context.h error_dialog.h
	$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c context.c 

preferences.o : cflags preferences.c preferences.h error_dialog.h globals.h
	$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c preferences.c 

prefs_dialog.o : cflags prefs_dialog/prefs_dialog.c prefs_dialog/prefs_dialog.h\
 prefs_dialog/prefs_help.h globals.h context.h prefs_dialog/prefs_context.h\
 error_dialog.h prefs_dialog/prefs_comment.h \
 xpm/connect_16.xpm xpm/connected.xpm xpm/connect_24.xpm xpm/disconnect_16.xpm\
 xpm/access_rules.xpm xpm/credentials.xpm xpm/general_prefs.xpm \
 xpm/knowledgebase.xpm xpm/plugins.xpm xpm/properties.xpm \
 xpm/target_selection.xpm
	$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c prefs_dialog/prefs_dialog.c 

prefs_scope_tree.o : cflags prefs_dialog/prefs_scope_tree.c error_dialog.h \
  globals.h preferences.h context.h prefs_dialog/prefs_context.h \
  xpm/connected.xpm
	$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c prefs_dialog/prefs_scope_tree.c 

prefs_dialog_misc.o : cflags prefs_dialog/prefs_dialog_misc.c prefs_dialog/prefs_dialog_misc.h globals.h
	$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c prefs_dialog/prefs_dialog_misc.c 

prefs_dialog_scan_opt.o : cflags prefs_dialog/prefs_dialog_scan_opt.c\
 prefs_dialog/prefs_dialog_scan_opt.h error_dialog.h globals.h
	$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c prefs_dialog/prefs_dialog_scan_opt.c 

prefs_target.o : cflags prefs_dialog/prefs_target.c\
 prefs_dialog/prefs_target.h read_target_file.h
	$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c prefs_dialog/prefs_target.c 

prefs_dialog_user.o : cflags prefs_dialog/prefs_dialog_user.c globals.h
	$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c prefs_dialog/prefs_dialog_user.c 

prefs_dialog_auth.o : cflags prefs_dialog/prefs_dialog_auth.c \
 prefs_dialog/prefs_help.h globals.h context.h error_dialog.h
	$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c prefs_dialog/prefs_dialog_auth.c 

nessus_plugin.o : cflags nessus_plugin.c
	$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c nessus_plugin.c

prefs_plugins.o : cflags prefs_dialog/prefs_plugins.c error_dialog.h\
                  prefs_dialog/prefs_help.h prefs_dialog/prefs_plugins_tree.h\
		  globals.h
	$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c prefs_dialog/prefs_plugins.c 

prefs_plugins_tree.o : cflags prefs_dialog/prefs_plugins_tree.c \
	prefs_dialog/prefs_plugins_tree.h filter.h \
	error_dialog.h prefs_dialog/prefs_help.h globals.h \
	plugin_infos.h families.h xpm/warning_small.xpm
	$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c prefs_dialog/prefs_plugins_tree.c 

prefs_dialog_plugins_prefs.o : cflags prefs_dialog/prefs_dialog_plugins_prefs.c context.h \
	prefs_dialog/listnotebook.h
	$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c prefs_dialog/prefs_dialog_plugins_prefs.c 

prefs_kb.o : cflags prefs_dialog/prefs_kb.c prefs_dialog/prefs_help.h \
 context.h
	$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c prefs_dialog/prefs_kb.c

prefs_context.o : cflags prefs_dialog/prefs_context.c globals.h context.h \
 preferences.h error_dialog.h prefs_dialog/prefs_comment.h
	$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c prefs_dialog/prefs_context.c

prefs_comment.o : cflags prefs_dialog/prefs_comment.c \
                  prefs_dialog/prefs_comment.h globals.h
	$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c prefs_dialog/prefs_comment.c

prefs_options.o : cflags prefs_dialog/prefs_options.c \
                  prefs_dialog/prefs_options.h prefs_dialog/listnotebook.h \
		  globals.h
	$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c prefs_dialog/prefs_options.c

prefs_report.o : cflags prefs_dialog/prefs_report.c \
 prefs_dialog/prefs_report.h globals.h xpm/computer.xpm xpm/network.xpm \
 xpm/warning_small.xpm xpm/info_small.xpm xpm/error_small.xpm xpm/nothing.xpm
	$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c prefs_dialog/prefs_report.c

prefs_dialog_prefs.o : cflags prefs_dialog/prefs_dialog_prefs.c \
                  prefs_dialog/prefs_dialog_prefs.h globals.h
	$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c prefs_dialog/prefs_dialog_prefs.c

prefs_scan_assistant.o : cflags prefs_dialog/prefs_scan_assistant.c \
 error_dialog.h context.h prefs_dialog/prefs_context.h \
 prefs_dialog/prefs_scope_tree.h prefs_dialog/prefs_dialog.h \
 prefs_dialog/prefs_dialog_auth.h
	$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c prefs_dialog/prefs_scan_assistant.c

listnotebook.o : cflags prefs_dialog/listnotebook.c \
		  prefs_dialog/listnotebook.h
	$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c prefs_dialog/listnotebook.c

error_dialog.o : cflags error_dialog.c error_dialog.h globals.h
	$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c error_dialog.c 

families.o : cflags families.c families.h globals.h
	$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c families.c 

plugin_infos.o : cflags plugin_infos.c plugin_infos.h globals.h context.h
	$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c plugin_infos.c 

main_window.o : cflags main_window.c main_window.h
	$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c main_window.c 

nsr_output.o : cflags nsr_output.c nsr_output.h error_dialog.h
	$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c nsr_output.c 

nbe_output.o : cflags nbe_output.c nbe_output.h error_dialog.h
	$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c nbe_output.c 
	
	
html_output.o : cflags html_output.c html_output.h error_dialog.h globals.h
	$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c html_output.c 

text_output.o : cflags text_output.c text_output.h error_dialog.h globals.h
	$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c text_output.c 

xml_output.o : cflags xml_output.c xml_output.h error_dialog.h globals.h
	$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c xml_output.c

xml_output_ng.o : cflags xml_output_ng.c  error_dialog.h globals.h context.h
	$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c xml_output_ng.c

latex_output.o : cflags latex_output.c latex_output.h globals.h
	$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c latex_output.c 

html_graph_output.o : cflags html_graph_output.c html_graph_output.h error_dialog.h globals.h
	$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c html_graph_output.c 

pdf_output.o : cflags pdf_output.c pdf_output.h globals.h
	$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c pdf_output.c

monitor_dialog.o : cflags monitor_dialog.c monitor_dialog.h globals.h \
 context.h report.h xpm/computer.xpm \
 prefs_dialog/prefs_context.h prefs_dialog/prefs_scope_tree.h
	$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c monitor_dialog.c 
	
backend.o : cflags backend.c backend.h error_dialog.h
	$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c backend.c 	

data_mining.o : cflags data_mining.c data_mining.h
	$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c data_mining.c 	

report_utils.o : cflags report_utils.h report_utils.c
	$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c report_utils.c 

nessus.o : cflags nessus.c globals.h context.h preferences.h nessus.h
	$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c nessus.c 

sighand.o : cflags sighand.c sighand.h error_dialog.h context.h backend.h auth.h
	$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c sighand.c 

auth.o : cflags auth.c globals.h
	$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c auth.c 

comm.o : cflags comm.c error_dialog.h globals.h context.h
	$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c comm.c 

report.o : cflags report.c error_dialog.h globals.h context.h \
 prefs_dialog/prefs_scope_tree.h prefs_dialog/prefs_context.h
	$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c report.c 

report_save.o : cflags report_save.c preferences.h context.h error_dialog.h
	$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c report_save.c 	

parser.o : cflags parser.c error_dialog.h globals.h
	$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c parser.c 

attack.o : cflags attack.c globals.h context.h
	$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c attack.c 

password_dialog.o : cflags password_dialog.c error_dialog.h globals.h
	$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c password_dialog.c 

xstuff.o : cflags xstuff.c globals.h
	$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c xstuff.c 

cli.o : cflags cli.c cli.h globals.h preferences.h
	$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c cli.c

read_target_file.o : cflags read_target_file.c error_dialog.h globals.h
	$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c read_target_file.c 

prefs_about.o : cflags prefs_dialog/prefs_about.c globals.h \
 xpm/nessus.xpm xpm/logo_tenable.xpm xpm/logo_intevation.xpm xpm/logo_bsi.xpm \
 xpm/logo_bsi_de.xpm
	$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c prefs_dialog/prefs_about.c 


regex.o : cflags regex.c 
	$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c regex.c 

filter.o : cflags filter.c error_dialog.h
	$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c filter.c 

dirutils.o : cflags dirutils.c
	$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c dirutils.c

sslui.o : cflags sslui.c globals.h xpm/lock.xpm
	$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c sslui.c

gdchart0.94b/gdc.o : cflags
	cd gdchart0.94b && $(MAKE)

gdchart0.94b/gdchart.o : cflags
	cd gdchart0.94b && $(MAKE)

gdchart0.94b/price_conv.o : cflags
	cd gdchart0.94b && $(MAKE)

gdchart0.94b/gdc_pie.o : cflags
	cd gdchart0.94b && $(MAKE)
clean : 
	rm -f *.o NessusClient *~ cflags prefs_dialog/*.o
	cd gdchart0.94b && $(MAKE) clean
