Add support for a configure script
authorRoy Marples <roy@marples.name>
Mon, 24 May 2010 12:57:49 +0000 (12:57 +0000)
committerRoy Marples <roy@marples.name>
Mon, 24 May 2010 12:57:49 +0000 (12:57 +0000)
23 files changed:
.gitignore
Makefile
configure [new file with mode: 0755]
mk/cc.mk [deleted file]
mk/debug.mk [deleted file]
mk/depend-.mk [deleted file]
mk/depend-gmake.mk [deleted file]
mk/depend.mk
mk/dist.mk [deleted file]
mk/icon.mk
mk/lib.mk
mk/prog.mk
mk/sys.mk
src/Makefile
src/dhcpcd-gtk/GNUMakefile [new file with mode: 0644]
src/dhcpcd-gtk/Makefile
src/dhcpcd-gtk/main.c
src/libdhcpcd/GNUMakefile [new file with mode: 0644]
src/libdhcpcd/Makefile
src/libdhcpcd/Makefile.inc
src/libdhcpcd/libdhcpcd.h
src/libdhcpcd/main.c
src/libdhcpcd/wpa.c

index ea45b4b017830edb010656e02d93951f41cdbb71..50f50faff04721f8af7382d917dfdac86a25d4cc 100644 (file)
@@ -1 +1,3 @@
+config.h
+config.mk
 dhcpcd-ui-*.tar.bz2
index bf34733a4c068591082cb24c34f8ca21470e20f6..81f50c26c99cd5fc4525f625eb22aeaa7116b7ca 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -5,9 +5,41 @@ VERSION=       0.4.3
 
 SUBDIR=                src icons
 
-MK=    mk
-include ${MK}/subdir.mk
-include ${MK}/dist.mk
+TOPDIR=                .
+include ${TOPDIR}/config.mk
+include ${MKDIR}/subdir.mk
+
+GITREF?=       HEAD
+DISTPREFIX?=   ${PROG}-${VERSION}
+DISTFILE?=     ${DISTPREFIX}.tar.bz2
+
+CLEANFILES+=   *.tar.bz2
+
+_SNAP_SH=      date -u +%Y%m%d%H%M
+_SNAP!=                ${_SNAP_SH}
+SNAP=          ${_SNAP}$(shell ${_SNAP_SH})
+SNAPDIR=       ${DISTPREFIX}-${SNAP}
+SNAPFILE=      ${SNAPDIR}.tar.bz2
+
+dist:
+       mkdir /tmp/${DISTPREFIX}
+       cp -RPp * /tmp/${DISTPREFIX}
+       (cd /tmp/${DISTPREFIX}; make clean icons)
+       find /tmp/${DISTPREFIX} -name .gitignore -delete
+       tar -cvjpf ${DISTFILE} -C /tmp ${DISTPREFIX}
+       rm -rf /tmp/${DISTPREFIX}
+       ls -l ${DISTFILE}
+
+snapshot: icons
+       mkdir /tmp/${SNAPDIR}
+       cp -RPp * /tmp/${SNAPDIR}
+       (cd /tmp/${SNAPDIR}; make clean)
+       find /tmp/${SNAPDIR} -name .gitignore -delete
+       tar -cvjpf ${SNAPFILE} -C /tmp ${SNAPDIR}
+       rm -rf /tmp/${SNAPDIR}
+       ls -l ${SNAPFILE}
+
+snap: snapshot
 
 icons:
        ${MAKE} -C icons
diff --git a/configure b/configure
new file mode 100755 (executable)
index 0000000..315e68a
--- /dev/null
+++ b/configure
@@ -0,0 +1,260 @@
+#!/bin/sh
+# Try and be like autotools configure, but without autotools
+
+# Ensure that we do not inherit these from env
+DEBUG=
+LIBDHCPCD=no
+WITH_GTK=
+NOTIFY=yes
+
+for x; do
+       opt=${x%%=*}
+       var=${x#*=}
+       case "$opt" in
+       --os|OS) OS=$var;;
+       --with-cc|CC) CC=$var;;
+       --debug) DEBUG=$var;;
+       --disable-debug) DEBUG=no;;
+       --enable-debug) DEBUG=yes;;
+       --prefix) PREFIX=$var;;
+       --sysconfdir) SYSCONFDIR=$var;;
+       --bindir) BINDIR=$var;;
+       --libexecdir) LIBEXECDIR=$var;;
+       --statedir|--localstatedir) STATEDIR=$var;;
+       --rundir) RUNDIR=$var;;
+       --mandir) MANDIR=$var;;
+       --with-ccopts|CFLAGS) CFLAGS=$var;;
+       CPPFLAGS) CPPFLAGS=$var;;
+       --build) BUILD=$var;;
+       --host) HOST=$var;;
+       --target) TARGET=$var;;
+       --libdir) LIBDIR=$var;;
+       --datadir|--infodir) ;; # ignore autotools
+       --icondir) ICONDIR=$var;;
+       --with-gtk|--with-gtk+) WITH_GTK=${var:-yes};;
+       --without-gtk|--without-gtk+) WITH_GTK=no;;
+       --enable-notification) NOTIFY=yes;;
+       --disable-notification) NOTIFY=no;;
+       --help) echo "See the README file for available options"; exit 0;;
+       *) echo "$0: WARNING: unknown option $opt" >&2;;
+       esac
+done
+
+: ${INSTALL:=install}
+: ${SED:=sed}
+
+: ${PREFIX:=/usr/local}
+: ${SYSCONFDIR:=$PREFIX/etc}
+: ${BINDIR:=$PREFIX/bin}
+: ${LIBEXECDIR:=$PREFIX/libexec}
+: ${STATEDIR:=/var}
+: ${MANDIR:=${PREFIX:-/usr}/share/man}
+
+: ${ICONDIR:=$PREFIX/share/dhcpcd/icons}
+
+_which()
+{
+       x="$(which "$1" 2>/dev/null)"
+       if [ -n "$x" ]; then
+               echo "$x"
+               return 0
+       fi
+       for x in /sbin/"$1" /usr/sbin/"$1" \
+               /usr/pkg/sbin/"$1" /usr/local/sbin/"$1"
+       do
+               if [ -e "$x" ]; then
+                       echo "$x"
+                       return 0
+               fi
+       done
+       return 1
+}
+
+CONFIG_H=config.h
+CONFIG_MK=config.mk
+
+if [ -z "$BUILD" ]; then
+       BUILD=`uname -m`-unknown-`uname -s | tr '[:upper:]' '[:lower:]'`
+fi
+if [ -z "$HOST" ]; then
+       [ -z "$TARGET" ] && TARGET=$BUILD
+       HOST=$TARGET
+fi
+if [ -z "$TARGET" ]; then
+       [ -z "$HOST" ] && HOST=$BUILD
+       TARGET=$HOST
+fi
+
+if [ -z "$OS" ]; then
+       # Derive OS from cpu-manufacturer-os-kernel
+       CPU=${TARGET%%-*}
+       REST=${TARGET#*-}
+       MANU=${REST%%-*}
+       REST=${REST#*-}
+       OS=${REST%%-*}
+       REST=${REST#*-}
+       KERNEL=${REST%%-*}
+fi
+
+echo "Configuring dhcpcd-dbus for ... $OS"
+rm -f $CONFIG_H $CONFIG_MK
+echo "# $OS" >$CONFIG_MK
+echo "/* $OS */" >$CONFIG_H
+
+for x in PREFIX SYSCONFDIR BINDIRi ICONDIR; do
+       eval v=\$$x
+       # Make files look nice for import
+       l=$((10 - ${#x}))
+       unset t
+       [ $l -gt 3 ] && t="     "
+       echo "$x=$t     $v" >>$CONFIG_MK
+       unset t
+       [ $l -gt 2 ] && t="     "
+       echo "#define $x$t      \"$v\"" >>$CONFIG_H
+done
+
+if [ -z "$CC" ]; then
+       printf "Looking for compiler ... "
+       for b in $TARGET- ""; do
+               for cc in gcc pcc icc cc; do
+                       if type $b$cc >/dev/null 2>&1; then
+                               CC=$b$cc
+                               echo "$CC"
+                               break
+                       fi
+               done
+               [ -n "$CC" ] && break
+       done
+       if [ -z "$CC" ]; then
+               echo
+               echo "no suitable compiler found - aborting" >&2
+               exit 1
+       fi
+else
+       echo "Using compiler $CC"
+fi
+echo "CC=              $CC" >>$CONFIG_MK
+
+if [ -z "$CFLAGS"]; then
+       CFLAGS="-O2"
+fi
+echo "CFLAGS=          $CFLAGS" >>$CONFIG_MK
+if [ -n "$CPPLAGS" ]; then
+       echo "CPPLAGS=          $CPPLAGS" >>$CONFIG_MK
+fi
+
+if [ -n "$DEBUG" -a "$DEBUG" != no -a "$DEBUG" != false ]; then
+       echo "Enabling memory debugging"
+       echo "CPPFLAGS+=        -DDEBUG_MEMORY" >>$CONFIG_MK
+elif [ -z "$DEBUG" -a -d .git ]; then
+       printf "Found git ... "
+       DEBUG=yes
+       echo "LDADD+=           -Wl,-rpath=../libdhcpcd" >>$CONFIG_MK
+else
+       DEBUG=no
+fi
+if [ "$DEBUG" != no -a "$DEBUG" != false ]; then
+       echo "Adding debugging CFLAGS"
+       cat <<EOF >>$CONFIG_MK
+CFLAGS+=       -Wall -Wextra -Wimplicit -Wshadow -Wformat=2
+CFLAGS+=       -Wmissing-prototypes -Wmissing-declarations
+CFLAGS+=       -Wmissing-noreturn -Wmissing-format-attribute
+CFLAGS+=       -Wredundant-decls  -Wnested-externs
+CFLAGS+=       -Winline -Wwrite-strings -Wcast-align -Wcast-qual
+CFLAGS+=       -Wpointer-arith
+CFLAGS+=       -Wdeclaration-after-statement -Wsequence-point
+CFLAGS+=       -fno-common
+EOF
+fi
+
+# Add CPPFLAGS and CFLAGS to CC for testing features
+XCC="$CC `$SED -n -e 's/CPPLAGS+=*\(.*\)/\1/p' $CONFIG_MK`"
+XCC="$XCC `$SED -n -e 's/CFLAGS+=*\(.*\)/\1/p' $CONFIG_MK`"
+
+if [ -z "$STRLCPY" ]; then
+       printf "Testing for strlcpy ... "
+       cat <<EOF >_strlcpy.c
+#include <string.h>
+int main(void) {
+       const char s1[] = "foo";
+       char s2[10];
+       strlcpy(s2, s1, sizeof(s2));
+       return 0;
+}
+EOF
+       if $XCC _strlcpy.c -o _strlcpy 2>/dev/null; then
+               STRLCPY=yes
+       else
+               STRLCPY=no
+       fi
+       echo "$STRLCPY"
+       rm -f _strlcpy.c _strlcpy
+fi
+if [ "$STRLCPY" = no ]; then
+       echo "#define strlcpy(dst, src, n) snprintf(dst, n, \"%s\", src)" \
+       >>$CONFIG_H
+fi
+
+if [ -z "$LIBDIR" ]; then
+       printf "lib directory name ... "
+       case `readlink /lib` in
+               "") LIBNAME="lib";;
+               *) LIBNAME=$(basename `readlink /lib`);;
+       esac
+       echo "$LIBNAME"
+       echo "LIBNAME=  $LIBNAME" >>$CONFIG_MK
+       LIBDIR=${PREFIX}/${LIBNAME}
+       echo "LIBDIR=           \${PREFIX}/\${LIBNAME}" >>$CONFIG_MK
+else
+       echo "LIBDIR=   $LIBDIR" >>$CONFIG_MK
+fi
+
+# We normally want to build in the static library
+if [ "$LIBDHCPCD" = yes ]; then
+       x="-ldhcpcd"
+       echo "LIB_DHCPCD_INSTALL=       _libinstall" >>$CONFIG_MK
+else
+       x="-Wl,-Bstatic -ldhcpcd -Wl,-Bdynamic"
+fi
+echo "LIB_DHCPCD=      $x" >>$CONFIG_MK
+
+# Get DBus CFLAGS
+DBUS_CFLAGS=$(pkg-config --cflags dbus-1) || exit 1
+DBUS_LIBS=$(pkg-config --libs dbus-1) || exit 1
+echo "DBus CFLAGS=$DBUS_CFLAGS"
+echo "DBus LIBS=$DBUS_LIBS"
+echo "DBUS_CFLAGS=     $DBUS_CFLAGS" >>$CONFIG_MK
+echo "DBUS_LIBS=       $DBUS_LIBS" >>$CONFIG_MK
+
+UI=
+if [ "$WITH_GTK" = yes -o -z "$WITH_GTK" ]; then
+       PKG="gtk+-2.0"
+       if [ "$NOTIFY" = yes ]; then
+               PKG="$PKG${PKG:+ }libnotify"
+               echo "NOTIFY=           -DNOTIFY" >>$CONFIG_MK
+       fi
+       GTK_CFLAGS=$(pkg-config --cflags $PKG)
+       [ $? != 0 -a "$WITH_GTK" = yes ] && exit 1
+       GTK_LIBS=$(pkg-config --libs $PKG)
+       [ $? != 0 -a "$WITH_GTK" = yes ] && exit 1
+       echo "GTK+ CFLAGS=$GTK_CFLAGS"
+       echo "GTK+ LIBS=$GTK_LIBS"
+       echo "GTK_CFLAGS=       $GTK_CFLAGS" >>$CONFIG_MK
+       echo "GTK_LIBS= $GTK_LIBS" >>$CONFIG_MK
+       UI="$UI${UI:+ }dhcpcd-gtk"
+fi
+
+if [ -z "$UI" ]; then
+       echo "no UI is available, not building." >&2
+       exit 1
+fi
+echo "UI=              $UI" >>config.mk
+
+echo
+echo "   SYSCONFDIR =          $SYSCONFDIR"
+echo "   BINDIR =              $BINDIR"
+echo "   LIBDIR =              $LIBDIR"
+echo "   UI =                  $UI"
+echo
+
+echo "MKDIR=           \${TOPDIR}/mk" >>$CONFIG_MK
diff --git a/mk/cc.mk b/mk/cc.mk
deleted file mode 100644 (file)
index 16a5028..0000000
--- a/mk/cc.mk
+++ /dev/null
@@ -1,22 +0,0 @@
-# Copyright 2008 Roy Marples <roy@marples.name>
-
-# Setup some good default CFLAGS
-CFLAGS?=       -O2
-
-# Try and use some good cc flags
-# We don't use -pedantic as it will warn about our perfectly valid
-# use of %m in our logger.
-_CCFLAGS=      -Wall -Wextra -Wimplicit -Wshadow -Wformat=2 \
-               -Wmissing-prototypes -Wmissing-declarations \
-               -Wmissing-noreturn -Wmissing-format-attribute \
-               -Wredundant-decls  -Wnested-externs \
-               -Winline -Wwrite-strings -Wcast-align -Wcast-qual \
-               -Wpointer-arith \
-               -Wdeclaration-after-statement -Wsequence-point
-_CC_FLAGS_SH=  for f in ${_CCFLAGS}; do \
-               if echo "int main(void) { return 0;} " | \
-               ${CC} $$f -S -xc -o /dev/null - ; \
-               then printf "%s" "$$f "; fi \
-               done; fi
-_CC_FLAGS!=    ${_CC_FLAGS_SH}
-CFLAGS+=       ${_CC_FLAGS}$(shell ${_CC_FLAGS_SH})
diff --git a/mk/debug.mk b/mk/debug.mk
deleted file mode 100644 (file)
index 4008efa..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-# rules to enable debugging support
-# Copyright 2008 Roy Marples <roy@marples.name>
-# All rights reserved. Released under the 2-clause BSD license.
-
-_RC_DEBUG_SH=  case "${DEBUG}" in "") echo "";; *) echo "-DRC_DEBUG";; esac
-_RC_DEBUG!=    ${_RC_DEBUG_SH}
-CPPFLAGS+=     ${_RC_DEBUG}$(shell ${_RC_DEBUG_SH})
-
-# Should we enable this with a different flag?
-_LD_DEBUG_SH=  case "${DEBUG}" in "") echo "";; *) echo "-Wl,--rpath=../librc -Wl,--rpath=../libeinfo";; esac
-_LD_DEBUG!=    ${_LD_DEBUG_SH}
-LDFLAGS+=      ${_LD_DEBUG}$(shell ${_LD_DEBUG_SH})
-
-_GGDB_SH=      case "${DEBUG}" in "") echo "";; *) echo "-ggdb";; esac
-_GGDB!=                ${_GGDB_SH}
-CFLAGS+=       ${_GGDB}$(shell ${_GGDB_SH})
diff --git a/mk/depend-.mk b/mk/depend-.mk
deleted file mode 100644 (file)
index 9d13b52..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-# This space left intentionally blank because gmake does not load .depend
-# by default
diff --git a/mk/depend-gmake.mk b/mk/depend-gmake.mk
deleted file mode 100644 (file)
index 947843e..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-# Tell gmake to include the optional dependency file.
-# This sucks, but I don't know any other way of portably making this work.
--include .depend
index 1c8909f712d7e396bdabbdd3da10ba383732bbf3..9eca00f55759660e1e62d26da8540a99efb64b62 100644 (file)
@@ -8,11 +8,3 @@ CLEANFILES+=   .depend
        ${CC} ${CPPFLAGS} ${CFLAGS} -MM ${SRCS} > .depend
 
 depend: .depend
-
-
-# Nasty hack. depend-.mk is a blank file, depend-gmake.mk has a gmake specific
-# command to optionally include .depend.
-# Someone should patch gmake to optionally include .depend if it exists.
-_INC_DEP=      $(shell if ${MAKE} --version | grep -q "^GNU "; then \
-               echo "gmake"; else echo ""; fi)
-include ${MK}/depend-${_INC_DEP}.mk
diff --git a/mk/dist.mk b/mk/dist.mk
deleted file mode 100644 (file)
index 8c41f88..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-# rules to make a distribution tarball from a svn repo
-# Copyright 2008 Roy Marples <roy@marples.name>
-
-GITREF?=       HEAD
-DISTPREFIX?=   ${PROG}-${VERSION}
-DISTFILE?=     ${DISTPREFIX}.tar.bz2
-
-CLEANFILES+=   *.tar.bz2
-
-_SNAP_SH=      date -u +%Y%m%d%H%M
-_SNAP!=                ${_SNAP_SH}
-SNAP=          ${_SNAP}$(shell ${_SNAP_SH})
-SNAPDIR=       ${DISTPREFIX}-${SNAP}
-SNAPFILE=      ${SNAPDIR}.tar.bz2
-
-dist:
-       mkdir /tmp/${DISTPREFIX}
-       cp -RPp * /tmp/${DISTPREFIX}
-       (cd /tmp/${DISTPREFIX}; make clean icons)
-       tar -cvjpf ${DISTFILE} -C /tmp ${DISTPREFIX}
-       rm -rf /tmp/${DISTPREFIX}
-       ls -l ${DISTFILE}
-
-snapshot: icons
-       mkdir /tmp/${SNAPDIR}
-       cp -RPp * /tmp/${SNAPDIR}
-       (cd /tmp/${SNAPDIR}; make clean)
-       tar -cvjpf ${SNAPFILE} -C /tmp ${SNAPDIR}
-       rm -rf /tmp/${SNAPDIR}
-       ls -l ${SNAPFILE}
-
-snap: snapshot
index 80fd53ddda81e8045eb5058c94c49ab28a8a3aa1..18dfa19eedaf9c3437526caddf1f97cf111cb786 100644 (file)
@@ -1,7 +1,8 @@
 include ${MK}/sys.mk
 
 SIZEDIR?=      ${SIZE}x${SIZE}
-ICONDIR?=      ${PREFIX}/share/dhcpcd/icons/hicolor/${SIZEDIR}/${CATEGORY}
+ICONDIR?=      ${PREFIX}/share/dhcpcd/icons
+IDIR=          ${ICONDIR}/hicolor/${SIZEDIR}/${CATEGORY}
 
 RSVG_CONVERT?= rsvg-convert
 
@@ -16,8 +17,8 @@ all: ${ICONS}
        ${RSVG_CONVERT} -h ${SIZE} -w ${SIZE} $< >$@
 
 _iconinstall: ${ICONS}
-       ${INSTALL} -d ${DESTDIR}${ICONDIR}
-       ${INSTALL} -m ${NONBINMODE} ${ICONS} ${DESTDIR}${ICONDIR}
+       ${INSTALL} -d ${DESTDIR}${IDIR}
+       ${INSTALL} -m ${NONBINMODE} ${ICONS} ${DESTDIR}${IDIR}
 
 install: _iconinstall
 
index 707cfe692d396983438df9aef59804ef336fec41..6ed2b5aa61162348d38cef92bee01c22fa0493d9 100644 (file)
--- a/mk/lib.mk
+++ b/mk/lib.mk
@@ -1,5 +1,7 @@
 # rules to build a library
 
+include ${TOPDIR}/config.mk
+
 SHLIB=                 lib${LIB}.so.${SHLIB_MAJOR}
 SHLIB_LINK=            lib${LIB}.so
 LIBNAME=               lib${LIB}.a
@@ -37,7 +39,7 @@ ${SHLIB}:     ${SOBJS}
 
 _libinstall:   all
        ${INSTALL} -d ${DESTDIR}${LIBDIR}
-       ${INSTALL} -m ${LIBMODE} ${LIB} ${DESTDIR}${LIBDIR}
+       ${INSTALL} -m ${LIBMODE} ${LIBNAME} ${DESTDIR}${LIBDIR}
        ${INSTALL} -d ${DESTDIR}${SHLIBDIR}
        ${INSTALL} -m ${LIBMODE} ${SHLIB} ${DESTDIR}${SHLIBDIR}
        ln -fs ${SHLIB} ${DESTDIR}${SHLIBDIR}/${SHLIB_LINK}
@@ -54,5 +56,5 @@ extra_depend:
        ${SED} -e 's/^\([^\.]*\).o[ ]*:/\1.o \1.So:/' .depend > $${TMP}; \
        mv $${TMP} .depend
 
-include ${MK}/sys.mk
-include ${MK}/depend.mk
+include ${MKDIR}/sys.mk
+include ${MKDIR}/depend.mk
index 9b40e44eb1e12c99b26f6d6907f045ca730ad808..4a3e8e78862e14c4fe81b67801ee18a92a93ea3e 100644 (file)
@@ -1,9 +1,7 @@
 # rules to build a program 
 # based on FreeBSD's bsd.prog.mk
 
-# Copyright 2008 Roy Marples <roy@marples.name>
-
-include ${MK}/cc.mk
+# Copyright 2008-2010 Roy Marples <roy@marples.name>
 
 SRCS?=         ${PROG}.c
 OBJS+=         ${SRCS:.c=.o}
@@ -20,8 +18,9 @@ _proginstall: ${PROG}
        ${INSTALL} -d ${DESTDIR}${BINDIR}
        ${INSTALL} -m ${BINMODE} ${PROG} ${DESTDIR}${BINDIR}
 
-include ${MK}/depend.mk
-include ${MK}/files.mk
+include ${MKDIR}/sys.mk
+include ${MKDIR}/depend.mk
+include ${MKDIR}/files.mk
 
 install: _proginstall _filesinstall
 
index 73f189ec3535e4af6e7d0c5fbe13e6ccaa55e3c9..311a6ec1a2f3227724b270f3c810f9bb09ad14d1 100644 (file)
--- a/mk/sys.mk
+++ b/mk/sys.mk
@@ -5,6 +5,10 @@ PREFIX?=       /usr/local
 BINDIR?=       ${PREFIX}/bin
 BINMODE?=      0755
 NONBINMODE?=   0644
+LIBMODE?=      ${NONBINMODE}
+
+INCDIR?=       ${PREFIX}/include
+INCMODE?=      ${NONBINMODE}
 
 SYSCONFDIR?=   ${PREFIX}/etc
 
@@ -14,8 +18,6 @@ INSTALL?=     install
 RANLIB?=       ranlib
 SED?=          sed
 
-PICFLAG?=              -fPIC
+PICFLAG?=      -fPIC
 
-_LIBNAME_SH=           case `readlink /lib` in "") echo "lib";; *) basename `readlink /lib`;; esac
-_LIBNAME!=             ${_LIBNAME_SH}
-LIBNAME?=              ${_LIBNAME}$(shell ${_LIBNAME_SH})
+LIBNAME?=      lib
index e2f417b5fe869c78dda6dcaabd5cb71f8ad331e1..ce054e311c703d3d8ed527dd7ddb6267a5f6ea82 100644 (file)
@@ -1,12 +1,6 @@
-MKGTK?=                yes
-_GTK_SH=       case "${MKGTK}" in \
-               [Yy][Ee][Ss]) echo "dhcpcd-gtk";; \
-               *) echo "";; \
-               esac
-_GTK!=         ${_GTK_SH}
-GTK=           ${_GTK}$(shell ${_GTK_SH})
+TOPDIR=                ..
+include ${TOPDIR}/config.mk
 
-SUBDIR=                libdhcpcd ${GTK}
+SUBDIR=                libdhcpcd ${UI}
 
-MK=../mk
-include ${MK}/subdir.mk
+include ${MKDIR}/subdir.mk
diff --git a/src/dhcpcd-gtk/GNUMakefile b/src/dhcpcd-gtk/GNUMakefile
new file mode 100644 (file)
index 0000000..b1f636b
--- /dev/null
@@ -0,0 +1 @@
+.include .depend
index 55781dd38f6e860e72434292b475f89884c4a0a0..40db36a3e4bd158ba07f9c9b1bc3b4e988026b85 100644 (file)
@@ -1,30 +1,18 @@
-# Makefile based on BSD make.
-# Our mk stubs also work with GNU make.
-# Copyright 2008 Roy Marples <roy@marples.name>
-
 PROG=          dhcpcd-gtk
 SRCS=          main.c menu.c prefs.c wpa.c
 
+TOPDIR=                ../..
+include ${TOPDIR}/config.mk
+
 ICONDIR?=      ${PREFIX}/share/dhcpcd/icons
 SYSCONFDIR?=   ${PREFIX}/etc/xdg/autostart
 FILESDIR?=     ${SYSCONFDIR}
 FILES=         dhcpcd-gtk.desktop
 
-include ../libdhcpcd/Makefile.inc
-
-CPPFLAGS+=     -DICONDIR=\"${ICONDIR}\"
-CPPFLAGS+=     -DNOTIFY
-
-_PKGCFLAGS_SH= pkg-config --cflags gtk+-2.0 libnotify
-_PKGCFLAGS!=   ${_PKGCFLAGS_SH}
-PKGCFLAGS?=    ${_PKGCFLAGS}$(shell ${_PKGCFLAGS_SH})
-CFLAGS+=       ${PKGCFLAGS}
+CPPFLAGS+=     ${NOTIFY} -I${TOPDIR}
 
-_PKGLIBS_SH=   pkg-config --libs gtk+-2.0 libnotify
-_PKGLIBS!=     ${_PKGLIBS_SH}
-PKGLIBS?=      ${_PKGLIBS}$(shell ${_PKGLIBS_SH})
-LDADD+=                ${PKGLIBS}
+CFLAGS+=       ${GTK_CFLAGS}
+LDADD+=                ${LIB_DHCPCD} ${GTK_LIBS}
 
-MK=            ../../mk
-include ${MK}/sys.mk
-include ${MK}/prog.mk
+include ../libdhcpcd/Makefile.inc
+include ${MKDIR}/prog.mk
index c66243a1709e8ae2081b7628cf62a2c77ac38279..2754d5c901baf493a89f251272aec6da20a927fd 100644 (file)
@@ -34,6 +34,7 @@
 static NotifyNotification *nn;
 #endif
 
+#include "config.h"
 #include "dhcpcd-gtk.h"
 
 static GtkStatusIcon *status_icon;
diff --git a/src/libdhcpcd/GNUMakefile b/src/libdhcpcd/GNUMakefile
new file mode 100644 (file)
index 0000000..b1f636b
--- /dev/null
@@ -0,0 +1 @@
+.include .depend
index fb30f21eaa5b7527651fd417ce403655f02cc096..7115d8559f3b40bb3d20baa2fc733f059112e637 100644 (file)
@@ -1,21 +1,16 @@
 LIB=           dhcpcd
 SHLIB_MAJOR=   1
 SRCS=          main.c config.c dispatch.c misc.c wpa.c
+INCS=          libdhcpcd.h
 
-_PKGCFLAGS_SH= pkg-config --cflags dbus-1
-_PKGCFLAGS!=   ${_PKGCFLAGS_SH}
-PKGCFLAGS?=    ${_PKGCFLAGS}$(shell ${_PKGCFLAGS_SH})
-CFLAGS+=       ${PKGCFLAGS}
+TOPDIR=                ../..
+include ${TOPDIR}/config.mk
 
-_PKGLIBS_SH=   pkg-config --libs dbus-1
-_PKGLIBS!=     ${_PKGLIBS_SH}
-PKGLIBS?=      ${_PKGLIBS}$(shell ${_PKGLIBS_SH})
-LDADD+=                ${PKGLIBS}
+CPPFLAGS+=     -I${TOPDIR} ${DBUS_CFLAGS}
+CFLAGS+=       ${DBUS_CFLAGS}
+LDADD+=                ${DBUS_LIBS}
 
 # Don't install
-LIBINSTALL=
+LIBINSTALL=    ${LIB_DHCPCD_INSTALL}
 
-MK=            ../../mk
-include ${MK}/lib.mk
-include ${MK}/cc.mk
-include ${MK}/debug.mk
+include ${MKDIR}/lib.mk
index 887c57710fb082219ee67d24a5288143c22c751d..39cc327f521bba9f4f75b4f3492365626c57c3b1 100644 (file)
@@ -1,13 +1,4 @@
 CPPFLAGS+=     -I../libdhcpcd
 LDFLAGS+=      -L../libdhcpcd
 
-# We normally want to build in the static library
-MKSTATIC?=     yes
-_LDADD_SH=     case "${MKSTATIC}" in \
-               [Yy][Ee][Ss]) echo "-Wl,-Bstatic -ldhcpcd -Wl,-Bdynamic";; \
-               *) echo "-ldhcpcd";; \
-               esac
-_LDADD!=       ${_LDADD_SH}
-LDADD+=                ${_LDADD}$(shell ${_LDADD_SH})
-
 TARGETS+=      ../libdhcpcd/libdhcpcd.a
index 07ac6accefd9240920a9faf737e0e79b93d013b0..2555dde6d12c2136024dd570beb8a0af7974147c 100644 (file)
@@ -113,10 +113,6 @@ extern DHCPCD_WATCH *dhcpcd_watching;
 #define DHCPCD_SERVICE "name.marples.roy.dhcpcd"
 #define DHCPCD_PATH    "/name/marples/roy/dhcpcd"
 
-#ifdef __GLIBC__
-#  define strlcpy(dst, src, n) snprintf(dst, n, "%s", src)
-#endif
-
 bool dhcpcd_iter_get(DHCPCD_CONNECTION *, DHCPCD_MESSAGEITER *, int, void *);
 DHCPCD_MESSAGE * dhcpcd_send_reply(DHCPCD_CONNECTION *, DHCPCD_MESSAGE *);
 DHCPCD_MESSAGE * dhcpcd_message_reply(DHCPCD_CONNECTION *,
index 7bffcbe1548ccd8de7c5e885b2751d3c3cef87ee..ff338e7372b7bd7b4be98a88125445096cb120bc 100644 (file)
@@ -35,6 +35,7 @@
 
 #define IN_LIBDHCPCD
 #include "libdhcpcd.h"
+#include "config.h"
 
 #define DHCPCD_TIMEOUT_MS 500
 
index f187984fe1b93158493eb37a54f9a6ca563b4e04..e4cab32d036d9533954924c3cf47dd75e8d73c76 100644 (file)
@@ -31,6 +31,7 @@
 
 #define IN_LIBDHCPCD
 #include "libdhcpcd.h"
+#include "config.h"
 
 #define HIST_MAX 10 /* Max history per ssid/bssid */