# META-NOTE: this note is different from the note in the other Makefiles!
# NOTE: Makefile.pre.in is converted into Makefile.pre by the configure
# script in the toplevel directory or by ../config.status.
# Makefile.pre is converted into Makefile by running the makesetup
# script in the source directory.  Once Makefile exists, it can be
# brought up to date by running "make Makefile".  (The makesetup also
# creates config.c from config.c.in in the source directory.)

# === Variables set by makesetup ===

#MODOBJS=	_MODOBJS_
#MODLIBS=	_MODLIBS_

# === Variables set by configure ===

srcdir=
VPATH=

CC=		mwcc
RANLIB=
AR=		mwld -xml -o

DEFS=	-DHAVE_CONFIG_H

OPT=	 -nosyspath -O7 -DBEBOX -DPPC603=1 -I.

LIBS=
LIBM=
LIBC=

# Machine-dependent subdirectories
MACHDEP=

# Install prefix for architecture-independent files
prefix=

# Install prefix for architecture-dependent files
exec_prefix=

# Symbols used for using shared libraries
SO=
LDSHARED=
CCSHARED=
LINKFORSHARED=
DESTSHARED=	$(exec_prefix)/lib/python/$(MACHDEP)

# === Variables that are customizable by hand or by inclusion in Setup ===

LINKCC=		$(CC)
INCLDIR=	$(srcdir)../Include
CFLAGS=		$(OPT) -I$(INCLDIR) -I.. $(DEFS)

MKDEP=		mkdep
SHELL=		/bin/sh

MAKESETUP=	$(srcdir)/makesetup

# (The makesetup script inserts all variable definitions found
# found in the Setup file just below the following line.
# This means that the Setup file can override any of the definitions
# given before this point, but not any given below.
# The script insert the definitions in reverse order,
# for the benefits of independent extensions.)
# === Definitions added by makesetup ===

MODOBJS= posixmodule.o arraymodule.o mathmodule.o regexpr.o \
	regexmodule.o stropmodule.o structmodule.o timemodule.o fcntlmodule.o \
	audioop.o imageop.o rgbimgmodule.o md5module.o md5c.o \
	rotormodule.o parsermodule.o binascii.o environment.o \
	threadmodule.o timingmodule.o selectmodule.o socketmodule.o signalmodule.o
MODLIBS=

DESTLIB=$(prefix)/lib/python

# Standard path -- don't edit
DESTPATH=:$(DESTLIB)

# Standard enabled (tests are always available)
TESTPATH=:$(DESTLIB)/test

# Path for machine- or system-dependent modules (and shared libraries)
#MACHDEPPATH=:$(DESTLIB)/$(MACHDEP)

COREPYTHONPATH=.$(SITEPATH)$(DESTPATH)$(TESTPATH)$(MACHDEPPATH)$(STDWINPATH)$(TKPATH)
PYTHONPATH=$(COREPYTHONPATH)

# === Fixed definitions ===

OBJS=		$(MODOBJS)

ADDOBJS=	main.o config.o getpath.o

LIB=		libModules.a

MYLIBS=		$(LIB) \
		../Python/libPython.a \
		../Objects/libObjects.a \
		../Parser/libParser.a

CORELIBS= \
		../Python/libPython.a \
		../Objects/libObjects.a \
		../Parser/libParser.a

SYSLIBS=	$(LIBM) $(LIBC)


# === Rules ===

all:		$(LIB) ../pythonstatic sharedmods ../python \
	../libPyCore.so

#stuff for a semi dynamic python ! ie there's one big shared lib.

../libPyCore.so: config.o getpath.o $(MYLIBS)
	mwld -o ../libPyCore.so -map ../libPyCore.so.xMAP \
	-G -nodefaults -f libPyCore.exp /boot/develop/libraries/libdll.a \
	/boot/system/lib/libbe.so \
	config.o getpath.o $(MYLIBS)

../python: ../libPyCore.so main.o # Makefile
	$(LINKCC) $(OPT) main.o -map ../python.xMAP \
	../libPyCore.so $(LIBS) -o ../python

$(LIB):		$& $(OBJS) # Makefile
		-rm -f $(LIB)
		$(AR) $(LIB) $(OBJS)

../pythonstatic: $(MYLIBS) $(ADDOBJS) # Makefile
		$(LINKCC) $(OPT)  $(ADDOBJS) \
		      $(MYLIBS) $(LIBS) -o ../pythonstatic

clean:
		-rm -f *.o python core *~ [@,#]* *.old *.orig *.rej

clobber:	clean
		-rm -f *.a tags TAGS config.c glmodule.c Makefile.pre
		-rm -f *.so so_locations

getpath.o:	getpath.c # Makefile
		$(CC) -c $(CFLAGS) -DPYTHONPATH='"$(PYTHONPATH)"' \
		      $(srcdir)getpath.c

#config.c Makefile: Makefile.pre config.c.in $(MAKESETUP) Setup
#		$(SHELL) $(MAKESETUP) Setup
#
#Setup:
#		cp $(srcdir)/Setup.in Setup
#
#Makefile.pre:	Makefile.pre.in ../config.status
#		(cd ..; CONFIG_FILES=Modules/Makefile.pre CONFIG_HEADERS= \
#		$(SHELL) config.status)
#
#depend:
#		$(MKDEP) $(CFLAGS) `echo $(OBJS) | tr ' ' '\012' | \
#					sed 's|\(.*\)\.o|$(srcdir)/\1.c|'`

.PRECIOUS:	../python

#glmodule.c:	$(srcdir)/cgen.py $(srcdir)/cstubs
#		python $(srcdir)/cgen.py <$(srcdir)/cstubs >glmodule.c

libPyMods_stub.o: libPyMods_stub.c

almodule.o: almodule.c
arraymodule.o: arraymodule.c
audioop.o: audioop.c
cdmodule.o: cdmodule.c
clmodule.o: clmodule.c
dbmmodule.o: dbmmodule.c
fcntlmodule.o: fcntlmodule.c
flmodule.o: flmodule.c
fmmodule.o: fmmodule.c
glmodule.o: glmodule.c
imageop.o: imageop.c
imgfile.o: imgfile.c
main.o: main.c
mathmodule.o: mathmodule.c
md5c.o: md5c.c
md5module.o: md5module.c
mpzmodule.o: mpzmodule.c
nismodule.o: nismodule.c
parsermodule.o: parsermodule.c
posixmodule.o: posixmodule.c
pwdmodule.o: pwdmodule.c
regexmodule.o: regexmodule.c
regexpr.o: regexpr.c
rgbimgmodule.o: rgbimgmodule.c
rotormodule.o: rotormodule.c
selectmodule.o: selectmodule.c
sgimodule.o: sgimodule.c
socketmodule.o: socketmodule.c
stdwinmodule.o: stdwinmodule.c
stropmodule.o: stropmodule.c
structmodule.o: structmodule.c
sunaudiodev.o: sunaudiodev.c
svmodule.o: svmodule.c
threadmodule.o: threadmodule.c
timemodule.o: timemodule.c
timingmodule.o: timingmodule.c timing.h
xxmodule.o: xxmodule.c
yuvconvert.o: yuvconvert.c

# Rules to build and install all shared modules
sharedmods:	$(SHAREDMODS)
#sharedinstall:	$(DESTSHARED) $(SHAREDMODS)
#		-for i in dummy $(SHAREDMODS); do \
#		    if test -f $$i; then mv $$i $(DESTSHARED)/$$i; fi; done
#
#$(DESTSHARED):
#		mkdir $(DESTSHARED)

# Stuff is appended here by makesetup and make depend
