[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: OT -- gentle makefile assistance?



On Fri, Jan 24, 2003 at 02:41:56AM -0600, will trillich wrote:
> okay, i used to know how these makefiles worked, but that was a
> few lifetimes ago... :(
>
> i'm doing many iterations on the edit-run-edit cycle in creating
> a postgresql 7.2.1 (woody) and thought that make would be able
> to help keep my inter-dependencies in line.
> 
> of course, there's no "object" file as there is when compiling
> C. does there HAVE TO BE some output stored somewhere? maybe i
> can have the results of "psql $(DB) -f <source.sql>" redirected
> to an outfile for timestamp tracking purposes?

I have done similar things - although that was for an Oracle database,
the same principles apply.

My solution was to use a dummy .$(SCRIPT)-run.stamp file - and use the
timestamp on this file to remember when $(SCRIPT).sql was last run:

#/usr/bin/make -f
SQLFILES = fns.sql person.sql dates.sql
STAMPFILES = $(SQLFILES:%.sql=.%-run.stamp)

.PHONY : default
default : $(STAMPFILES)

# If an *.sql file changes, run it
.%-run.stamp : %.sql
        $(PG) $(@:.%-run.stamp=%.sql)
        touch $@

# if fns.sql changes, re-run person.sql
.person-run.stamp : fns.sql

# if person.sql changes, re-run dates.sql
.dates-run.stamp : person.sql

# End of makefile

This will make sure that if an *.sql file changes, it gets run.
Additionally, person.sql will get re-run if fns.sql changes, and if
person.sql changes, dates.sql will be re-run too.


HTH
-- 
Karl E. Jørgensen
karl@jorgensen.com   http://karl.jorgensen.com   JabberID: linux_geek@jabber.org
==== Today's fortune:
You mean you didn't *know* she was off making lots of little phone companies?

Attachment: pgpTCKosxBmcV.pgp
Description: PGP signature


Reply to: