Hi Mickey,

> > this code needs massive cleanup.  It is almost impossible to review this 
> code.
> 
> Agreed. The code layout is a bit on the ugly side. Patches very welcome.

lets start simple. Attached is a patch that cleans up the mess around
autoconf/automake and has at least auto-generation (and cleanup) of the
D-Bus binding files. Also now "make maintainer-clean" works as expected.

It cleans also the mess around the CFLAGS etc. That stuff was quite ugly
and reminded me as copied from some crazy GTK+ template. Non of this
crap is needed since it actually is only a daemon.

After this patch you can remove src/mux.h and m4/ from the subversion
repository since that is no longer needed.

Regards

Marcel

Index: configure.ac
===================================================================
--- configure.ac	(revision 265)
+++ configure.ac	(working copy)
@@ -1,30 +1,38 @@
 AC_PREREQ(2.53)
-AC_INIT(gsm0710muxd, 0.9.1, http://www.freesmartphone.org/)
-AM_INIT_AUTOMAKE()
-AC_CONFIG_SRCDIR(src/gsm0710muxd.c)
+AC_INIT()
+
+AM_INIT_AUTOMAKE(gsm0710muxd, 0.9.1)
 AM_CONFIG_HEADER(config.h)
+
 AM_MAINTAINER_MODE
 
-AC_ISC_POSIX
+AC_PREFIX_DEFAULT(/usr/local)
+
+if (test "${CFLAGS}" = ""); then
+	CFLAGS="-Wall -O2"
+fi
+
+AC_LANG_C
+
 AC_PROG_CC
-dnl uncomment once Vala generates C99-compliant stuff
-dnl AC_PROG_CC_STDC
-AC_STDC_HEADERS
-AC_PROG_LIBTOOL
+AC_PROG_INSTALL
 
-dnl check dependencies
-PKG_CHECK_MODULES(DEPENDENCIES, dbus-1 glib-2.0 dbus-glib-1)
-AC_SUBST(DEPENDENCIES)
+PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.10, dummy=yes,
+				AC_MSG_ERROR(libglib-2.0 is required))
+AC_SUBST(DBUS_CFLAGS)
+AC_SUBST(DBUS_LIBS)
 
-dnl dbus
-DBUS_GLIB_BIN="`$PKG_CONFIG --variable=exec_prefix dbus-glib-1`/bin"
-AC_ARG_WITH(dbusbindir,[  --with-dbusbindir=DIR  dbus tools in DIR], [DBUS_GLIB_BIN="$withval"])
-echo "DBus tools location ${DBUS_GLIB_BIN}"
-AC_SUBST(DBUS_GLIB_BIN)
+PKG_CHECK_MODULES(DBUS, dbus-1 >= 1.0, dummy=yes,
+				AC_MSG_ERROR(libdbus is required))
+AC_SUBST(DBUS_CFLAGS)
+AC_SUBST(DBUS_LIBS)
 
-AC_OUTPUT([
-Makefile
-src/Makefile
-data/Makefile
-])
+PKG_CHECK_MODULES(DBUS_GLIB, dbus-glib-1 >= 0.70, dummy=yes,
+				AC_MSG_ERROR(libdbus-glib is required))
+AC_SUBST(DBUS_GLIB_CFLAGS)
+AC_SUBST(DBUS_GLIB_LIBS)
 
+DBUS_BINDING_TOOL="dbus-binding-tool"
+AC_SUBST(DBUS_BINDING_TOOL)
+
+AC_OUTPUT(Makefile src/Makefile data/Makefile)
Index: src/mux.xml
===================================================================
--- src/mux.xml	(revision 265)
+++ src/mux.xml	(working copy)
@@ -1,15 +1,5 @@
 <!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
 "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd";>
-<!-- # xml does not allow double-dash in comments :/
-dbus-binding-tool -\
--mode=glib-server -\
--prefix=mux src/mux.xml > src/mux.h
--->
-<!-- other types sample
-			<arg type="u" name="x" direction="in" />
-			<arg type="d" name="trouble" direction="in" />
-			<arg type="d" name="d_ret" direction="out" />
-	-->
 <node>
 	<!-- interface to a channel muxer as described in gsm07.10.
 	several pseudo ttys are muxed to one serial line. -->
Index: src/Makefile.am
===================================================================
--- src/Makefile.am	(revision 265)
+++ src/Makefile.am	(working copy)
@@ -1,26 +1,21 @@
-INCLUDES = -I$(top_srcdir)
 
-AM_CPPFLAGS = \
-  -DPKGDATADIR=\"$(pkgdatadir)\" \
-  -DTERMINAL_LOCALE_DIR=\""$(prefix)/$(DATADIRNAME)/locale"\" \
-  -DDATADIR=\""$(datadir)"\" -D_GNU_SOURCE
+sbin_PROGRAMS = gsm0710muxd
 
-AM_CFLAGS = -Wall -pedantic @DEPENDENCIES_CFLAGS@
+gsm0710muxd_SOURCES = gsm0710muxd.c
 
-# add the name of your application
-bin_PROGRAMS = gsm0710muxd
+gsm0710muxd_LDADD = @DBUS_GLIB_LIBS@ @DBUS_LIBS@ @GLIB_LIBS@
 
-# headers
-EXTRA_DIST = \
-  mux.h \
-  muxercontrol.h \
-  muxercontrol.c
+AM_CFLAGS = @GLIB_CFLAGS@ @DBUS_CFLAGS@ @DBUS_GLIB_CFLAGS@
 
-# add the sources to compile for your application
-gsm0710muxd_SOURCES = \
-  gsm0710muxd.c
+BUILT_SOURCES = mux-glue.h
 
-gsm0710muxd_LDADD  = @DEPENDENCIES_LIBS@
+nodist_gsm0710muxd_SOURCES = $(BUILT_SOURCES)
 
-MAINTAINERCLEANFILES  = config.h.in Makefile.in
+CLEANFILES = $(BUILT_SOURCES)
 
+EXTRA_DIST = mux.xml muxercontrol.h muxercontrol.c muxercontrol.vala
+
+MAINTAINERCLEANFILES = Makefile.in
+
+mux-glue.h: mux.xml
+	$(DBUS_BINDING_TOOL) --prefix=mux --mode=glib-server --output=$@ $<
Index: src/gsm0710muxd.c
===================================================================
--- src/gsm0710muxd.c	(revision 265)
+++ src/gsm0710muxd.c	(working copy)
@@ -709,7 +709,7 @@
 }
 
 #include "muxercontrol.c"
-#include "mux.h"
+#include "mux-glue.h"
 
 static int dbus_init()
 {
Index: data/Makefile.am
===================================================================
--- data/Makefile.am	(revision 265)
+++ data/Makefile.am	(working copy)
@@ -1,20 +1,19 @@
-#
-# misc. data files
-#
-# None yet
-# dist_pkgdata_DATA =
 
-dbusdir = ${sysconfdir}/dbus-1/system.d/
+dbusdir = $(sysconfdir)/dbus-1/system.d
+
 dist_dbus_DATA = gsm0710muxd.conf
 
-# Dbus system service file
 servicedir = $(datadir)/dbus-1/system-services
+
 service_in_files = org.freesmartphone.GSM.MUX.service.in
+
 service_DATA = $(service_in_files:.service.in=.service)
 
-# Rule to make the service file with bindir expanded
-$(service_DATA): $(service_in_files) Makefile
-	@sed -e "s|[EMAIL PROTECTED]@|$(bindir)|" $<> $@
+CLEANFILES = $(service_DATA)
 
-EXTRA_DIST = org.freesmartphone.GSM.MUX.service.in
+EXTRA_DIST = $(service_in_files)
 
+MAINTAINERCLEANFILES = Makefile.in
+
+$(service_DATA): $(service_in_files)
+	@sed -e "s|[EMAIL PROTECTED]@|$(bindir)|" $<> $@
Index: data/org.freesmartphone.GSM.MUX.service.in
===================================================================
--- data/org.freesmartphone.GSM.MUX.service.in	(revision 265)
+++ data/org.freesmartphone.GSM.MUX.service.in	(working copy)
@@ -1,4 +1,4 @@
 [D-BUS Service]
 Name=org.freesmartphone.GSM.MUX
[EMAIL PROTECTED]@/gsm0710muxd
[EMAIL PROTECTED]@/gsm0710muxd
 User=root
Index: autogen.sh
===================================================================
--- autogen.sh	(revision 265)
+++ autogen.sh	(working copy)
@@ -12,6 +12,6 @@
 echo "Running automake..." ; automake --add-missing --copy --gnu || exit 1
 
 if [ -z "$NOCONFIGURE" ]; then
-    ./configure "$@"
+    ./configure --enable-maintainer-mode --prefix=/usr --sysconfdir=/etc "$@"
 fi
 

Reply via email to