Thread: utils C files
I have applied the following diff to make the sharing of C files among modules more sane. Instead of having configure.in set the file name to strdup.o and have the Makefiles specify the path, I set it to the full path $(top_builddir)/src/utils/strdup.o and have the makefiles use that directly, rather than going through with 'make -c dirname filename'. -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 853-3000 + If your life is a hard drive, | 830 Blythe Avenue + Christ can be your backup. | Drexel Hill, Pennsylvania 19026 Index: configure.in =================================================================== RCS file: /cvsroot/pgsql/configure.in,v retrieving revision 1.187 diff -c -r1.187 configure.in *** configure.in 7 Jul 2002 20:28:24 -0000 1.187 --- configure.in 15 Jul 2002 21:07:07 -0000 *************** *** 870,877 **** # have working "long long int" support -- see below. SNPRINTF='' ! AC_CHECK_FUNCS(snprintf, [], SNPRINTF='snprintf.o') ! AC_CHECK_FUNCS(vsnprintf, [], SNPRINTF='snprintf.o') AC_SUBST(SNPRINTF) --- 870,877 ---- # have working "long long int" support -- see below. SNPRINTF='' ! AC_CHECK_FUNCS(snprintf, [], SNPRINTF='$(top_builddir)/src/backend/port/snprintf.o') ! AC_CHECK_FUNCS(vsnprintf, [], SNPRINTF='$(top_builddir)/src/backend/port/snprintf.o') AC_SUBST(SNPRINTF) *************** *** 913,921 **** AC_SUBST(MISSING_RANDOM) AC_CHECK_FUNCS(inet_aton, [], INET_ATON='inet_aton.o') AC_SUBST(INET_ATON) ! AC_CHECK_FUNCS(strerror, [], STRERROR='strerror.o') AC_SUBST(STRERROR) ! AC_CHECK_FUNCS(strdup, [], STRDUP='../../utils/strdup.o') AC_SUBST(STRDUP) AC_CHECK_FUNCS(strtol, [], STRTOL='strtol.o') AC_SUBST(STRTOL) --- 913,921 ---- AC_SUBST(MISSING_RANDOM) AC_CHECK_FUNCS(inet_aton, [], INET_ATON='inet_aton.o') AC_SUBST(INET_ATON) ! AC_CHECK_FUNCS(strerror, [], STRERROR='$(top_builddir)/src/backend/port/strerror.o') AC_SUBST(STRERROR) ! AC_CHECK_FUNCS(strdup, [], STRDUP='$(top_builddir)/src/utils/strdup.o') AC_SUBST(STRDUP) AC_CHECK_FUNCS(strtol, [], STRTOL='strtol.o') AC_SUBST(STRTOL) *************** *** 1093,1109 **** ], [ AC_MSG_RESULT(no) # Force usage of our own snprintf, since system snprintf is broken ! SNPRINTF='snprintf.o' INT64_FORMAT='"%lld"' ], [ AC_MSG_RESULT(assuming not on target machine) # Force usage of our own snprintf, since we cannot test foreign snprintf ! SNPRINTF='snprintf.o' INT64_FORMAT='"%lld"' ]) ], [ AC_MSG_RESULT(assuming not on target machine) # Force usage of our own snprintf, since we cannot test foreign snprintf ! SNPRINTF='snprintf.o' INT64_FORMAT='"%lld"' ]) else --- 1093,1109 ---- ], [ AC_MSG_RESULT(no) # Force usage of our own snprintf, since system snprintf is broken ! SNPRINTF='$(top_builddir)/src/backend/port/snprintf.o' INT64_FORMAT='"%lld"' ], [ AC_MSG_RESULT(assuming not on target machine) # Force usage of our own snprintf, since we cannot test foreign snprintf ! SNPRINTF='$(top_builddir)/src/backend/port/snprintf.o' INT64_FORMAT='"%lld"' ]) ], [ AC_MSG_RESULT(assuming not on target machine) # Force usage of our own snprintf, since we cannot test foreign snprintf ! SNPRINTF='$(top_builddir)/src/backend/port/snprintf.o' INT64_FORMAT='"%lld"' ]) else Index: doc/FAQ_Solaris =================================================================== RCS file: /cvsroot/pgsql/doc/FAQ_Solaris,v retrieving revision 1.14 diff -c -r1.14 FAQ_Solaris *** doc/FAQ_Solaris 4 Mar 2002 17:47:11 -0000 1.14 --- doc/FAQ_Solaris 15 Jul 2002 21:07:07 -0000 *************** *** 94,100 **** (1) In src/Makefile.global, change the line SNPRINTF = to read ! SNPRINTF = snprintf.o (2) In src/backend/port/Makefile, add "snprintf.o" to OBJS. (Skip this step if you see "$(SNPRINTF)" already listed in OBJS.) --- 94,100 ---- (1) In src/Makefile.global, change the line SNPRINTF = to read ! SNPRINTF = $(top_builddir)/src/backend/port/snprint.o (2) In src/backend/port/Makefile, add "snprintf.o" to OBJS. (Skip this step if you see "$(SNPRINTF)" already listed in OBJS.) Index: src/backend/port/Makefile =================================================================== RCS file: /cvsroot/pgsql/src/backend/port/Makefile,v retrieving revision 1.13 diff -c -r1.13 Makefile *** src/backend/port/Makefile 5 May 2002 16:02:37 -0000 1.13 --- src/backend/port/Makefile 15 Jul 2002 21:07:16 -0000 *************** *** 21,54 **** top_builddir = ../../.. include $(top_builddir)/src/Makefile.global ! OBJS = dynloader.o pg_sema.o pg_shmem.o ! OBJS += $(GETHOSTNAME) $(GETRUSAGE) $(INET_ATON) $(ISINF) $(MEMCMP) \ ! $(MISSING_RANDOM) $(SNPRINTF) $(SRANDOM) $(STRCASECMP) $(STRERROR) \ ! $(STRTOL) $(STRTOUL) ! OBJS += $(TAS) - ifdef STRDUP - OBJS += $(top_builddir)/src/utils/strdup.o - endif ifeq ($(PORTNAME), qnx4) ! OBJS += getrusage.o qnx4/SUBSYS.o endif ifeq ($(PORTNAME), beos) ! OBJS += beos/SUBSYS.o endif ifeq ($(PORTNAME), darwin) ! OBJS += darwin/SUBSYS.o endif all: SUBSYS.o SUBSYS.o: $(OBJS) $(LD) $(LDREL) $(LDOUT) $@ $^ - - $(top_builddir)/src/utils/strdup.o: - $(MAKE) -C $(top_builddir)/src/utils strdup.o qnx4/SUBSYS.o: qnx4.dir --- 21,48 ---- top_builddir = ../../.. include $(top_builddir)/src/Makefile.global ! OBJS=dynloader.o pg_sema.o pg_shmem.o ! OBJS+=$(GETHOSTNAME) $(GETRUSAGE) $(INET_ATON) $(ISINF) $(MEMCMP) \ ! $(MISSING_RANDOM) $(SNPRINTF) $(SRANDOM) $(STRCASECMP) $(STRDUP) \ ! $(STRERROR) $(STRTOL) $(STRTOUL) ! OBJS+=$(TAS) ifeq ($(PORTNAME), qnx4) ! OBJS+=getrusage.o qnx4/SUBSYS.o endif ifeq ($(PORTNAME), beos) ! OBJS+=beos/SUBSYS.o endif ifeq ($(PORTNAME), darwin) ! OBJS+=darwin/SUBSYS.o endif all: SUBSYS.o SUBSYS.o: $(OBJS) $(LD) $(LDREL) $(LDOUT) $@ $^ qnx4/SUBSYS.o: qnx4.dir Index: src/bin/pg_dump/Makefile =================================================================== RCS file: /cvsroot/pgsql/src/bin/pg_dump/Makefile,v retrieving revision 1.34 diff -c -r1.34 Makefile *** src/bin/pg_dump/Makefile 6 Jul 2002 20:12:30 -0000 1.34 --- src/bin/pg_dump/Makefile 15 Jul 2002 21:07:17 -0000 *************** *** 14,34 **** include $(top_builddir)/src/Makefile.global OBJS= pg_backup_archiver.o pg_backup_db.o pg_backup_custom.o \ ! pg_backup_files.o pg_backup_null.o pg_backup_tar.o sprompt.o ! ! ifdef STRDUP ! OBJS+=$(top_builddir)/src/utils/strdup.o ! ! $(top_builddir)/src/utils/strdup.o: ! $(MAKE) -C $(top_builddir)/src/utils strdup.o ! endif ! ! ifdef STRTOUL ! OBJS+=$(top_builddir)/src/backend/port/strtoul.o ! ! $(top_builddir)/src/backend/port/strtoul.o: ! $(MAKE) -C $(top_builddir)/src/backend/port strtoul.o ! endif override CPPFLAGS := -I$(libpq_srcdir) $(CPPFLAGS) --- 14,21 ---- include $(top_builddir)/src/Makefile.global OBJS= pg_backup_archiver.o pg_backup_db.o pg_backup_custom.o \ ! pg_backup_files.o pg_backup_null.o pg_backup_tar.o sprompt.o \ ! $(STRDUP) $(STRTOUL) override CPPFLAGS := -I$(libpq_srcdir) $(CPPFLAGS) Index: src/bin/psql/Makefile =================================================================== RCS file: /cvsroot/pgsql/src/bin/psql/Makefile,v retrieving revision 1.33 diff -c -r1.33 Makefile *** src/bin/psql/Makefile 6 Jul 2002 20:12:30 -0000 1.33 --- src/bin/psql/Makefile 15 Jul 2002 21:07:17 -0000 *************** *** 17,57 **** override CPPFLAGS := -I$(libpq_srcdir) $(CPPFLAGS) ! OBJS=command.o common.o help.o input.o stringutils.o mainloop.o \ ! copy.o startup.o prompt.o variables.o large_obj.o print.o describe.o \ ! sprompt.o tab-complete.o mbprint.o all: submake psql - - ifdef STRDUP - OBJS+=$(top_builddir)/src/utils/strdup.o - - $(top_builddir)/src/utils/strdup.o: - $(MAKE) -C $(top_builddir)/src/utils strdup.o - endif - - # Move these to the utils directory? - - ifdef STRERROR - OBJS+=$(top_builddir)/src/backend/port/strerror.o - - $(top_builddir)/src/backend/port/strerror.o: - $(MAKE) -C $(top_builddir)/src/backend/port strerror.o - endif - - ifdef SNPRINTF - OBJS+=$(top_builddir)/src/backend/port/snprintf.o - - $(top_builddir)/src/backend/port/snprintf.o: - $(MAKE) -C $(top_builddir)/src/backend/port snprintf.o - endif - - ifdef STRTOUL - OBJS+=$(top_builddir)/src/backend/port/strtoul.o - - $(top_builddir)/src/backend/port/strtoul.o: - $(MAKE) -C $(top_builddir)/src/backend/port strtoul.o - endif # End of hacks for picking up backend 'port' modules --- 17,28 ---- override CPPFLAGS := -I$(libpq_srcdir) $(CPPFLAGS) ! OBJS=command.o common.o help.o input.o stringutils.o mainloop.o copy.o \ ! startup.o prompt.o variables.o large_obj.o print.o describe.o \ ! sprompt.o tab-complete.o mbprint.o $(SNPRINTF) $(STRDUP) \ ! $(STRERROR) $(STRTOUL) all: submake psql # End of hacks for picking up backend 'port' modules Index: src/interfaces/ecpg/preproc/Makefile =================================================================== RCS file: /cvsroot/pgsql/src/interfaces/ecpg/preproc/Makefile,v retrieving revision 1.83 diff -c -r1.83 Makefile *** src/interfaces/ecpg/preproc/Makefile 11 Mar 2002 12:56:02 -0000 1.83 --- src/interfaces/ecpg/preproc/Makefile 15 Jul 2002 21:07:17 -0000 *************** *** 18,40 **** endif OBJS=preproc.o pgc.o type.o ecpg.o ecpg_keywords.o output.o\ ! keywords.o c_keywords.o ../lib/typename.o descriptor.o variable.o all: ecpg - - ifdef SNPRINTF - OBJS+=$(top_builddir)/src/backend/port/snprintf.o - - $(top_builddir)/src/backend/port/snprintf.o: - $(MAKE) -C $(top_builddir)/src/backend/port snprintf.o - endif - - ifdef STRDUP - OBJS+=$(top_builddir)/src/utils/strdup.o - - $(top_builddir)/src/utils/strdup.o: - $(MAKE) -C $(top_builddir)/src/utils strdup.o - endif ecpg: $(OBJS) $(CC) $(CFLAGS) $(LDFLAGS) $^ $(LIBS) -o $@ --- 18,27 ---- endif OBJS=preproc.o pgc.o type.o ecpg.o ecpg_keywords.o output.o\ ! keywords.o c_keywords.o ../lib/typename.o descriptor.o variable.o \ ! $(SNPRINTF) $(STRDUP) all: ecpg ecpg: $(OBJS) $(CC) $(CFLAGS) $(LDFLAGS) $^ $(LIBS) -o $@ Index: src/utils/Makefile =================================================================== RCS file: /cvsroot/pgsql/src/utils/Makefile,v retrieving revision 1.9 diff -c -r1.9 Makefile *** src/utils/Makefile 31 Aug 2000 16:12:35 -0000 1.9 --- src/utils/Makefile 15 Jul 2002 21:07:18 -0000 *************** *** 22,27 **** --- 22,29 ---- include $(top_builddir)/src/Makefile.global all: + # Nothing required here. These C files are compiled in + # directories as needed. clean distclean maintainer-clean: rm -f dllinit.o getopt.o strdup.o
Bruce Momjian writes: > I have applied the following diff to make the sharing of C files among > modules more sane. Instead of having configure.in set the file name to > strdup.o and have the Makefiles specify the path, I set it to the full > path $(top_builddir)/src/utils/strdup.o and have the makefiles use > that directly, rather than going through with 'make -c dirname > filename'. Don't do that, it doesn't work. Building outside the source tree, weird compilers, etc. The current state was the result of much labor to get rid of exactly the state you reintroduced. A secondary objection is that I've been meaning to replace configure checks of the form AC_CHECK_FUNCS(inet_aton, [], INET_ATON='inet_aton.o') AC_SUBST(INET_ATON) with one integrated macro, which doesn't work if we have to encode the path into configure. Also, do not tab-indent comments in makefiles. That makes them part of the command to execute. -- Peter Eisentraut peter_e@gmx.net
Peter Eisentraut wrote: > Bruce Momjian writes: > > > I have applied the following diff to make the sharing of C files among > > modules more sane. Instead of having configure.in set the file name to > > strdup.o and have the Makefiles specify the path, I set it to the full > > path $(top_builddir)/src/utils/strdup.o and have the makefiles use > > that directly, rather than going through with 'make -c dirname > > filename'. > > Don't do that, it doesn't work. Building outside the source tree, weird > compilers, etc. The current state was the result of much labor to get rid > of exactly the state you reintroduced. Well, the actual problem was that there was inconsistency in the way things where handled, e.g. some had their own rules for making the *.o files if the *.o files were out of the current directory, other didn't. I can change it but it has to be consistent. What do you suggest? > A secondary objection is that I've been meaning to replace configure > checks of the form > > AC_CHECK_FUNCS(inet_aton, [], INET_ATON='inet_aton.o') > AC_SUBST(INET_ATON) > > with one integrated macro, which doesn't work if we have to encode the > path into configure. The path is only the thing we assign to the variable. I can't see how that effects the configure script. Actually, once we move stuff into the same directory, it will not matter. They will all be in the same directory so you can just prepend whatever directory we need. > Also, do not tab-indent comments in makefiles. That makes them part of > the command to execute. Fixed. Thanks. -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 853-3000 + If your life is a hard drive, | 830 Blythe Avenue + Christ can be your backup. | Drexel Hill, Pennsylvania 19026
Bruce Momjian writes: > Well, the actual problem was that there was inconsistency in the way > things where handled, e.g. some had their own rules for making the *.o > files if the *.o files were out of the current directory, other didn't. > I can change it but it has to be consistent. What do you suggest? Can you point to one example of such an inconsistency? I can't find one. The rule of thumb is that rules involving the C compiler should only use files in the current directory. Otherwise you don't know where those files are going to end up. > > A secondary objection is that I've been meaning to replace configure > > checks of the form > > > > AC_CHECK_FUNCS(inet_aton, [], INET_ATON='inet_aton.o') > > AC_SUBST(INET_ATON) > > > > with one integrated macro, which doesn't work if we have to encode the > > path into configure. > > The path is only the thing we assign to the variable. I can't see how > that effects the configure script. What I want this to read in the end is PGAC_SOME_MACRO([func1 func2 func3]) > Actually, once we move stuff into the same directory, it will not > matter. True, that will help a lot. -- Peter Eisentraut peter_e@gmx.net
Peter Eisentraut wrote: > Bruce Momjian writes: > > > Well, the actual problem was that there was inconsistency in the way > > things where handled, e.g. some had their own rules for making the *.o > > files if the *.o files were out of the current directory, other didn't. > > I can change it but it has to be consistent. What do you suggest? > > Can you point to one example of such an inconsistency? I can't find one. Sure, interfaces/libpq had: OBJS= fe-auth.o fe-connect.o fe-exec.o fe-misc.o fe-print.o fe-lobj.o \ pqexpbuffer.o dllist.o md5.o pqsignal.o fe-secure.o \ $(INET_ATON) $(SNPRINTF) $(STRERROR) while psql/Makefile had what I think you wanted: OBJS=command.o common.o help.o input.o stringutils.o mainloop.o \ copy.o startup.o prompt.o variables.o large_obj.o print.o describe.o \ sprompt.o tab-complete.o mbprint.o all: submake psql ifdef STRDUP OBJS+=$(top_builddir)/src/utils/strdup.o $(top_builddir)/src/utils/strdup.o: $(MAKE) -C $(top_builddir)/src/utils strdup.o endif ifdef STRERROR OBJS+=$(top_builddir)/src/backend/port/strerror.o $(top_builddir)/src/backend/port/strerror.o: $(MAKE) -C $(top_builddir)/src/backend/port strerror.o endif ifdef SNPRINTF OBJS+=$(top_builddir)/src/backend/port/snprintf.o $(top_builddir)/src/backend/port/snprintf.o: $(MAKE) -C $(top_builddir)/src/backend/port snprintf.o endif Here we see SNPRINTF done in two different ways. I think the library file is the way to go anyway. We compile it once, and use it whenever we need it. Clean. > The rule of thumb is that rules involving the C compiler should only use > files in the current directory. Otherwise you don't know where those > files are going to end up. Sure. > > > A secondary objection is that I've been meaning to replace configure > > > checks of the form > > > > > > AC_CHECK_FUNCS(inet_aton, [], INET_ATON='inet_aton.o') > > > AC_SUBST(INET_ATON) > > > > > > with one integrated macro, which doesn't work if we have to encode the > > > path into configure. > > > > The path is only the thing we assign to the variable. I can't see how > > that effects the configure script. > > What I want this to read in the end is > > PGAC_SOME_MACRO([func1 func2 func3]) > > > Actually, once we move stuff into the same directory, it will not > > matter. > > True, that will help a lot. Heck, soon configure is only going to control what gets put in the libport.a file and that's it. -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 853-3000 + If your life is a hard drive, | 830 Blythe Avenue + Christ can be your backup. | Drexel Hill, Pennsylvania 19026
Bruce Momjian writes: > > Can you point to one example of such an inconsistency? I can't find one. > > Sure, interfaces/libpq had: > > OBJS= fe-auth.o fe-connect.o fe-exec.o fe-misc.o fe-print.o fe-lobj.o \ > pqexpbuffer.o dllist.o md5.o pqsignal.o fe-secure.o \ > $(INET_ATON) $(SNPRINTF) $(STRERROR) > > while psql/Makefile had what I think you wanted: Note that the libpq makefile goes through trouble to link the inet_aton.c file into the current directory, so this example doesn't count. -- Peter Eisentraut peter_e@gmx.net
Peter Eisentraut wrote: > Bruce Momjian writes: > > > > Can you point to one example of such an inconsistency? I can't find one. > > > > Sure, interfaces/libpq had: > > > > OBJS= fe-auth.o fe-connect.o fe-exec.o fe-misc.o fe-print.o fe-lobj.o \ > > pqexpbuffer.o dllist.o md5.o pqsignal.o fe-secure.o \ > > $(INET_ATON) $(SNPRINTF) $(STRERROR) > > > > while psql/Makefile had what I think you wanted: > > Note that the libpq makefile goes through trouble to link the inet_aton.c > file into the current directory, so this example doesn't count. Well, the code is: # this only gets done if configure finds system doesn't have inet_aton() inet_aton.c: $(backend_src)/port/inet_aton.c rm -f $@ && $(LN_S) $< . How is this any better than just mentioning the *.o file and letting the default rules compile it. I don't understand how linking to the current directory gets us anything. Now, if you did a 'make -C dir target' that would be different. In fact, with the lib idea dead, if there are special rules for for certain port/*.o files, we should put those rules in Makefile.global and let all the code use it. That way, we defined it in one place, but can use the object file anywhere. -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 853-3000 + If your life is a hard drive, | 830 Blythe Avenue + Christ can be your backup. | Drexel Hill, Pennsylvania 19026
Bruce Momjian <pgman@candle.pha.pa.us> writes: > How is this any better than just mentioning the *.o file and letting the > default rules compile it. I don't understand how linking to the current > directory gets us anything. Now, if you did a 'make -C dir target' that > would be different. The whole point of the pushups for libpq is that we DON'T want the default rules. We need to compile it PIC so that it can go into a shared library. This will not be the same object file built in the ports directory. regards, tom lane
Tom Lane wrote: > Bruce Momjian <pgman@candle.pha.pa.us> writes: > > How is this any better than just mentioning the *.o file and letting the > > default rules compile it. I don't understand how linking to the current > > directory gets us anything. Now, if you did a 'make -C dir target' that > > would be different. > > The whole point of the pushups for libpq is that we DON'T want the > default rules. We need to compile it PIC so that it can go into a > shared library. This will not be the same object file built in the > ports directory. Oh, so specifying the full path for the *.o allows it to use an existing *.o, while putting it in the directory forces a recompile with the current Makefile. Got it. Libpq has all of them done. I see the comment in libpq/Makefile now: # We use several backend modules verbatim, but since we need to # compile with appropriate options to build a shared lib, we can't # necessarily use the same object files as the backend uses. Instead, # symlink the source files in here and build our own object file. Thanks. -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 853-3000 + If your life is a hard drive, | 830 Blythe Avenue + Christ can be your backup. | Drexel Hill, Pennsylvania 19026
Tom Lane wrote: > Bruce Momjian <pgman@candle.pha.pa.us> writes: > > How is this any better than just mentioning the *.o file and letting the > > default rules compile it. I don't understand how linking to the current > > directory gets us anything. Now, if you did a 'make -C dir target' that > > would be different. > > The whole point of the pushups for libpq is that we DON'T want the > default rules. We need to compile it PIC so that it can go into a > shared library. This will not be the same object file built in the > ports directory. OK, this cleanup makes the src/backend/port file location dependent only on configure.in values. I will now move them from src/backend/port to src/port. -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 853-3000 + If your life is a hard drive, | 830 Blythe Avenue + Christ can be your backup. | Drexel Hill, Pennsylvania 19026 Index: contrib/pg_controldata/Makefile =================================================================== RCS file: /cvsroot/pgsql/contrib/pg_controldata/Makefile,v retrieving revision 1.5 diff -c -r1.5 Makefile *** contrib/pg_controldata/Makefile 6 Sep 2001 10:49:29 -0000 1.5 --- contrib/pg_controldata/Makefile 18 Jul 2002 03:58:46 -0000 *************** *** 5,18 **** include $(top_builddir)/src/Makefile.global PROGRAM = pg_controldata ! OBJS = pg_controldata.o pg_crc.o $(SNPRINTF) pg_crc.c: $(top_srcdir)/src/backend/utils/hash/pg_crc.c rm -f $@ && $(LN_S) $< . ! # this only gets done if configure finds system doesn't have snprintf() ! snprintf.c: $(top_srcdir)/src/backend/port/snprintf.c rm -f $@ && $(LN_S) $< . EXTRA_CLEAN = pg_crc.c snprintf.c --- 5,19 ---- include $(top_builddir)/src/Makefile.global PROGRAM = pg_controldata ! OBJS = pg_controldata.o pg_crc.o $(notdir $(SNPRINTF)) pg_crc.c: $(top_srcdir)/src/backend/utils/hash/pg_crc.c rm -f $@ && $(LN_S) $< . ! ifdef SNPRINTF ! $(basename $(notdir $(SNPRINTF))).c: $(basename $(SNPRINTF)).c rm -f $@ && $(LN_S) $< . + endif EXTRA_CLEAN = pg_crc.c snprintf.c Index: contrib/pg_resetxlog/Makefile =================================================================== RCS file: /cvsroot/pgsql/contrib/pg_resetxlog/Makefile,v retrieving revision 1.3 diff -c -r1.3 Makefile *** contrib/pg_resetxlog/Makefile 6 Sep 2001 10:49:30 -0000 1.3 --- contrib/pg_resetxlog/Makefile 18 Jul 2002 03:58:46 -0000 *************** *** 5,18 **** include $(top_builddir)/src/Makefile.global PROGRAM = pg_resetxlog ! OBJS = pg_resetxlog.o pg_crc.o $(SNPRINTF) pg_crc.c: $(top_srcdir)/src/backend/utils/hash/pg_crc.c rm -f $@ && $(LN_S) $< . ! # this only gets done if configure finds system doesn't have snprintf() ! snprintf.c: $(top_srcdir)/src/backend/port/snprintf.c rm -f $@ && $(LN_S) $< . EXTRA_CLEAN = pg_crc.c snprintf.c --- 5,19 ---- include $(top_builddir)/src/Makefile.global PROGRAM = pg_resetxlog ! OBJS = pg_resetxlog.o pg_crc.o $(notdir $(SNPRINTF)) pg_crc.c: $(top_srcdir)/src/backend/utils/hash/pg_crc.c rm -f $@ && $(LN_S) $< . ! ifdef SNPRINTF ! $(basename $(notdir $(SNPRINTF))).c: $(basename $(SNPRINTF)).c rm -f $@ && $(LN_S) $< . + endif EXTRA_CLEAN = pg_crc.c snprintf.c Index: src/interfaces/libpq/Makefile =================================================================== RCS file: /cvsroot/pgsql/src/interfaces/libpq/Makefile,v retrieving revision 1.62 diff -c -r1.62 Makefile *** src/interfaces/libpq/Makefile 14 Jun 2002 04:23:17 -0000 1.62 --- src/interfaces/libpq/Makefile 18 Jul 2002 03:58:48 -0000 *************** *** 12,17 **** --- 12,18 ---- top_builddir = ../../.. include $(top_builddir)/src/Makefile.global + # shared library parameters NAME= pq SO_MAJOR_VERSION= 2 *************** *** 21,32 **** OBJS= fe-auth.o fe-connect.o fe-exec.o fe-misc.o fe-print.o fe-lobj.o \ pqexpbuffer.o dllist.o md5.o pqsignal.o fe-secure.o \ ! $(INET_ATON) $(SNPRINTF) $(STRERROR) ifdef MULTIBYTE OBJS+= wchar.o encnames.o endif # Add libraries that libpq depends (or might depend) on into the # shared library link. (The order in which you list them here doesn't # matter.) --- 22,34 ---- OBJS= fe-auth.o fe-connect.o fe-exec.o fe-misc.o fe-print.o fe-lobj.o \ pqexpbuffer.o dllist.o md5.o pqsignal.o fe-secure.o \ ! $(notdir $(INET_ATON)) $(notdir $(SNPRINTF)) $(notdir $(STRERROR)) ifdef MULTIBYTE OBJS+= wchar.o encnames.o endif + # Add libraries that libpq depends (or might depend) on into the # shared library link. (The order in which you list them here doesn't # matter.) *************** *** 37,68 **** # Shared library stuff include $(top_srcdir)/src/Makefile.shlib - - - # We use several backend modules verbatim, but since we need to - # compile with appropriate options to build a shared lib, we can't - # necessarily use the same object files as the backend uses. Instead, - # symlink the source files in here and build our own object file. - backend_src = $(top_srcdir)/src/backend dllist.c: $(backend_src)/lib/dllist.c rm -f $@ && $(LN_S) $< . md5.c: $(backend_src)/libpq/md5.c rm -f $@ && $(LN_S) $< . # this only gets done if configure finds system doesn't have inet_aton() ! inet_aton.c: $(backend_src)/port/inet_aton.c rm -f $@ && $(LN_S) $< . ! # this only gets done if configure finds system doesn't have snprintf() ! snprintf.c: $(backend_src)/port/snprintf.c rm -f $@ && $(LN_S) $< . ! # this only gets done if configure finds system doesn't have strerror() ! strerror.c: $(backend_src)/port/strerror.c rm -f $@ && $(LN_S) $< . ifdef MULTIBYTE wchar.c : % : $(backend_src)/utils/mb/% --- 39,73 ---- # Shared library stuff include $(top_srcdir)/src/Makefile.shlib backend_src = $(top_srcdir)/src/backend + dllist.c: $(backend_src)/lib/dllist.c rm -f $@ && $(LN_S) $< . md5.c: $(backend_src)/libpq/md5.c rm -f $@ && $(LN_S) $< . + # We use several backend modules verbatim, but since we need to + # compile with appropriate options to build a shared lib, we can't + # necessarily use the same object files as the backend uses. Instead, + # symlink the source files in here and build our own object file. # this only gets done if configure finds system doesn't have inet_aton() ! ! ifdef INET_ATON ! $(basename $(notdir $(INET_ATON))).c: $(basename $(INET_ATON)).c rm -f $@ && $(LN_S) $< . + endif ! ifdef SNPRINTF ! $(basename $(notdir $(SNPRINTF))).c: $(basename $(SNPRINTF)).c rm -f $@ && $(LN_S) $< . + endif ! ifdef STRERROR ! $(basename $(notdir $(STRERROR))).c: $(basename $(STRERROR)).c rm -f $@ && $(LN_S) $< . + endif ifdef MULTIBYTE wchar.c : % : $(backend_src)/utils/mb/%
Tom Lane wrote: > Bruce Momjian <pgman@candle.pha.pa.us> writes: > > How is this any better than just mentioning the *.o file and letting the > > default rules compile it. I don't understand how linking to the current > > directory gets us anything. Now, if you did a 'make -C dir target' that > > would be different. > > The whole point of the pushups for libpq is that we DON'T want the > default rules. We need to compile it PIC so that it can go into a > shared library. This will not be the same object file built in the > ports directory. OK, I have moved the files to src/port. Would people like this rule added to Makefile.global.in so that any usage of src/port/*.c files will compile in the local directory? ifdef SNPRINTF $(basename $(notdir $(SNPRINTF))).c: $(basename $(SNPRINTF)).c rm -f $@ && $(LN_S) $< . endif -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 853-3000 + If your life is a hard drive, | 830 Blythe Avenue + Christ can be your backup. | Drexel Hill, Pennsylvania 19026
Bruce Momjian <pgman@candle.pha.pa.us> writes: > OK, I have moved the files to src/port. Would people like this rule > added to Makefile.global.in so that any usage of src/port/*.c files will > compile in the local directory? I'd guess *not*. libpq is a special case. regards, tom lane
Tom Lane wrote: > Bruce Momjian <pgman@candle.pha.pa.us> writes: > > OK, I have moved the files to src/port. Would people like this rule > > added to Makefile.global.in so that any usage of src/port/*.c files will > > compile in the local directory? > > I'd guess *not*. libpq is a special case. But the case is specifically for libpq, so that it appears as a local file for compile by the local makefile rules. Adding this would make all uses of those files behave the same way. -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 853-3000 + If your life is a hard drive, | 830 Blythe Avenue + Christ can be your backup. | Drexel Hill, Pennsylvania 19026
Tom Lane wrote: > Bruce Momjian <pgman@candle.pha.pa.us> writes: > > OK, I have moved the files to src/port. Would people like this rule > > added to Makefile.global.in so that any usage of src/port/*.c files will > > compile in the local directory? > > I'd guess *not*. libpq is a special case. Oh, so you are saying let most uses of src/port use the *.o files that are in the directory, and it isn't needed to have other directories use the link trick. Just let me know what people want. -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 853-3000 + If your life is a hard drive, | 830 Blythe Avenue + Christ can be your backup. | Drexel Hill, Pennsylvania 19026