Received: from styx.apartia.ch (APoncelet-101-2-1-171.abo.wanadoo.fr [193.251.42.171]) by mail.postgresql.org (8.11.1/8.11.1) with ESMTP id f1S7dux89824 for ; Wed, 28 Feb 2001 02:39:56 -0500 (EST) (envelope-from cunctator@apartia.ch) Received: by styx.apartia.ch (Postfix, from userid 1000) id 078015E5; Tue, 27 Feb 2001 21:40:08 +0100 (CET) Date: Tue, 27 Feb 2001 21:40:08 +0100 From: Louis-David Mitterrand To: pgsql-sql@postgresql.org Subject: Re: Compiling "C" Functions Message-ID: <20010227214008.A493@apartia.ch> Mail-Followup-To: pgsql-sql@postgresql.org References: <3A390BF7.71D0E481@marilia.com> <3A4B5009.9B09745D@yellowbank.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: 8bit User-Agent: Mutt/1.3.14i In-Reply-To: <3A4B5009.9B09745D@yellowbank.com>; from ron.peterson@yellowbank.com on Thu, Dec 28, 2000 at 09:36:57AM -0500 X-URL: http://www.apartia.org X-Archive-Number: 200102/420 X-Sequence-Number: 1625 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)