pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Louis-David Mitterrand <cunctator@apartia.ch>
To: pgsql-sql@postgresql.org
Subject: Re: Compiling "C" Functions
Date: Tue, 27 Feb 2001 21:40:08 +0100
Message-ID: <20010227214008.A493@apartia.ch> (raw)
In-Reply-To: <3A4B5009.9B09745D@yellowbank.com>
References: <3A390BF7.71D0E481@marilia.com>
	<3A4B5009.9B09745D@yellowbank.com>

On Thu, Dec 28, 2000 at 09:36:57AM -0500, Ron Peterson wrote:
> Tulio Oliveira wrote:
> > 
> > I appreciate any "C" Function complete samples, including de command
> > line for
> > the compiler.
> 
> I've attached a generic GNU make snippet for compiling .so files. 
> Adjust to suite your tastes.  Like my math textbooks used to say
> "writing the C code is trivial, and is left as an excercise for the
> reader."  ;)
> 
> CC = /usr/bin/gcc
> TARGET = debug
> #TARGET = final
> DFLAGS = -Wall -g
> FFLAGS = -Wall -O2
> SFLAGS = -fpic -shared
> MYINCLUDES = -I/usr/local/include
> -I/usr/local/src/postgresql/src/include -I/usr/local/postgresql/include
> MYLIBS = -L/usr/local/lib -L/usr/local/postgresql/lib -lpq
> 
> ifeq ($(TARGET),final)
>         MYCFLAGS = $(FFLAGS)
> else
>         MYCFLAGS = $(DFLAGS)
> endif 
> 
> %.so:
>         $(CC) $(MYCFLAGS) $(MYINCLUDES) $(MYLIBS) $(*F).c -c -o $(*F).o
>         $(CC) $(SFLAGS) $(*F).o -o $(*F).so
> 	[ -d $(TARGET) ] || mkdir $(TARGET)
> 	mv $(*F).so $(TARGET)
>         rm *.o

Or using implicit rules, only type "make my_file.so":

INCLUDES = -I /usr/include/postgresql
CFLAGS = -g -Wall $(INCLUDES) -fPIC 

%.so: %.o 
	ld -shared -soname $@ -o $@ $< $(LIBS)


-- 
 THERAMENE: Elle veut quelque temps douter de son malheur,
            Et ne connaissant plus ce héros qu'elle adore,
            Elle voit Hippolyte et le demande encore.
                                          (Phèdre, J-B Racine, acte 5, scène 6)



view thread (3+ messages)

Message-ID: <20010227214008.A493@apartia.ch>
Permalink:  ../20010227214008.A493@apartia.ch/
Also on:    postgresql.org/message-id/20010227214008.A493@apartia.ch

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: cunctator@apartia.ch
  Subject: Re: Compiling "C" Functions
  In-Reply-To: <20010227214008.A493@apartia.ch>
  References: <3A390BF7.71D0E481@marilia.com> <3A4B5009.9B09745D@yellowbank.com> <20010227214008.A493@apartia.ch>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox