[Bio] / ReleaseTools / standard.mk Repository:
ViewVC logotype

View of /ReleaseTools/standard.mk

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (download) (annotate)
Fri Sep 17 21:04:49 2004 UTC (15 years, 5 months ago) by efrank
Branch: MAIN
Changes since 1.2: +7 -5 lines
mods to support libdir/PackagenameGen directory.

Problem:  If you have package, PkgA, and PkgA has IDL-like stuff in
it that is used to generate code, then python causes problems.  In
our case, we had Foo.st, the input to the schema tools.  Foo.st
was eaten by generatePy to make Foo.py in libdir/PkgA.  Even
though we havfe libdir at the head of PYTHONPATH, python adds
PWD before PYTHONPATH, so if the first import in the execution
snags, say, PkgA.MyClass, then when you later look for PkgA.Foo,
the thing emitted into the libdir, python would not find it because
PkgA was found via PWD.  (This is the caes when trying to run from
the working direction).

So, for each package, we now create  libdir/Pkg and libdir/PkgGen
where the  latter is used to emit generated python.  If a programmer
needs to use a generated .py in an import, they specify
	from PkgGen.TheClass import TheClass

This solves the problem.

Pain in the butt.

#######################################################################
# standard.mk
#
# Centralized make rules, macros, etc., shared amongst the packages.
# Package level makefiles do  not define rules, targets, etc.  Instead,
# they define a few macros needed to generate the build lists and
# standard.mk does the rest.
#
# The general pattern is to have "all of a kind" selected by wildcard
# into a build product, e.g., all .c or .cc go into a library or
# all .py get .pyc'd into the install area.  But, there are a few
# macro's that define things to exclude, e.g., .c files that have main()
# and are executables or foo.py files that are top-level programs and
# are to be installed in bin as foo.
#
# A package level makefile does "include standard.mk".  This works because
# of -I's in the Makefile.top in the workdir.  See Makefile.PackageSample.
#
#######################################################################

########################################################################
# Document macros users define in their package level makefiles here:
########################################################################
#
#BINPYSCRIPTS := script1.py etc.  List of py scripts to install in bin.
#                Installed as script1, not script1.py.  Filtered out of
#                python library list (LIBPYFILES)
#
#BINSCRIPTS:     List of scripts to be copied to bin verbatim.
#
#
#SCHEMATOOLS := file.st, etc.  List of python files defining input to schema
#	        tools.



########################################################################
# Various lists of things to build
#   implemented via macros above.
########################################################################


LIBPYFILES := $(filter-out $(BINPYSCRIPTS), $(wildcard *.py))



########################################################################
# Package-level makefile Targets
########################################################################

# this follows the all: in Makefile.top, but we drop decouple:, makefile:,
# and installdirs:, because those don't make sense at package level

all: schematools lib bin

bin:	$(foreach var, $(BINPYSCRIPTS), $(subst .py,,$(bindir)/$(var))) $(foreach var, $(BINSCRIPTS), $(bindir)/$(var)) 

lib:	$(foreach var, $(LIBPYFILES), $(libdir)/$(PKGNAME)/$(var))

schematools: $(foreach var, $(subst .st,,$(SCHEMATOOLS)), $(libdir)/$(PKGNAME)Gen/$(var).py) $(foreach var, $(subst .st,,$(SCHEMATOOLS)), $(libdir)/$(PKGNAME)Gen/$(var).sql) $(foreach var, $(subst .st,,$(SCHEMATOOLS)), $(libdir)/$(PKGNAME)Gen/$(var)DbiHandler.py)
 
test:

clean:

########################################################################
# Rules
########################################################################

##
# lib related
##
# verbatim copy from sourcedir to libdir, e.g., py (distutils someday...)
$(libdir)/$(PKGNAME)/%: $(TOPDIR)/$(PKGNAME)/%
	cp -p  $< $@

# generate .py from schematools description of class. (Kah related)
$(libdir)/$(PKGNAME)Gen/%.py: $(TOPDIR)/$(PKGNAME)/%.st
	cd $(libdir)/$(PKGNAME); generatePy $< > $@

# generate .sql from schematools description of class. (Kah related)
$(libdir)/$(PKGNAME)Gen/%.sql: $(TOPDIR)/$(PKGNAME)/%.st
	cd $(libdir)/$(PKGNAME); generateDb $< > $@

# generate object/relational converters from schematools
# description of class. (Kah related)
$(libdir)/$(PKGNAME)Gen/%DbiHandler.py: $(TOPDIR)/$(PKGNAME)/%.st
	cd $(libdir)/$(PKGNAME); generateDbiHandler $< > $@

## 
# bin related
##
# python scripts. make script, "foo" from "foo.py".  (rewrite path #! someday)
$(bindir)/%: $(TOPDIR)/$(PKGNAME)/%.py
	cp -p  $< $@

# scripts to copy verbatim.
$(bindir)/%: $(TOPDIR)/$(PKGNAME)/%
	cp -p  $< $@


########################################################################
# Dependency generation
########################################################################
#
# not written yet.  (of all the things not to have...)
#

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3