From: ellson Date: Sun, 17 Jul 2005 19:52:21 +0000 (+0000) Subject: Move cmd/dot/args.c to lib/common/args.c so it can be used by other progs X-Git-Tag: LAST_LIBGRAPH~32^2~7423 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9c8d2d55299223c9c229485987cf5cd34251e220;p=graphviz Move cmd/dot/args.c to lib/common/args.c so it can be used by other progs Remove cmd/dot/dotneato-config-* Use pkgconfig mechanism now. Add dot.demo/ with two demo programs. --- diff --git a/cmd/dot/Makefile.am b/cmd/dot/Makefile.am index a61fcdc43..6fd34cf5e 100644 --- a/cmd/dot/Makefile.am +++ b/cmd/dot/Makefile.am @@ -11,22 +11,19 @@ AM_CPPFLAGS = \ -I$(top_srcdir) \ -I$(top_srcdir)/lib/common \ -I$(top_srcdir)/lib/gvc \ - -I$(top_srcdir)/lib/pack \ -I$(top_srcdir)/lib/pathplan \ -I$(top_srcdir)/lib/graph \ - -I$(top_srcdir)/lib/cdt \ - -I$(top_srcdir)/lib/fdpgen + -I$(top_srcdir)/lib/cdt pkginclude_HEADERS = dotneato.h pkglib_LTLIBRARIES = libdotneato.la pkgconfig_DATA = libdotneato.pc -bin_SCRIPTS = dotneato-config bin_PROGRAMS = dot -man_MANS = dot.1 dotneato-config.1 -pdf_DATA = dot.pdf dotneato-config.pdf +man_MANS = dot.1 +pdf_DATA = dot.pdf libdotneato_la_SOURCES = dotneato.c -dot_SOURCES = dot.c args.c +dot_SOURCES = dot.c if DISABLE_LTDL libdotneato_la_LIBADD = \ @@ -70,9 +67,6 @@ uninstall-hook: dot.pdf: $(top_srcdir)/cmd/dot/dot.1 groff -Tps -man $(top_srcdir)/cmd/dot/dot.1 | ps2pdf - - >$@ -dotneato-config.pdf: $(top_srcdir)/cmd/dot/dotneato-config.1 - groff -Tps -man $(top_srcdir)/cmd/dot/dotneato-config.1 | ps2pdf - - >$@ +EXTRA_DIST = Makefile.old dot.1 dot.pdf -EXTRA_DIST = Makefile.old dot.1 dotneato-config.1 dot.pdf dotneato-config.pdf dotneato-config.in - -DISTCLEANFILES = dot.pdf dotneato-config.pdf +DISTCLEANFILES = dot.pdf diff --git a/cmd/dot/Makefile.old b/cmd/dot/Makefile.old index d6c2f0fa4..6feca6087 100644 --- a/cmd/dot/Makefile.old +++ b/cmd/dot/Makefile.old @@ -40,7 +40,7 @@ DOTLIBS = ../../lib/common/libcommon.a ../../lib/dotgen/libdotgen.a \ LIBDOTNEATO = libdotneato.a -OBJS = dot.o args.o +OBJS = dot.o SHLIBS = twopigen/libtwopi.a dotgen/libdot.a neatogen/libneato.a pack/libpack.a gvrender/libgvrender.a common/libcommon.a all : dot $(LIBDOTNEATO) @@ -52,9 +52,6 @@ dot : $(OBJS) $(DOTLIBS) dot.o : dot.c $(CC) -c $(CCFLAGS) $(DEFINES) $(INCS) dot.c -args.o : args.c - $(CC) -c $(CCFLAGS) $(DEFINES) $(ALLINCS) args.c - plugins.o : plugins.c $(CC) -c $(CCFLAGS) $(DEFINES) $(ALLINCS) plugins.c diff --git a/cmd/dot/dotneato-config.1 b/cmd/dot/dotneato-config.1 deleted file mode 100644 index 66257e7e3..000000000 --- a/cmd/dot/dotneato-config.1 +++ /dev/null @@ -1,36 +0,0 @@ -.\" Process this file with -.\" groff -man -Tascii dotneato-config.1 -.\" -.TH dotneato-config 1 "FEBRUARY 1999" "Library Configuration" "User Manuals" -.SH NAME -dotneato-config \- Display Dotneato Library Configuration -.SH SYNOPSIS -.B dotneato-config -.I OPTION -.B [ -.I OPTION -.B ... ] -.SH DESCRIPTION -.B dotneato-config -is a script that is used to display the compiler and linker flags that are -required for building applications that link to the dotneato libraries -from GraphViz. - -.SH OPTIONS -.IP --version -dotneato version information -.IP --prefix -displays prefix of directory where dotneato was installed. -.IP --exec-prefix -displays exec-prefix of the directory where architecture-specific parts -of dotneato were installed. -.IP --cflags -C pre-processor and compiler flags for use with dotneato. -.IP --libs -dotneato library linking information -.IP --libtool -dotneato libtool information -.SH "SEE ALSO" -.BR dot (1) -.SH AUTHOR -John Ellson diff --git a/cmd/dot/dotneato-config.in b/cmd/dot/dotneato-config.in deleted file mode 100644 index aa41f0f2f..000000000 --- a/cmd/dot/dotneato-config.in +++ /dev/null @@ -1,112 +0,0 @@ -#! /bin/sh - -prefix=@prefix@ -exec_prefix=@exec_prefix@ -pkglibdir=@libdir@/@PACKAGE@ -includedir=@includedir@ -pkgincludedir=${includedir}/@PACKAGE@ - -usage() -{ - cat <&2 -fi - -while test $# -gt 0 ; do - case "$1" in - -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;; - *) optarg= ;; - esac - - case $1 in - --prefix=*) - prefix=$optarg - local_prefix=yes - ;; - --prefix) - echo_prefix=yes - ;; - --exec-prefix=*) - exec_prefix=$optarg - exec_prefix_set=yes - local_prefix=yes - ;; - --exec-prefix) - echo_exec_prefix=yes - ;; - --version) - echo @VERSION@ - exit 0 - ;; - --cflags) - echo_cflags=yes - ;; - --ldflags) - echo_ldflags=yes - ;; - --libs) - echo_libs=yes - ;; - --rlibs) - echo_rlibs=yes - ;; - --libtool) - echo_libtool=yes - ;; - *) - usage 1 1>&2 - ;; - esac - shift -done - -if test "$local_prefix" = "yes" ; then - if test "$exec_prefix_set" != "yes" ; then - exec_prefix=$prefix - fi -fi - -if test "$echo_prefix" = "yes" ; then - echo $prefix -fi - -if test "$echo_exec_prefix" = "yes" ; then - echo $exec_prefix -fi - -if test "$echo_cflags" = "yes" ; then - echo -I$pkgincludedir $cflags -fi - -if test "$echo_ldflags" = "yes" ; then - echo "-L$pkglibdir" -fi - -if test "$echo_libs" = "yes" ; then - echo "-ldotneato" -fi - -if test "$echo_rlibs" = "yes" ; then - echo "" -fi - -if test "$echo_libtool" = "yes" ; then - echo "$pkglibdir/libdotneato.la" -fi - -# EOF diff --git a/dot.demo/Makefile b/dot.demo/Makefile new file mode 100644 index 000000000..6f83caf03 --- /dev/null +++ b/dot.demo/Makefile @@ -0,0 +1,22 @@ +COMPILE=libtool --tag=CC --mode=compile ${CC} -c +LINK=libtool --tag=CC --mode=link ${CC} + +CFLAGS=`pkg-config libdotneato --cflags` +LDFLAGS=`pkg-config libdotneato --libs` + +all: dot demo + +dot: dot.lo + ${LINK} ${LDFLAGS} -o $@ dot.lo + +dot.lo: dot.c + ${COMPILE} ${CFLAGS} -o $@ dot.c + +demo: demo.lo + ${LINK} ${LDFLAGS} -o $@ demo.lo + +demo.lo: demo.c + ${COMPILE} ${CFLAGS} -o $@ demo.c + +clean: + rm -rf .libs dot demo *.o *.lo diff --git a/dot.demo/demo.c b/dot.demo/demo.c new file mode 100644 index 000000000..b87da72a9 --- /dev/null +++ b/dot.demo/demo.c @@ -0,0 +1,60 @@ +/* $Id$ $Revision$ */ +/* vim:set shiftwidth=4 ts=8: */ + +/********************************************************** +* This software is part of the graphviz package * +* http://www.graphviz.org/ * +* * +* Copyright (c) 1994-2004 AT&T Corp. * +* and is licensed under the * +* Common Public License, Version 1.0 * +* by AT&T Corp. * +* * +* Information and Software Systems Research * +* AT&T Research, Florham Park NJ * +**********************************************************/ + +#include + +int main(int argc, char **argv) +{ + Agraph_t *g; + Agnode_t *n, *m; + Agedge_t *e; + Agsym_t *a; + GVC_t *gvc; + + /* set up renderer context */ + gvc = gvContext(); + + /* parse command line args - minimally argv[0] sets layout engine */ + parse_args(gvc, argc, argv); + + /* Create a simple digraph */ + g = agopen("g", AGDIGRAPH); + n = agnode(g, "n"); + m = agnode(g, "m"); + e = agedge(g, n, m); + + /* Set an attribute - in this case one that affects the visible rendering */ + if (!(a = agfindattr(g->proto->n, "color"))) + a = agnodeattr(g, "color", ""); + agxset(n, a->index, "red"); + + /* Compute a layout */ + gvlayout_layout(gvc, g); + + /* Write the graph according to -T and -o options */ + emit_jobs(gvc, g); + + /* Clean out layout data */ + gvlayout_cleanup(gvc, g); + + /* Free graph structures */ + agclose(g); + + /* Clean up output file and errors */ + dotneato_terminate(gvc); + + return 0; +} diff --git a/dot.demo/dot.c b/dot.demo/dot.c new file mode 100644 index 000000000..583d4bf1c --- /dev/null +++ b/dot.demo/dot.c @@ -0,0 +1,38 @@ +/* $Id$ $Revision$ */ +/* vim:set shiftwidth=4 ts=8: */ + +/********************************************************** +* This software is part of the graphviz package * +* http://www.graphviz.org/ * +* * +* Copyright (c) 1994-2004 AT&T Corp. * +* and is licensed under the * +* Common Public License, Version 1.0 * +* by AT&T Corp. * +* * +* Information and Software Systems Research * +* AT&T Research, Florham Park NJ * +**********************************************************/ + +#include + +int main(int argc, char **argv) +{ + graph_t *g, *prev = NULL; + GVC_t *gvc; + + gvc = gvContext(); + parse_args(gvc, argc, argv); + + while ((g = next_input_graph())) { + if (prev) { + gvlayout_cleanup(gvc, prev); + agclose(prev); + } + gvlayout_layout(gvc, g); + emit_jobs(gvc, g); + prev = g; + } + dotneato_terminate(gvc); + return 0; +} diff --git a/lib/common/Makefile.am b/lib/common/Makefile.am index 5babf7147..0ac3051d9 100644 --- a/lib/common/Makefile.am +++ b/lib/common/Makefile.am @@ -3,6 +3,8 @@ AM_CPPFLAGS = \ -I$(top_srcdir) \ -I$(top_srcdir)/lib/gvc \ + -I$(top_srcdir)/lib/pack \ + -I$(top_srcdir)/lib/fdpgen \ -I$(top_srcdir)/lib/pathplan \ -I$(top_srcdir)/lib/graph \ -I$(top_srcdir)/lib/cdt @GD_INCLUDES@ @EXPAT_INCLUDES@ @Z_INCLUDES@ @@ -18,7 +20,7 @@ endif libcommon_la_SOURCES = arrows.c colxlate.c fontmetrics.c \ - gdtextsize.c gdusershape.c \ + args.c gdtextsize.c gdusershape.c \ globals.c htmllex.c htmlparse.y htmltable.c input.c \ pointset.c postproc.c psusershape.c routespl.c splines.c \ svgusershape.c timing.c labels.c ns.c shapes.c utils.c \ diff --git a/lib/common/Makefile.old b/lib/common/Makefile.old index 1872c744e..d93a64c05 100644 --- a/lib/common/Makefile.old +++ b/lib/common/Makefile.old @@ -6,6 +6,8 @@ include $(ROOT)/makearch/$(ARCH) INCS = -I. \ -I$(ROOT) \ -I../cdt \ + -I../pack \ + -I../fdpgen \ -I../pathplan \ -I../gd \ -I../graph \ diff --git a/cmd/dot/args.c b/lib/common/args.c similarity index 100% rename from cmd/dot/args.c rename to lib/common/args.c