From 24379d24f8cc72248ba5b0c6c4b5a1869bbc58f7 Mon Sep 17 00:00:00 2001 From: Nathan Ramella Date: Sat, 13 Oct 2012 04:28:41 -0700 Subject: [PATCH] Pooled all the Makefiles into a single top-level Makefile that handles everything. Highlights include: * Easy management of exported functions for enscriptem * Numerous tiny bug fixes to get llvm to be less mouthy about warnings. * Building reliably with -O3 optimization enabled on OSX Mountain Lion * New makefile targets for installing and zipping up a completed build Caveats: * I haven't tested this on Linux, it's possible that a couple of my header file changes might cause some hiccups. But, all in all given the amount of llvm warnings I got rid of, I doubt anyone will notice. :D -Nathan Ramella / Synthesizer Patel (nar@hush.com) --- Makefile | 178 ++++++++++++++++++++++++++++++++++--- cdt/Makefile | 18 ---- common/Makefile | 14 --- common/arrows.c | 1 + common/geomprocs.h | 4 +- common/render.h | 1 + common/utils.c | 15 +--- common/utils.h | 20 ++++- common/xdot.c | 8 +- common/xdot.h | 4 + config.h | 4 + dotgen/Makefile | 45 ---------- dotgen/liviz-apis/Makefile | 12 --- graph/Makefile | 17 ---- graph/agxbuf.c | 3 - graph/agxbuf.h | 9 +- graph/lexer.c | 2 +- gvc/Makefile | 12 --- gvc/gvcontext.c | 1 - gvc/gvplugin.c | 18 ++-- pathplan/Makefile | 13 --- 21 files changed, 218 insertions(+), 181 deletions(-) delete mode 100644 cdt/Makefile delete mode 100644 common/Makefile delete mode 100644 dotgen/Makefile delete mode 100755 dotgen/liviz-apis/Makefile delete mode 100644 graph/Makefile delete mode 100644 gvc/Makefile delete mode 100644 pathplan/Makefile diff --git a/Makefile b/Makefile index 77f11df..5f7e7a9 100644 --- a/Makefile +++ b/Makefile @@ -1,15 +1,167 @@ -all: - cd cdt; make - cd common; make - cd gvc; make - cd pathplan; make - cd graph; make - cd dotgen; make +# Nathan Ramella (nar@hush.com) +CC = clang +EMCC = emcc +DEFINES = -DHAVE_CONFIG_H +INCLUDE = -I. -Icdt -Icommon -Idotgen -Igraph -Igvc -Ipathplan +OPTIMIZATION_LEVEL = -O3 + +# Setting c99 might not be critically important, but c89 didn't play +# well for lack of inline.A + +CFLAGS = -std=c99 + +ifeq "$(shell uname -s)" "Darwin" +EXTRA_CFLAGS = -arch i686 +EXTRA_DEFINES = -DHAVE_STRINGS_H +endif + +SUBDIRS = cdt common gvc pathplan graph dotgen dotgen/liviz-api + +COMPILER_CMD=$(EMCC) $(DEFINES) $(EXTRA_DEFINES) $(INCLUDE) $(EXTRA_INCLUDE) $(CFLAGS) $(EXTRA_CFLAGS) + +# Dynamically generate a timestamp to tag the +# build with. + +BUILD_TIMESTAMP = $(shell date +%s) + +CDT_SRC = $(addprefix cdt/, \ + dtclose.c dtdisc.c dtextract.c dtview.c \ + dthash.c dtlist.c dtflatten.c dtrestore.c \ + dtopen.c dtsize.c dtstrhash.c dttreeset.c \ + dttree.c dtwalk.c dtmethod.c) + +COMMON_SRC = $(addprefix common/, \ + ns.c xdot.c emit.c geom.c input.c utils.c \ + arrows.c timing.c labels.c memory.c \ + shapes.c splines.c globals.c htmllex.c \ + postproc.c htmlparse.c htmltable.c \ + routespl.c colxlate.c psusershape.c \ + fontmetrics.c) + +GVC_SRC = $(addprefix gvc/, \ + gvc.c gvconfig.c gvcontext.c gvdevice.c \ + gvlayout.c gvevent.c gvjobs.c gvplugin.c \ + gvrender.c gvusershape.c gvloadimage.c \ + gvtextlayout.c) + +PATHPLAN_SRC = $(addprefix pathplan/, \ + cvt.c inpoly.c route.c shortest.c \ + solvers.c triang.c util.c \ + visibility.c) + +GRAPH_SRC = $(addprefix graph/, \ + agxbuf.c attribs.c edge.c graph.c \ + graphio.c lexer.c node.c parser.c \ + refstr.c trie.c) + +DOTGEN_SRC = $(addprefix dotgen/, \ + acyclic.c aspect.c class1.c class2.c \ + cluster.c compound.c conc.c decomp.c \ + dotinit.c dotsplines.c fastgr.c \ + flat.c mincross.c position.c rank.c \ + sameport.c) + +# This is a little trick to make the maintenance of exported +# functions a little easier. Add them to the EXPORTED_FUNCTION_LIST +# below and at build time through the magic of awk and some make +# voodoo, they'll be assembled into a Python parsable array that +# can be passed to emscripten. + + +EXPORTED_FUNCTION_LIST = \ + _finalizeGVContext \ + _prepareGVContext \ + _getFirstNode \ + _getNextNode \ + _getCurentGraph \ + _beginGVJob \ + _testCountNodes \ + _countEdges \ + _extractGraph \ + _runDotLayout \ + _getNodeName \ + _getGraphWidth \ + _getGraphHeight \ + _getEdgeColor \ + _extractRanks \ + _extractEdgesEarly \ + _getEdgeLabel + +EXPORTED_FUNCTIONS = $(addprefix -s EXPORTED_FUNCTIONS=[, \ + $(addsuffix ], \ + $(shell echo $(EXPORTED_FUNCTION_LIST) \ + | awk '{for (i=1;i #define EPSILON .0001 diff --git a/common/geomprocs.h b/common/geomprocs.h index 6be584b..38f8702 100644 --- a/common/geomprocs.h +++ b/common/geomprocs.h @@ -17,11 +17,13 @@ #ifndef GV_GEOMPROCS_H #define GV_GEOMPROCS_H +//#define MIN(a,b) (((a)<(b))?(a):(b)) +//#define MAX(a,b) (((a)>(b))?(a):(b)) + #ifdef __cplusplus extern "C" { #endif - #include "geom.h" #ifdef WIN32 diff --git a/common/render.h b/common/render.h index 1283739..590ad64 100644 --- a/common/render.h +++ b/common/render.h @@ -50,6 +50,7 @@ extern "C" { #include "gvcjob.h" /* must follow gvcext.h (in types.h) */ #include "gvcint.h" /* must follow gvcext.h (in types.h) */ #include "gvcproc.h" /* must follow gvcext.h (in types.h) */ +#include "geom.h" typedef struct epsf_s { int macro_id; diff --git a/common/utils.c b/common/utils.c index eb73b6e..1431af9 100644 --- a/common/utils.c +++ b/common/utils.c @@ -11,20 +11,7 @@ * Contributors: See CVS logs. Details at http://www.graphviz.org/ *************************************************************************/ -#include "render.h" -#include "agxbuf.h" -#include "htmltable.h" -#include "entities.h" -#include "logic.h" -#include "gvc.h" - -#ifdef WIN32 -#include "libltdl/lt_system.h" -#endif -#ifndef WIN32 -#include -#endif -#include +#include "utils.h" /* * a queue of nodes diff --git a/common/utils.h b/common/utils.h index 0ddbc4e..6eb3534 100644 --- a/common/utils.h +++ b/common/utils.h @@ -12,7 +12,25 @@ *************************************************************************/ #ifndef _UTILS_H -#define _UTILS_H 1 +#define _UTILS_H + +#include "render.h" +#include "agxbuf.h" +#include "htmltable.h" +#include "entities.h" +#include "logic.h" +#include "gvc.h" + + +#ifdef WIN32 +#include "libltdl/lt_system.h" +#endif +#ifndef WIN32 +#include +#include +#endif +#include + #ifdef __cplusplus extern "C" { diff --git a/common/xdot.c b/common/xdot.c index 8a17949..a432f57 100644 --- a/common/xdot.c +++ b/common/xdot.c @@ -12,9 +12,6 @@ *************************************************************************/ #include -#include -#include -#include #define NEW(t) (t*)calloc(1, sizeof(t)) #define N_NEW(n,t) (t*)calloc((n), sizeof(t)) @@ -533,8 +530,9 @@ typedef struct { int dyna; /* true if buffer is malloc'ed */ } agxbuf; -#define agxbputc(X,C) ((((X)->ptr >= (X)->eptr) ? agxbmore(X,1) : 0), \ - (int)(*(X)->ptr++ = ((unsigned char)C))) +//#define agxbputc(X,C) ((((X)->ptr >= (X)->eptr) ? agxbmore(X,1) : 0), (int)(*(X)->ptr++ = ((unsigned char)C))) +#define agxbputc(X,C) ((((X)->ptr >= (X)->eptr) ? agxbmore(X,1) : 0), (*(X)->ptr++ = ((unsigned char)C))) + #define agxbuse(X) (agxbputc(X,'\0'),(char*)((X)->ptr = (X)->buf)) static void agxbinit(agxbuf * xb, unsigned int hint, unsigned char *init) diff --git a/common/xdot.h b/common/xdot.h index 08f26c6..f483f75 100644 --- a/common/xdot.h +++ b/common/xdot.h @@ -18,6 +18,10 @@ #endif #define INITIAL_XDOT_CAPACITY 512 +#include +#include +#include + typedef enum { xd_left, xd_center, xd_right } xdot_align; diff --git a/config.h b/config.h index d07750d..aa6c498 100644 --- a/config.h +++ b/config.h @@ -1,3 +1,6 @@ +//#define MIN(a,b) (((a)<(b))?(a):(b)) +//#define MAX(a,b) (((a)>(b))?(a):(b)) + #define GVPLUGIN_CONFIG_FILE "config6" #define GVPLUGIN_VERSION 6 #define PACKAGE "graphviz" @@ -20,3 +23,4 @@ #define DEFAULT_DPI 96 #define HAVE_STRDUP 1 +#define HAVE_STRINGS_H 1 diff --git a/dotgen/Makefile b/dotgen/Makefile deleted file mode 100644 index bdbe55e..0000000 --- a/dotgen/Makefile +++ /dev/null @@ -1,45 +0,0 @@ -CC = clang -EM = emcc -EMFLAGS = -s EXPORTED_FUNCTIONS="[\"_finalizeGVContext\",\"_prepareGVContext\",\"_getFirstNode\",\"_getNextNode\",\"_getCurentGraph\",\"_beginGVJob\",\"_testCountNodes\",\"_countEdges\",\"_extractGraph\",\"_runDotLayout\",\"_getNodeName\",\"_getGraphWidth\",\"_getGraphHeight\",\"_getEdgeColor\",\"_extractRanks\",\"_extractEdgesEarly\",\"_getEdgeLabel\"]" -CFLAGS = -I. -I.. -I../common -I../gvc -I../pathplan -I../cdt -I../graph \ - -DHAVE_CONFIG_H -LIBS = liviz-apis/liviz-apis.bc \ - ../common/libcommon-em.bc \ - ../gvc/libgvc-em.bc \ - ../graph/libgraph-em.bc \ - ../cdt/libcdt-em.bc \ - ../pathplan/libpathplan-em.bc - -DOTOBJS = acyclic.c aspect.c class1.c class2.c \ - cluster.c compound.c conc.c decomp.c \ - dotinit.c dotsplines.c fastgr.c flat.c \ - mincross.c position.c rank.c sameport.c - - -testrun-2.js: testrun-2.bc dotgen.bc liviz-apis/liviz-apis.bc - $(EM) -o testrun-2.js testrun-2.bc dotgen.bc $(LIBS) $(EMFLAGS) - cp testrun-2.js ../liviz/js/em-dotgen.js - -testrun-2.bc: - $(EM) -o testrun-2.bc $(CFLAGS) -c testrun-dot-2.c - -liviz-apis/liviz-apis.bc: - cd liviz-apis; make - -testrun-1: testrun-1.bc dotgen.bc - llvm-ld -native -o testrun-1 testrun-1.bc dotgen.bc $(LIBS) - - -testrun-1.bc: - $(EM) -o testrun-1.bc $(CFLAGS) -c testrun-dot-1.c - - -dotgen.bc: - $(EM) -o dotgen.bc $(CFLAGS) $(DOTOBJS) - -.PHONY: clean -clean: - cd liviz-apis; make clean - rm -f testrun - rm -f testrun-2.js - rm -f *.bc diff --git a/dotgen/liviz-apis/Makefile b/dotgen/liviz-apis/Makefile deleted file mode 100755 index d2eae32..0000000 --- a/dotgen/liviz-apis/Makefile +++ /dev/null @@ -1,12 +0,0 @@ -CC = clang -EM = emcc -CFLAGS = -I. -I.. -I../.. -I../../common -I../../gvc \ - -I../../pathplan -I../../cdt -I../../graph \ - -DHAVE_CONFIG_H - -liviz-apis.bc: - $(EM) -o liviz-apis.bc $(CFLAGS) liviz-apis.c - -.PHONY: clean -clean: - rm -f *.bc diff --git a/graph/Makefile b/graph/Makefile deleted file mode 100644 index e0b815b..0000000 --- a/graph/Makefile +++ /dev/null @@ -1,17 +0,0 @@ -CC = clang -EM = emcc -CFLAGS = -I. -I../cdt -I../gvc -I../common -I../pathplan -OBJS = agxbuf.c attribs.c edge.c \ - graph.c graphio.c lexer.c node.c parser.c refstr.c trie.c - -testrun: libgraph-em.bc - $(CC) -o testrun $(CFLAGS) testrun-graph.c libgraph-em.bc ../cdt/libcdt-em.bc - $(EM) -o testrun.js $(CFLAGS) testrun-graph.c libgraph-em.bc ../cdt/libcdt-em.bc - -libgraph-em.bc: - $(EM) -o libgraph-em.bc $(CFLAGS) $(OBJS) - -.PHONY: clean -clean: - rm -f testrun - rm -f *.bc diff --git a/graph/agxbuf.c b/graph/agxbuf.c index 6cfde9a..64e21b9 100644 --- a/graph/agxbuf.c +++ b/graph/agxbuf.c @@ -12,9 +12,6 @@ *************************************************************************/ -#include -#include -#include #include #define N_GNEW(n,t) (t*)malloc((n)*sizeof(t)) diff --git a/graph/agxbuf.h b/graph/agxbuf.h index 3db1c49..de5a28c 100644 --- a/graph/agxbuf.h +++ b/graph/agxbuf.h @@ -18,6 +18,11 @@ extern "C" { #ifndef AGXBUF_H #define AGXBUF_H +#include +#include +#include + + /* Extensible buffer: * Malloc'ed memory is never released until agxbfree is called. */ @@ -64,8 +69,8 @@ extern "C" { * Add character to buffer. * int agxbputc(agxbuf*, char) */ -#define agxbputc(X,C) ((((X)->ptr >= (X)->eptr) ? agxbmore(X,1) : 0), \ - (int)(*(X)->ptr++ = ((unsigned char)C))) +//#define agxbputc(X,C) ((((X)->ptr >= (X)->eptr) ? agxbmore(X,1) : 0), (int) (*(X)->ptr++ = ((unsigned char)C))) +#define agxbputc(X,C) ((((X)->ptr >= (X)->eptr) ? agxbmore(X,1) : 0), (*(X)->ptr++ = ((unsigned char)C))) /* agxbuse: * Null-terminates buffer; resets and returns pointer to data; diff --git a/graph/lexer.c b/graph/lexer.c index fb8f3d4..1a52cca 100644 --- a/graph/lexer.c +++ b/graph/lexer.c @@ -145,7 +145,7 @@ static char *scan_token(unsigned char *p, unsigned char *token) } *q = '\0'; - return p; + return (char*) *p; } static char *scan_num(char *p, char *token) diff --git a/gvc/Makefile b/gvc/Makefile deleted file mode 100644 index 869e5bd..0000000 --- a/gvc/Makefile +++ /dev/null @@ -1,12 +0,0 @@ -EM = emcc -CFLAGS = -DHAVE_CONFIG_H -I. -I.. -I../common -I../pathplan -I../cdt -I../graph -OBJS = gvc.c gvconfig.c gvcontext.c gvdevice.c gvlayout.c \ - gvevent.c gvjobs.c gvplugin.c gvrender.c gvusershape.c \ - gvloadimage.c gvtextlayout.c - -libgvc-em.bc: - $(EM) -o libgvc-em.bc $(CFLAGS) $(OBJS) - -.PHONY: clean -clean: - rm -f *.bc diff --git a/gvc/gvcontext.c b/gvc/gvcontext.c index 5326be2..c0f2eee 100644 --- a/gvc/gvcontext.c +++ b/gvc/gvcontext.c @@ -25,7 +25,6 @@ #include -#include "builddate.h" #include "types.h" #include "gvplugin.h" #include "gvcjob.h" diff --git a/gvc/gvplugin.c b/gvc/gvplugin.c index b039e8a..10c5497 100644 --- a/gvc/gvplugin.c +++ b/gvc/gvplugin.c @@ -59,7 +59,7 @@ api_t gvplugin_api(char *str) /* translate api_t into string name, or NULL */ char *gvplugin_api_name(api_t api) { - if (api < 0 || api >= ARRAY_SIZE(api_names)) + if (api >= ARRAY_SIZE(api_names)) return NULL; return api_names[api]; } @@ -77,8 +77,8 @@ boolean gvplugin_install(GVC_t * gvc, api_t api, const char *typestr, #define TYPSIZ 63 char *p, pins[TYPSIZ+1], pnxt[TYPSIZ+1]; - if (api < 0) - return FALSE; + //if (api < 0) + //return FALSE; strncpy(pins, typestr, TYPSIZ); if ((p = strchr(pins, ':'))) @@ -134,8 +134,8 @@ static boolean gvplugin_activate(GVC_t * gvc, api_t api, gvplugin_available_t **pnext; - if (api < 0) - return FALSE; + //if (api < 0) + //return FALSE; /* point to the beginning of the linked list of plugins for this api */ pnext = &(gvc->apis[api]); @@ -265,8 +265,8 @@ gvplugin_available_t *gvplugin_load(GVC_t * gvc, api_t api, const char *str) api_t apidep; /* check for valid apis[] index */ - if (api < 0) - return NULL; + //if (api < 0) + //return NULL; if (api == API_device || api == API_loadimage) /* api dependencies - FIXME - find better way to code these *s */ @@ -359,8 +359,8 @@ char *gvplugin_list(GVC_t * gvc, api_t api, const char *str) static agxbuf xb; /* check for valid apis[] index */ - if (api < 0) - return NULL; + //if (api < 0) + //return NULL; if (first) { agxbinit(&xb, 0, 0); diff --git a/pathplan/Makefile b/pathplan/Makefile deleted file mode 100644 index 6c2d310..0000000 --- a/pathplan/Makefile +++ /dev/null @@ -1,13 +0,0 @@ -CC = clang -EM = emcc -CFLAGS = -I. -OBJS = cvt.c inpoly.c route.c shortest.c \ - solvers.c triang.c util.c visibility.c - - -libpathplan-em.bc: - $(EM) -o libpathplan-em.bc $(CFLAGS) $(OBJS) - -.PHONY: clean -clean: - rm -f *.bc