sci-misc/gt-itm: fix build w/ Clang 16, musl

Closes: https://bugs.gentoo.org/832835
Closes: https://bugs.gentoo.org/741582
Signed-off-by: Sam James <sam@gentoo.org>
This commit is contained in:
Sam James
2022-10-24 19:01:44 +01:00
parent eaee51329b
commit c301cc94e6
5 changed files with 628 additions and 41 deletions

View File

@@ -0,0 +1,326 @@
From 960d73fb2149340e39acc23741ede9dee52b8778 Mon Sep 17 00:00:00 2001
From: Sam James <sam@gentoo.org>
Date: Mon, 24 Oct 2022 18:47:48 +0100
Subject: [PATCH 1/2] Fix build with Clang 16
Bug: https://bugs.gentoo.org/741582
--- a/gt-itm/src/dfs.c
+++ b/gt-itm/src/dfs.c
@@ -23,7 +23,7 @@ int dfs(Graph *G,int n,u_char *vis);
/* check connectivity of graph g */
/* uses depth-first search. */
-isconnected(Graph *G)
+int isconnected(Graph *G)
{
u_char *vis;
Vertex *vp;
--- a/gt-itm/src/edriver.c
+++ b/gt-itm/src/edriver.c
@@ -51,9 +51,7 @@
} \
}\
-main(argc,argv)
- int argc;
- char *argv[];
+int main(int argc, char **argv)
{
int i;
int min, max, sum, bins, *ddist;
@@ -63,14 +61,14 @@ main(argc,argv)
char outfile[MAXF];
char *dstr = "-nd";
int plen, idx;
- FILE *ddf, *evf, *pdf, *fp, *fopen();
+ FILE *ddf, *evf, *pdf, *fp;
int prdist = 1;
enum Field f0, f1;
int first = 1;
if (argc == 1) {
printf("Usage: edriver <filestem> [-nd] [-<f0><f1>]*\n\n");
- return;
+ return 1;
}
/* determine whether to print distributions */
/* determine where in argv the field pairs begin */
--- a/gt-itm/src/eval.c
+++ b/gt-itm/src/eval.c
@@ -201,10 +201,7 @@ int bicomp(Graph *g,int verbose)
}
-void twofield_sptree(g,u,f0,f1)
-Graph*g;
-Vertex*u;
-enum Field f0,f1;
+void twofield_sptree(Graph *g, Vertex *u, enum Field f0, enum Field f1)
{
Vertex *v, *t;
Arc *r;
--- a/gt-itm/src/geog.c
+++ b/gt-itm/src/geog.c
@@ -33,7 +33,7 @@
static char geogId[]="$Id: geog.c,v 1.1 1996/10/04 13:36:46 calvert Exp $";
long fdiam(Graph *g);
-void die(s);
+void die(char* errstr);
double
distance(Vertex *u, Vertex *v)
@@ -75,7 +75,7 @@ printparms(char *buf,geo_parms *pp)
void
randomize(long* a, long size, long mean, int iters)
{
-register i,indx;
+int i,indx;
for (i=0; i<size; i++) /* initialize */
a[i] = mean;
@@ -149,11 +149,11 @@ geo(long seed, geo_parms *pp)
{
double p,d,L,radius,r;
u_char *occ;
-register int scale;
+int scale;
unsigned nbytes, index, x, y;
u_long units,pertrange;
int mallocd;
-register i,j;
+int i,j;
Graph *G;
Vertex *up,*vp;
char namestr[128];
@@ -319,7 +319,7 @@ int
edge_level(Vertex *u, Vertex *v, int nlev)
{
char ss[MAXNAMELEN], tt[MAXNAMELEN];
-register char *s=ss, *t=tt, *b, *c;
+char *s=ss, *t=tt, *b, *c;
nlev -= 1;
@@ -359,7 +359,7 @@ geo_hier(long seed,
Graph *newG, *tG, *GG, *srcG, *dstG;
long *numv; /* array of sizes of lower-level graphs */
geo_parms *curparms, workparms[MAXLEVEL];
-register i,k,indx;
+int i,k,indx;
long dst;
int temp,total,lowsize,otherend,blen,level;
long maxP[MAXLEVEL], maxDiam[MAXLEVEL], wt[MAXLEVEL];
@@ -614,7 +614,7 @@ char vnamestr[MAXNAMELEN];
*/
{
char buf[ID_FIELD_SIZE+1];
- register char *cp;
+ char *cp;
int len, nextlen, left;
strcpy(tG->util_types,GEO_UTIL); /* same for all geo graphs, */
--- a/gt-itm/src/itm.c
+++ b/gt-itm/src/itm.c
@@ -56,7 +56,7 @@
char *delim = " \t\n", *nonestr = "<none>";
static char errstr[256];
-void die(s);
+void die(char* errstr);
char *
get_geoparms(FILE * f, geo_parms * pp)
@@ -298,7 +298,7 @@ geo_parms parmsbuf[MAXLEVEL]; /* make sure MAXLEVEL >= 3 */
return NULL;
}
-main(int argc, char **argv)
+int main(int argc, char **argv)
{
FILE *infile;
char *rv;
@@ -306,7 +306,7 @@ main(int argc, char **argv)
if (argc == 1) {
printf("itm <spec-file0> <spec-file1> ....\n\n");
- return;
+ return 1;
}
while (--argc) {
--- a/gt-itm/src/sgb2alt.c
+++ b/gt-itm/src/sgb2alt.c
@@ -24,7 +24,7 @@
#include "gb_save.h"
#include "geog.h"
-main(argc,argv)
+int main(argc,argv)
int argc;
char *argv[];
{
@@ -36,14 +36,14 @@ main(argc,argv)
if (argc != 3) {
printf("sgb2old <sgfile> <altfile>\n\n");
- return;
+ return 1;
}
fout = fopen(argv[2],"w");
g = restore_graph(argv[1]);
if (g == NULL) {
printf("%s does not contain a correct SGB graph\n",argv[1]);
- return;
+ return 1;
}
fprintf(fout,"GRAPH (#nodes #edges id uu vv ww xx yy zz):\n");
--- a/gt-itm/src/ts.c
+++ b/gt-itm/src/ts.c
@@ -76,7 +76,7 @@ int stubs_OK(Vertex *snp0,Vertex *snp1);
long
fdiam(Graph *g)
{
-register i,j,k;
+int i,j,k;
long **dist, **ldist;
int changed,mallocd;
long diam, ldiam, newdist = 0, otherend;
@@ -174,7 +174,7 @@ Arc *a;
} /* fdiam */
void
-die(s)
+die(char* s)
{
fprintf(stderr,"Fatal error %s\n",s);
exit(1);
@@ -187,7 +187,7 @@ exit(1);
void
copyedges(Graph *fromG, Graph *toG, long base)
{
-register i, indx;
+int i, indx;
Vertex *np, *vp, *basep;
Arc *ap;
@@ -245,7 +245,7 @@ long i,j,k;
long indx, diam, totalnodes, base, dom;
char dnodename[ID_FIELD_SIZE], snodename[ID_FIELD_SIZE];
int dnamelen, numtries=0;
-register Vertex *v,*dnp, *snp, /* domain node and stub node pointers */
+Vertex *v,*dnp, *snp, /* domain node and stub node pointers */
*ddnp, *fp, *tp, *tmp;
Arc *a;
--- a/gt-itm/src/sgb2alt.c
+++ b/gt-itm/src/sgb2alt.c
@@ -32,7 +32,7 @@ int main(argc,argv)
Vertex *v;
Arc *a;
Graph *g;
- FILE *fopen(), *fout;
+ FILE *fout;
if (argc != 3) {
printf("sgb2old <sgfile> <altfile>\n\n");
--- a/sgb2ns/sgb2comns.c
+++ b/sgb2ns/sgb2comns.c
@@ -80,9 +80,7 @@ void print_flat_nodes(FILE *fout, Graph *g);
void print_edges(FILE *fout, Graph *g);
void print_hdr(FILE *fout, Graph *g);
-main(argc,argv)
- int argc;
- char *argv[];
+int main(int argc, char *argv[])
{
int hier_flag=0;
@@ -102,7 +100,7 @@ main(argc,argv)
g = restore_graph(argv[1]);
if (g == NULL) {
printf("%s does not contain a correct SGB graph\n",argv[1]);
- return;
+ return 1;
}
if (hier_flag)
--- a/sgb2ns/sgb2hierns.c
+++ b/sgb2ns/sgb2hierns.c
@@ -47,9 +47,7 @@
#define HUGE 655536
-main(argc,argv)
- int argc;
- char *argv[];
+int main(int argc, char *argv[])
{
int i,
@@ -89,7 +87,7 @@ main(argc,argv)
/* for the purpose of scenario generator, need to return a list of transits
& stubs and num of nodes in each - hence the optional third arg topofile */
printf("sgb2hierns <sgfile> <outfile> ?<topofile>?\n\n");
- return;
+ return 1;
}
fout = fopen(argv[2],"w");
@@ -101,7 +99,7 @@ main(argc,argv)
g = restore_graph(argv[1]);
if (g == NULL) {
printf("%s does not contain a correct SGB graph\n",argv[1]);
- return;
+ return 1;
}
fprintf(fout,"# Generated by sgb2hier-ns,sgb2hier-ns generated from sgb2ns\n");
--- a/sgb2ns/sgb2ns.c
+++ b/sgb2ns/sgb2ns.c
@@ -41,27 +41,25 @@
#include "gb_save.h"
#include "geog.h"
-main(argc,argv)
- int argc;
- char *argv[];
+int main(int argc,char *argv[])
{
int i, j, nlink;
Vertex *v;
Arc *a;
Graph *g;
- FILE *fopen(), *fout;
+ FILE *fout;
char m[420];
if (argc != 3) {
printf("sgb2ns <sgfile> <nsfile>\n\n");
- return;
+ return 1;
}
fout = fopen(argv[2],"w");
g = restore_graph(argv[1]);
if (g == NULL) {
printf("%s does not contain a correct SGB graph\n",argv[1]);
- return;
+ return 1;
}
fprintf(fout, "# Generated by sgb2ns, created by Polly Huang\n");
--- a/sgb2ns/ts2ns.c
+++ b/sgb2ns/ts2ns.c
@@ -55,7 +55,7 @@ main(argc,argv)
Vertex *v;
Arc *a;
Graph *g;
- FILE *fopen(), *fout;
+ FILE *fout;
char m[420], name[40];
int transits[HUGE];
int p,q, total_transits;

View File

@@ -0,0 +1,69 @@
From 15670744cc6a182cf0d2a4ed16748255ac1ff5c8 Mon Sep 17 00:00:00 2001
From: Sam James <sam@gentoo.org>
Date: Mon, 24 Oct 2022 18:48:48 +0100
Subject: [PATCH 2/2] Fix musl build
Bug: https://bugs.gentoo.org/832835
--- a/gt-itm/src/dfs.c
+++ b/gt-itm/src/dfs.c
@@ -19,22 +19,22 @@ static char dfsID[]="$Id: dfs.c,v 1.1 1996/10/04 13:36:32 calvert Exp $";
#define NBBY 8
-int dfs(Graph *G,int n,u_char *vis);
+int dfs(Graph *G,int n,unsigned char *vis);
/* check connectivity of graph g */
/* uses depth-first search. */
int isconnected(Graph *G)
{
-u_char *vis;
+unsigned char *vis;
Vertex *vp;
int i,nbytes;
nbytes = (G->n/NBBY)+ (G->n%NBBY?1:0);
if (nbytes < STACKMAX) { /* for small amounts we use stack frame */
- vis = (u_char *) alloca(nbytes);
+ vis = (unsigned char *) alloca(nbytes);
} else {
- vis = (u_char *) malloc(nbytes);
+ vis = (unsigned char *) malloc(nbytes);
}
for (i=0; i<nbytes; i++) vis[i]=0;
@@ -54,7 +54,7 @@ int i,nbytes;
/* trivial depth-first search. */
/* Returns number of newly-visited nodes in subtree rooted at node n. */
int
-dfs(Graph *G,int n,u_char *vis)
+dfs(Graph *G,int n,unsigned char *vis)
{
int nvis, i, nextn;
Vertex *vp;
--- a/gt-itm/src/geog.c
+++ b/gt-itm/src/geog.c
@@ -148,7 +148,7 @@ Graph *
geo(long seed, geo_parms *pp)
{
double p,d,L,radius,r;
-u_char *occ;
+unsigned char *occ;
int scale;
unsigned nbytes, index, x, y;
u_long units,pertrange;
@@ -189,10 +189,10 @@ char namestr[128];
nbytes = ((scale*scale)%NBBY ? (scale*scale/NBBY)+1 : (scale*scale)/NBBY);
if (nbytes < STACKMAX) { /* small amount - just do it in the stack */
- occ = (u_char *) alloca(nbytes);
+ occ = (unsigned char *) alloca(nbytes);
mallocd = 0;
} else {
- occ = (u_char *) malloc(nbytes);
+ occ = (unsigned char *) malloc(nbytes);
mallocd = 1;
}

View File

@@ -0,0 +1,201 @@
--- a/gt-itm/sample-graphs/rand/r10/Runconvert
+++ b/gt-itm/sample-graphs/rand/r10/Runconvert
@@ -1,5 +1,5 @@
#!/bin/csh
foreach i (0 1 2)
- ../../../bin/sgb2alt r10-$i.gb r10-$i.alt
+ sgb2alt r10-$i.gb r10-$i.alt
end
--- a/gt-itm/sample-graphs/rand/r10/Runeval
+++ b/gt-itm/sample-graphs/rand/r10/Runeval
@@ -1,5 +1,5 @@
#!/bin/csh
foreach i (0 1 2)
- ../../../bin/edriver r10-$i -nd -hh -ll -hl
+ edriver r10-$i -nd -hh -ll -hl
end
--- a/gt-itm/sample-graphs/rand/r100/Runconvert
+++ b/gt-itm/sample-graphs/rand/r100/Runconvert
@@ -1,5 +1,5 @@
#!/bin/csh
foreach i (0 1 2 3 4 5 6 7 8 9)
- ../../../bin/sgb2alt r100-$i.gb r100-$i.alt
+ sgb2alt r100-$i.gb r100-$i.alt
end
--- a/gt-itm/sample-graphs/rand/r100/Runeval
+++ b/gt-itm/sample-graphs/rand/r100/Runeval
@@ -1,5 +1,5 @@
#!/bin/csh
foreach i (0 1 2 3 4 5 6 7 8 9)
- ../../../bin/edriver r100-$i -nd -hh -ll -hl
+ edriver r100-$i -nd -hh -ll -hl
end
--- a/gt-itm/sample-graphs/ts/ts100/Runconvert
+++ b/gt-itm/sample-graphs/ts/ts100/Runconvert
@@ -1,5 +1,5 @@
#!/bin/csh
foreach i (0 1 2 3 4 5 6 7 8 9)
- ../../bin/sgb2alt ts100-$i.gb ts100-$i.alt
+ sgb2alt ts100-$i.gb ts100-$i.alt
end
--- a/gt-itm/sample-graphs/ts/ts100/Runeval
+++ b/gt-itm/sample-graphs/ts/ts100/Runeval
@@ -1,5 +1,5 @@
#!/bin/csh
foreach i (0 1 2 3 4 5 6 7 8 9)
- ../../../bin/edriver ts100-$i -nd -hh -ll -hl
+ edriver ts100-$i -nd -hh -ll -hl
end
--- a/gt-itm/sample-graphs/ts/ts600/Runconvert
+++ b/gt-itm/sample-graphs/ts/ts600/Runconvert
@@ -1,5 +1,5 @@
#!/bin/csh
foreach i (0 1 2 3 4 5 6 7 8 9)
- ../../bin/sgb2alt ts600-$i.gb ts600-$i.alt
+ sgb2alt ts600-$i.gb ts600-$i.alt
end
--- a/gt-itm/sample-graphs/ts/ts600/Runeval
+++ b/gt-itm/sample-graphs/ts/ts600/Runeval
@@ -1,5 +1,5 @@
#!/bin/csh
foreach i (0 1 2 3 4 5 6 7 8 9)
- ../../../bin/edriver ts600-$i -nd -hh -ll -hl
+ edriver ts600-$i -nd -hh -ll -hl
end
--- a/gt-itm/src/Makefile
+++ b/gt-itm/src/Makefile
@@ -9,10 +9,10 @@
#
# For Solaris: uncomment the next two lines
#SYS = -DSYSV
-#LIBS = -lm -lgb5
+#LIBS = -lm -lgb
# For SunOS: uncomment the next line
-LIBS = -lm -lgb4
+LIBS = -lm -lgb
IDIR = ../include
@@ -35,29 +35,22 @@ EH = $(IDIR)/gb_graph.h $(IDIR)/gb_save.h $(IDIR)/gb_dijk.h \
all: itm sgb2alt edriver
itm: $(GO)
- $(CC) $(CFLAGS) -o $(BDIR)/itm $(GO) $(LIBS)
+ $(CC) $(LDFLAGS) $(CFLAGS) -o $(BDIR)/itm $(GO) $(LIBS)
-itm.o: $(GH)
-geog.o: $(GH)
-ts.o: $(GH)
-dfs.o: $(GH)
sgb2alt: $(CO)
- $(CC) $(CFLAGS) -o $(BDIR)/sgb2alt $(CO) $(LIBS)
+ $(CC) $(LDFLAGS) $(CFLAGS) -o $(BDIR)/sgb2alt $(CO) $(LIBS)
-sgb2alt.o: $(CH)
edriver: $(EO)
- $(CC) $(CFLAGS) -o $(BDIR)/edriver $(EO) $(LIBS)
+ $(CC) $(LDFLAGS) $(CFLAGS) -o $(BDIR)/edriver $(EO) $(LIBS)
-edriver.o: $(EH)
-eval.o: $(IDIR)/gb_graph.h $(IDIR)/gb_dijk.h $(IDIR)/eval.h
clean:
--- a/gt-itm/src/eval.c
+++ b/gt-itm/src/eval.c
@@ -159,7 +159,7 @@ int bicomp(Graph *g,int verbose)
if (u == &dummy) {
if (verbose) {
if (artic_pt)
- printf(" and %d (this ends a connected
+ printf(" and %d (this ends a connected \
component of the graph)\n", idx(g, artic_pt));
else
printf("Isolated vertex %d\n", idx(g, v));
--- a/gt-itm/src/geog.c
+++ b/gt-itm/src/geog.c
@@ -6,7 +6,7 @@
*/
#include <stdio.h>
-#include <sys/types.h> /* for NBBY */
+#include <sys/param.h> /* for NBBY */
#include <alloca.h>
#include <assert.h>
#include <string.h> /* for strchr() */
--- a/sgb2ns/Makefile
+++ b/sgb2ns/Makefile
@@ -8,11 +8,10 @@
# uncomment the two Solaris lines below, and comment the SunOS line.
#
# For Solaris: uncomment the next two lines
-SYS = -DSYSV
-LIBS = -lm -lgb5
+LIBS = -lm -lgb
# For SunOS: uncomment the next line
-#LIBS = -lm -lgb4
+#LIBS = -lm -lgb
GT_ITM = ../gt-itm
IDIR = $(GT_ITM)/include
@@ -33,16 +32,16 @@ CH = $(IDIR)/geog.h $(IDIR)/gb_graph.h $(IDIR)/gb_save.h
all: sgb2comns sgb2hierns sgb2ns ts2ns
sgb2ns: $(CN)
- $(CC) $(CFLAGS) -o $(BDIR)/sgb2ns $(CN) $(LIBS)
+ $(CC) $(LDFLAGS) $(CFLAGS) -o $(BDIR)/sgb2ns $(CN) $(LIBS)
ts2ns: $(CN)
- $(CC) $(CFLAGS) -o $(BDIR)/ts2ns $(CN) $(LIBS)
+ $(CC) $(LDFLAGS) $(CFLAGS) -o $(BDIR)/ts2ns $(CN) $(LIBS)
sgb2hierns: $(HN)
- $(CC) $(CFLAGS) -o $(BDIR)/sgb2hierns $(HN) $(LIBS)
+ $(CC) $(LDFLAGS) $(CFLAGS) -o $(BDIR)/sgb2hierns $(HN) $(LIBS)
sgb2comns: $(COM)
- $(CC) $(CFLAGS) -o $(BDIR)/sgb2comns $(COM) $(LIBS)
+ $(CC) $(LDFLAGS) $(CFLAGS) -o $(BDIR)/sgb2comns $(COM) $(LIBS)
sgb2ns.o: $(CH)
sgb2hierns.o: $(CH)
--- a/sgb2ns/sgb2comns.c
+++ b/sgb2ns/sgb2comns.c
@@ -49,6 +49,7 @@
*/
#include <stdio.h>
+#include <stdlib.h>
#include <strings.h>
#include <string.h>
#include "gb_graph.h"
--- a/sgb2ns/sgb2hierns.c
+++ b/sgb2ns/sgb2hierns.c
@@ -34,7 +34,8 @@
*/
#include <stdio.h>
-#include <strings.h>
+#include <stdlib.h>
+#include <string.h>
#include "gb_graph.h"
#include "gb_save.h"
#include "geog.h"

View File

@@ -1,5 +1,5 @@
--- gt-itm/src/geog.c
+++ gt-itm/src/geog.c
--- a/gt-itm/src/geog.c
+++ b/gt-itm/src/geog.c
@@ -6,6 +6,7 @@
*/
@@ -18,8 +18,8 @@
double
distance(Vertex *u, Vertex *v)
{
--- gt-itm/src/ts.c
+++ gt-itm/src/ts.c
--- a/gt-itm/src/ts.c
+++ b/gt-itm/src/ts.c
@@ -8,6 +8,7 @@
*/
@@ -39,8 +39,8 @@
/* fast diameter computation using Floyd-Warshall
* Returns the HOP diameter of the graph, i.e. each edge given UNIT wt.
* Leaves the LENGTH diameter of the graph in g->Gldiam.
--- gt-itm/include/geog.h
+++ gt-itm/include/geog.h
--- a/gt-itm/include/geog.h
+++ b/gt-itm/include/geog.h
@@ -74,3 +74,8 @@
geo_parms* toppp, /* params for transit connectivity */
geo_parms* transpp, /* " " transit domains */
@@ -50,8 +50,8 @@
+long idist(Vertex *u, Vertex *v);
+int printparms(char *buf,geo_parms *pp);
+int isconnected(Graph *G);
--- gt-itm/src/edriver.c
+++ gt-itm/src/edriver.c
--- a/gt-itm/src/edriver.c
+++ b/gt-itm/src/edriver.c
@@ -35,6 +35,8 @@
*/
@@ -61,8 +61,8 @@
#include "gb_graph.h"
#include "gb_save.h"
#include "gb_dijk.h"
--- gt-itm/include/eval.h
+++ gt-itm/include/eval.h
--- a/gt-itm/include/eval.h
+++ b/gt-itm/include/eval.h
@@ -8,4 +8,7 @@
enum Field {Len, A, B, Hops};
@@ -72,8 +72,8 @@
+void dopaths(Graph *g, enum Field f0, enum Field f1, int *rmin, int *rmax, float *ravg);
+void dodepthdist(Graph *g, int** ddist);
+int bicomp(Graph *g,int verbose);
--- gt-itm/src/dfs.c
+++ gt-itm/src/dfs.c
--- a/gt-itm/src/dfs.c
+++ b/gt-itm/src/dfs.c
@@ -6,6 +6,7 @@
*/
@@ -91,8 +91,8 @@
/* check connectivity of graph g */
/* uses depth-first search. */
isconnected(Graph *G)
--- gt-itm/src/itm.c.orig 2010-10-12 17:11:25.748461793 +0200
+++ gt-itm/src/itm.c 2010-10-12 17:13:09.237165705 +0200
--- a/gt-itm/src/itm.c.orig
+++ b/gt-itm/src/itm.c
@@ -42,6 +42,7 @@
#include <stdlib.h> /* for calloc(),atoi(),etc. */
#include <string.h> /* for strtok() */

View File

@@ -1,15 +1,17 @@
# Copyright 1999-2021 Gentoo Authors
# Copyright 1999-2022 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=6
EAPI=8
inherit toolchain-funcs
inherit flag-o-matic toolchain-funcs
DESCRIPTION="Routines to generate / analyze graphs using models for internetwork topology"
HOMEPAGE="http://www.cc.gatech.edu/fac/Ellen.Zegura/graphs.html
http://www.isi.edu/nsnam/ns/ns-topogen.html#gt-itm"
SRC_URI="http://www.cc.gatech.edu/fac/Ellen.Zegura/gt-itm/gt-itm.tar.gz -> ${P}.tar.gz
http://www.isi.edu/nsnam/dist/sgb2ns.tar.gz -> sgb2ns-${PV}.tar.gz"
S="${WORKDIR}/${PN}"
S2="${WORKDIR}/sgb2ns"
LICENSE="all-rights-reserved sgb2ns"
SLOT="0"
@@ -20,10 +22,13 @@ IUSE="doc"
DEPEND="dev-util/sgb"
RDEPEND="${DEPEND}"
S="${WORKDIR}/${PN}"
S2="${WORKDIR}/sgb2ns"
PATCHES=(
"${FILESDIR}"/${PN}-19961004-gentoo.patch
"${FILESDIR}"/${PN}-implicits.patch
"${FILESDIR}"/${PN}-19961004-Fix-build-with-Clang-16.patch
"${FILESDIR}"/${PN}-19961004-Fix-musl-build.patch
)
PATCHES=( "${FILESDIR}"/${PN}-implicits.patch )
DOCS=( README docs/. )
src_unpack() {
@@ -35,32 +40,16 @@ src_unpack() {
}
src_prepare() {
sed -ri -e '/^[[:alnum:]]+\.o:/d' \
-e 's|LIBS = -lm -lgb.*|LIBS = -lm -lgb|' \
-e 's/\$\(CC\)/& \$\(LDFLAGS\)/g' \
src/Makefile || die
sed -ri -e '/^SYS = -DSYSV/d' \
-e 's|LIBS = -lm -lgb.*|LIBS = -lm -lgb|' \
-e 's/\$\(CC\)/& \$\(LDFLAGS\)/g' \
"${S2}"/Makefile || die
rm -f lib/* || die
while IFS="" read -d $'\0' -r file; do
sed -i -re 's|(\.\./)+bin/||g' "$file" || die
done < <(find sample-graphs/ -perm /a+x -type f -name 'Run*' -print0)
sed -i -e 's|sys/types.h|sys/param.h|' src/geog.c || die
sed -i -e '162 s/connected $/connected \\/' src/eval.c || die
# fix implicit function declarations
sed -i -e '/stdio.h/ a\#include <stdlib.h>' \
"${S2}/sgb2comns.c" "${S2}/sgb2hierns.c" || die
sed -i -e "s/<strings.h>/<string.h>/g" "${S2}/sgb2hierns.c" || die
cd "${WORKDIR}" || die
default
cd "${S}" || die
}
src_compile() {
append-cflags -std=gnu89
emake -C src CFLAGS="${CFLAGS} -I../include" LDFLAGS="${LDFLAGS}" \
CC="$(tc-getCC)"
@@ -70,11 +59,13 @@ src_compile() {
src_install() {
dobin bin/*
einstalldocs
newdoc "${S2}"/README README.sgb2ns
if use doc; then
dodoc -r sample-graphs
dodoc "${S2}"/*.{tcl,gb}
docompress -x "/usr/share/doc/${PF}/sample-graphs"
docompress -x /usr/share/doc/${PF}/sample-graphs
fi
}