[gl2ps] lack of build system

Dominik 'Rathann' Mierzejewski dominik at greysector.net
Fri Oct 2 22:29:37 CEST 2009


Hello all,
I am a developer for Fedora Linux distribution. I made a package of gl2ps
as a shared library, but the lack of build system and no ABI versioning
meant I had to take care of that myself. So far there haven't been any
incompatible ABI changes, but that could well change.

To help solve this, I'm attaching a simple Makefile that builds gl2ps
as a static and a shared library and allows keeping track of the ABI
version. It's not a fully-fledged build system, but I think it's good
enough for a start. Feel free to modify it in any way you please and
distribute it with gl2ps.

I'm also attaching a patch that changes calls to exit(3) to return NULL,
because a shared library should never call exit(3) directly.

Regards,
R.

-- 
Fedora http://fedoraproject.org/wiki/User:Rathann
RPMFusion http://rpmfusion.org | MPlayer http://mplayerhq.hu
"Faith manages."
        -- Delenn to Lennier in Babylon 5:"Confessions and Lamentations"
-------------- next part --------------
# shared library version
# increase MAJOR and reset MINOR/MICRO to zero in case of ABI changes
MAJOR = 0
MINOR = 0
MICRO = 0
OPTFLAGS = -O2 -Wall
CFLAGS += $(OPTFLAGS) -fPIC
PREFIX = /usr/local
LIBDIR = $(PREFIX)/lib
INCLUDEDIR = $(PREFIX)/include
LIBS = -lGL -lm
NAME = gl2ps
HEADERS = gl2ps.h
OBJS = gl2ps.o
LIBNAME = lib$(NAME).a
SLIBNAME_SO = lib$(NAME).so
SLIBNAME_WITH_MAJOR = $(SLIBNAME_SO).$(MAJOR)
SLIBNAME = $(SLIBNAME_WITH_MAJOR).$(MINOR).$(MICRO)

%.o: %.c
	$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<

all: $(SLIBNAME) $(LIBNAME)

clean:
	rm -f $(OBJS) $(SLIBNAME) $(LIBNAME)

$(LIBNAME): $(OBJS)
	$(AR) rcs $@ $^

$(SLIBNAME): $(OBJS)
	$(CC) -shared -Wl,-soname,$(SLIBNAME_WITH_MAJOR) -o $@ $^ $(LIBS) $(LDFLAGS)

install:
	mkdir -p $(DESTDIR)$(LIBDIR)
	install -pm644 $(LIBNAME) $(DESTDIR)$(LIBDIR)
	install -pm755 $(SLIBNAME) $(DESTDIR)$(LIBDIR)
	ln -s $(SLIBNAME) $(DESTDIR)$(LIBDIR)/$(SLIBNAME_WITH_MAJOR)
	ln -s $(SLIBNAME_WITH_MAJOR) $(DESTDIR)$(LIBDIR)/$(SLIBNAME_SO)
	mkdir -p $(DESTDIR)$(INCLUDEDIR)
	install -pm644 $(HEADERS) $(DESTDIR)$(INCLUDEDIR)
-------------- next part --------------
diff -up gl2ps-1.3.3/gl2ps.c.noexit gl2ps-1.3.3/gl2ps.c
--- gl2ps-1.3.3/gl2ps.c.noexit	2009-02-28 23:08:14.000000000 +0100
+++ gl2ps-1.3.3/gl2ps.c	2009-08-23 19:02:17.000000000 +0200
@@ -319,7 +319,7 @@ static void *gl2psMalloc(size_t size)
   ptr = malloc(size);
   if(!ptr){
     gl2psMsg(GL2PS_ERROR, "Couldn't allocate requested memory");
-    exit(1);
+    return(NULL);
   }
   return(ptr);
 }
@@ -330,7 +330,7 @@ static void *gl2psRealloc(void *ptr, siz
   ptr = realloc(ptr, size);
   if(!ptr){
     gl2psMsg(GL2PS_ERROR, "Couldn't reallocate requested memory");
-    exit(1);
+    return(NULL);
   }
   return(ptr);
 }