Avoid 'ifdef USE_GTK' in code with more clever Makefile?
Jan-Oliver Wagner <[email protected]> Thu, 7 Oct 2004 12:24:12 +0200
| Newsgroups | gmane.comp.security.nessus.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi, I wonder whether it would be OK to avoid a number of ifdef USE_GTK in the code in nessus-core/nessus by already detecting in the Makefile which modules are to be included depending on whether GTK is opted or not. Also, the modules would not even be linked anymore if nessus is build without GTK. A sample patch is attached. The only thing I am not sure of is whether $(if ..) construct is support by most make tools. So my proposal is to have my patch applied for only the two modules and wait whether there is anyone out there reporting problems. In that case I can immediately resolve the problem and apply the current style. If there will be no problems reported for a couple of month we could then apply the new method for all gtk modules. Best Jan -- Jan-Oliver Wagner http://intevation.de/~jan/ Intevation GmbH http://intevation.de/ FreeGIS http://freegis.org/ _______________________________________________ Nessus-devel mailing list [email protected] http://mail.nessus.org/mailman/listinfo/nessus-devel
Makefile.diff
(text/plain, 1.5 KB)
Index: Makefile
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/Makefile,v
retrieving revision 1.52.4.8
diff -u -3 -p -r1.52.4.8 Makefile
--- Makefile 7 Oct 2004 09:25:16 -0000 1.52.4.8
+++ Makefile 7 Oct 2004 10:14:49 -0000
@@ -58,7 +58,8 @@ OBJS = auth.o \
dirutils.o \
sslui.o \
nessus.o
-
+
+GTK_OBJS = prefs_comment.o prefs_dialog_prefs.o
all : cflags ${make_bindir}/nessus
@@ -74,8 +75,8 @@ cflags :
@rm cflags.tmp
@chmod +x cflags
-nessus : cflags $(OBJS)
- $(CC) $(LDFLAGS) $(OBJS) -o nessus $(LIBS)
+nessus : cflags $(OBJS) $(if $(USE_GTK),$(GTK_OBJS))
+ $(CC) $(LDFLAGS) $(OBJS) $(if $(USE_GTK),$(GTK_OBJS)) -o nessus $(LIBS)
detached_index.o : cflags detached_index.c
$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c detached_index.c
@@ -121,6 +122,14 @@ prefs_dialog_plugins_prefs.o : cflags pr
prefs_kb.o : cflags prefs_dialog/prefs_kb.c prefs_dialog/prefs_help.h globals.h
$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c prefs_dialog/prefs_kb.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_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
error_dialog.o : cflags error_dialog.c error_dialog.h globals.h
$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c error_dialog.c