Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.sbin/altq Build glue for ALTQ programs.



details:   https://anonhg.NetBSD.org/src/rev/68111c25956f
branches:  trunk
changeset: 500689:68111c25956f
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Sat Dec 16 18:57:34 2000 +0000

description:
Build glue for ALTQ programs.

diffstat:

 usr.sbin/altq/Makefile               |    7 +
 usr.sbin/altq/Makefile.inc           |    5 +
 usr.sbin/altq/altqd/Makefile         |   34 ++------
 usr.sbin/altq/altqd/if_nameindex.c   |  130 -----------------------------------
 usr.sbin/altq/altqd/if_nameindex.h   |   17 ----
 usr.sbin/altq/altqstat/Makefile      |   33 ++------
 usr.sbin/altq/libaltq/Makefile       |   45 +++--------
 usr.sbin/altq/libaltq/if_nameindex.c |  130 -----------------------------------
 usr.sbin/altq/libaltq/if_nameindex.h |   17 ----
 usr.sbin/altq/libaltq/parser.c       |    1 -
 usr.sbin/altq/tbrconfig/Makefile     |    8 ++
 11 files changed, 53 insertions(+), 374 deletions(-)

diffs (truncated from 493 to 300 lines):

diff -r ad4c5ef31b5b -r 68111c25956f usr.sbin/altq/Makefile
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.sbin/altq/Makefile    Sat Dec 16 18:57:34 2000 +0000
@@ -0,0 +1,7 @@
+#      $NetBSD: Makefile,v 1.1 2000/12/16 18:57:34 thorpej Exp $
+
+SUBDIR=        libaltq altqd altqstat tbrconfig
+
+all-altqd all-altqstat all-abrconfig: all-libaltq
+
+.include <bsd.subdir.mk>
diff -r ad4c5ef31b5b -r 68111c25956f usr.sbin/altq/Makefile.inc
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.sbin/altq/Makefile.inc        Sat Dec 16 18:57:34 2000 +0000
@@ -0,0 +1,5 @@
+#      $NetBSD: Makefile.inc,v 1.1 2000/12/16 18:57:34 thorpej Exp $
+
+.if exists(${.CURDIR}/../../Makefile.inc)
+.include "${.CURDIR}/../../Makefile.inc"
+.endif
diff -r ad4c5ef31b5b -r 68111c25956f usr.sbin/altq/altqd/Makefile
--- a/usr.sbin/altq/altqd/Makefile      Sat Dec 16 18:24:36 2000 +0000
+++ b/usr.sbin/altq/altqd/Makefile      Sat Dec 16 18:57:34 2000 +0000
@@ -1,29 +1,17 @@
-PREFIX?=       /usr/local
-SYS_INCLUDES?= -I/usr/src/sys-altq
+#      $NetBSD: Makefile,v 1.2 2000/12/16 18:57:34 thorpej Exp $
 
-PROGS=         altqd
-ALTQD_OBJS=    altqd.o if_nameindex.o libaltq2.o ../libaltq/libaltq.a
-MAN5=          altq.conf.5
-MAN8=          altqd.8
+PROG=  altqd
+MAN=   altqd.8 altq.conf.5
 
-CFLAGS=                -g -Wall
-CFLAGS+=       -W -Wpointer-arith -Wcast-qual -Wmissing-prototypes -ansi
-DEFINES=       -DALTQ $(SYS_DEFINES)
-INCLUDES=      -I. -I../libaltq $(SYS_INCLUDES)
+SRCS=  altqd.c libaltq2.c
 
-all: $(PROGS)
+CPPFLAGS+= -DALTQ -I${.CURDIR}/../libaltq
 
-install: $(PROGS)
-       $(INSTALL) $(COPY) -m 0755 $(PROGS) $(PREFIX)/bin
-       $(INSTALL) $(COPY) -m 0644 $(MAN5) $(PREFIX)/man/man5
-       $(INSTALL) $(COPY) -m 0644 $(MAN8) $(PREFIX)/man/man8
+LIBALTQOBJ != cd ${.CURDIR}/../libaltq && make print-objdir
+DPADD+=        ${LIBALTQOBJ}/libaltq.a
+LDADD+=        -L${LIBALTQOBJ} -laltq
 
-altqd: $(ALTQD_OBJS)
-       $(CC) $(CFLAGS) $(INCLUDES) $(DEFINES) -o $@ $(ALTQD_OBJS) $(SYS_LIBS) -lm
+DPADD+=        ${LIBM}
+LDADD+=        -lm
 
-.c.o: 
-       $(CC) $(CFLAGS) $(INCLUDES) $(DEFINES) -c $*.c
-
-clean:;                -rm -f $(PROGS) *.a *.o core *.core *.bak ,* *~ "#"*
-
-
+.include <bsd.prog.mk>
diff -r ad4c5ef31b5b -r 68111c25956f usr.sbin/altq/altqd/if_nameindex.c
--- a/usr.sbin/altq/altqd/if_nameindex.c        Sat Dec 16 18:24:36 2000 +0000
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,130 +0,0 @@
-/*
- * if_nameindex defined in RFC2133 (Basic Socket Interface Extensions
- * for IPv6)
- * this code is taken from "UNIX Network Programming vol.1 2ed"
- * by Richard Stevens.
- */
-#if !defined(INET6) && !defined(__OpenBSD__) && !defined(HAVE_IF_NAMEINDEX)
-
-#include <sys/param.h>
-#include <sys/sysctl.h>
-#include <sys/socket.h>
-
-#include <net/if.h>            /* if_msghdr{} */
-#include <net/if_dl.h>         /* sockaddr_sdl{} */
-#include <net/route.h>         /* RTA_xxx constants */
-
-#include <string.h>
-#include <stdlib.h>
-#include <err.h>
-
-#include "if_nameindex.h"
-
-static void     get_rtaddrs(int, struct sockaddr *, struct sockaddr **);
-static char    *net_rt_iflist(int, int, size_t *);
-
-/*
- * Round up 'a' to next multiple of 'size'
- */
-#define ROUNDUP(a, size) (((a) & ((size)-1)) ? (1 + ((a) | ((size)-1))) : (a))
-
-/*
- * Step to next socket address structure;
- * if sa_len is 0, assume it is sizeof(u_long).
- */
-#define NEXT_SA(ap)    ap = (struct sockaddr *) \
-       ((caddr_t) ap + (ap->sa_len ? ROUNDUP(ap->sa_len, sizeof (u_long)) : \
-                                                                       sizeof(u_long)))
-
-static void
-get_rtaddrs(int addrs, struct sockaddr *sa, struct sockaddr **rti_info)
-{
-       int             i;
-
-       for (i = 0; i < RTAX_MAX; i++) {
-               if (addrs & (1 << i)) {
-                       rti_info[i] = sa;
-                       NEXT_SA(sa);
-               } else
-                       rti_info[i] = NULL;
-       }
-}
-
-static char *
-net_rt_iflist(int family, int flags, size_t *lenp)
-{
-       int             mib[6];
-       char    *buf;
-
-       mib[0] = CTL_NET;
-       mib[1] = AF_ROUTE;
-       mib[2] = 0;
-       mib[3] = family;                /* only addresses of this family */
-       mib[4] = NET_RT_IFLIST;
-       mib[5] = flags;                 /* interface index, or 0 */
-       if (sysctl(mib, 6, NULL, lenp, NULL, 0) < 0)
-               return(NULL);
-
-       if ( (buf = malloc(*lenp)) == NULL)
-               return(NULL);
-       if (sysctl(mib, 6, buf, lenp, NULL, 0) < 0)
-               return(NULL);
-
-       return(buf);
-}
-
-struct if_nameindex *
-if_nameindex(void)
-{
-       char                            *buf, *next, *lim;
-       size_t                          len;
-       struct if_msghdr        *ifm;
-       struct sockaddr         *sa, *rti_info[RTAX_MAX];
-       struct sockaddr_dl      *sdl;
-       struct if_nameindex     *result, *ifptr;
-       char                            *namptr;
-
-       if ( (buf = net_rt_iflist(0, 0, &len)) == NULL)
-               return(NULL);
-
-       if ( (result = malloc(len)) == NULL)    /* overestimate */
-               return(NULL);
-       ifptr = result;
-       namptr = (char *) result + len; /* names start at end of buffer */
-
-       lim = buf + len;
-       for (next = buf; next < lim; next += ifm->ifm_msglen) {
-               ifm = (struct if_msghdr *) next;
-               if (ifm->ifm_type == RTM_IFINFO) {
-                       sa = (struct sockaddr *) (ifm + 1);
-                       get_rtaddrs(ifm->ifm_addrs, sa, rti_info);
-                       if ( (sa = rti_info[RTAX_IFP]) != NULL) {
-                               if (sa->sa_family == AF_LINK) {
-                                       sdl = (struct sockaddr_dl *) sa;
-                                       namptr -= sdl->sdl_nlen + 1;
-                                       strncpy(namptr, &sdl->sdl_data[0], sdl->sdl_nlen);
-                                       namptr[sdl->sdl_nlen] = 0;      /* null terminate */
-                                       ifptr->if_name = namptr;
-                                       ifptr->if_index = sdl->sdl_index;
-                                       ifptr++;
-                               }
-                       }
-
-               }
-       }
-       ifptr->if_name = NULL;  /* mark end of array of structs */
-       ifptr->if_index = 0;
-       free(buf);
-       return(result);                 /* call can free() this when done */
-}
-/* end if_nameindex */
-
-/* include if_freenameindex */
-void
-if_freenameindex(struct if_nameindex *ptr)
-{
-       free(ptr);
-}
-/* end if_freenameindex */
-
-#endif /* !INET6 && !__OpenBSD__ && !HAVE_IF_NAMEINDEX */
diff -r ad4c5ef31b5b -r 68111c25956f usr.sbin/altq/altqd/if_nameindex.h
--- a/usr.sbin/altq/altqd/if_nameindex.h        Sat Dec 16 18:24:36 2000 +0000
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,17 +0,0 @@
-
-#ifndef _IF_NAMEINDEX_H_
-#define _IF_NAMEINDEX_H_
-
-#if !defined(INET6) && !defined(__OpenBSD__) && !defined(HAVE_IF_NAMEINDEX)
-
-struct if_nameindex {
-  unsigned int   if_index;  /* 1, 2, ... */
-  char          *if_name;   /* null terminated name: "le0", ... */
-};
-
-struct if_nameindex *if_nameindex(void);
-void if_freenameindex(struct if_nameindex *);
-
-#endif
-
-#endif /* _IF_NAMEINDEX_H_ */
diff -r ad4c5ef31b5b -r 68111c25956f usr.sbin/altq/altqstat/Makefile
--- a/usr.sbin/altq/altqstat/Makefile   Sat Dec 16 18:24:36 2000 +0000
+++ b/usr.sbin/altq/altqstat/Makefile   Sat Dec 16 18:57:34 2000 +0000
@@ -1,28 +1,13 @@
-PREFIX?=       /usr/local
-SYS_INCLUDES?= -I/usr/src/sys-altq
+#      $NetBSD: Makefile,v 1.2 2000/12/16 18:57:35 thorpej Exp $
 
-PROG=          altqstat
-OBJS=          altqstat.o quip_client.o qdisc_conf.o \
-               qdisc_cbq.o qdisc_hfsc.o qdisc_cdnr.o \
-               qdisc_wfq.o qdisc_fifoq.o \
-               qdisc_red.o qdisc_rio.o qdisc_blue.o qdisc_priq.o
-MAN1=          altqstat.1
+PROG=  altqstat
+SRCS=  altqstat.c quip_client.c qdisc_conf.c qdisc_cbq.c qdisc_hfsc.c \
+       qdisc_cdnr.c qdisc_wfq.c qdisc_fifoq.c qdisc_red.c qdisc_rio.c \
+       qdisc_blue.c qdisc_priq.c
 
-CFLAGS=                -g -Wall
-CFLAGS+=       -W -Wpointer-arith -Wcast-qual -Wmissing-prototypes -ansi
-DEFINES=       -DALTQ $(SYS_DEFINES)
-INCLUDES=      -I. -I../libaltq $(SYS_INCLUDES)
-
-all: $(PROG)
+CPPFLAGS+= -DALTQ -I${.CURDIR}/../libaltq
 
-install: $(PROG)
-       $(INSTALL) $(COPY) -m 0755 $(PROG) $(PREFIX)/bin
-       $(INSTALL) $(COPY) -m 0644 $(MAN1) $(PREFIX)/man/man1
+DPADD+=        ${LIBCURSES}
+LDADD+=        -lcurses
 
-altqstat: $(OBJS)
-       $(CC) $(CFLAGS) $(INCLUDES) $(DEFINES) -o $@ $(OBJS) $(SYS_LIBS) -lcurses
-
-.c.o: 
-       $(CC) $(CFLAGS) $(INCLUDES) $(DEFINES) -c $*.c
-
-clean:;                -rm -f $(PROG) *.a *.o core *.core *.bak ,* *~ "#"*
+.include <bsd.prog.mk>
diff -r ad4c5ef31b5b -r 68111c25956f usr.sbin/altq/libaltq/Makefile
--- a/usr.sbin/altq/libaltq/Makefile    Sat Dec 16 18:24:36 2000 +0000
+++ b/usr.sbin/altq/libaltq/Makefile    Sat Dec 16 18:57:34 2000 +0000
@@ -1,38 +1,19 @@
-PREFIX?=       /usr/local
-SYS_INCLUDES?= -I/usr/src/sys-altq
+#      $NetBSD: Makefile,v 1.2 2000/12/16 18:57:35 thorpej Exp $
 
-LIB=   libaltq.a
+#WARNS=        2
 
-OBJS=  qop.o parser.o quip_server.o qop_cdnr.o qop_errlist.o \
-       qop_conf.o qop_dummy.o qop_cbq.o qop_hfsc.o qop_priq.o \
-       qop_red.o qop_rio.o qop_blue.o qop_wfq.o qop_fifoq.o \
-       qop_priq.o
-
-CFLAGS=                -g -Wall
-CFLAGS+=       -Wpointer-arith -Wcast-qual -Wmissing-prototypes -ansi
-DEFINES=       -DALTQ $(SYS_DEFINES)
-INCLUDES=      -I. $(SYS_INCLUDES)
-
-all: $(LIB)
+LIB=   altq
+SRCS=  parser.c qop.c qop_blue.c qop_cbq.c qop_cdnr.c qop_conf.c \
+       qop_dummy.c qop_errlist.c qop_fifoq.c qop_hfsc.c qop_priq.c \
+       qop_red.c qop_rio.c qop_wfq.c quip_server.c
 
-install: $(LIB)
-       $(INSTALL) $(COPY) -m 0444 $(LIB) $(PREFIX)/lib
-
-libaltq.a: libaltq.a($(OBJS))
-       rm -f $@
-       ar cq $@ `lorder $(OBJS) | tsort -q`
-       ranlib $@
-
-.c.o: 
-       $(CC) $(CFLAGS) $(INCLUDES) $(DEFINES) -c $*.c
+CPPFLAGS+= -DALTQ
 
-clean:;                -rm -f $(LIB) *.a *.o core *.core *.bak ,* *~ "#"*



Home | Main Index | Thread Index | Old Index