More pre-2.3 build tweaks for the OS/2 EMX port:

- separate the building of the core from the wrapper executables and the
  external modules (.PYDs), based on the Py_BUILD_CORE define;

- clean up the generated import library definiton (.DEF file) to remove
  references to a number of non-static symbols that aren't part of the
  Python API and which shouldn't be exported by the core DLL;

- compile the release build with -fomit-frame-pointer, for a small
  performance gain;

- make "make clean" remove byte compiled Python library files.
This commit is contained in:
Andrew MacIntyre 2003-07-13 13:41:59 +00:00
parent f9ce67d65f
commit 4ee893fe39
3 changed files with 493 additions and 283 deletions

View File

@ -83,6 +83,7 @@ ARFLAGS= crs
IMPLIB= emximp IMPLIB= emximp
EXPLIB= emxexp EXPLIB= emxexp
EXEOPT= emxbind EXEOPT= emxbind
PY_DEF= -DPy_BUILD_CORE
# adjust C compiler settings based on build options # adjust C compiler settings based on build options
@ -90,9 +91,10 @@ ifeq ($(MODE),debug)
CFLAGS+= -g -O CFLAGS+= -g -O
LDFLAGS+= -g LDFLAGS+= -g
else else
CFLAGS+= -s -O2 CFLAGS+= -s -O2 -fomit-frame-pointer
LDFLAGS+= -s LDFLAGS+= -s
endif endif
CFLAGS+= $(PY_DEF)
ifeq ($(ASSERTIONS),no) ifeq ($(ASSERTIONS),no)
CFLAGS+= -DNDEBUG CFLAGS+= -DNDEBUG
endif endif
@ -474,12 +476,16 @@ EXTERNDLLS+= $(addsuffix $(MODULE.EXT),$(patsubst %module,%,$(HARDEXTMODULES)))
# Targets # Targets
all: $(OUT) $(PYTHON.LIB) $(PYTHON.DEF) $(PYTHON.IMPLIB) $(PYTHON.DLL) \ all: $(OUT) $(PYTHON.LIB) $(PYTHON.DEF) $(PYTHON.IMPLIB) $(PYTHON.DLL) \
$(PYTHON.EXE) $(PYTHONPM.EXE) $(PGEN.EXE) $(EXTERNDLLS) python_noncore
python_noncore:
make PY_DEF= $(PYTHON.EXE) $(PYTHONPM.EXE) $(PGEN.EXE) $(EXTERNDLLS)
clean: clean:
rm -f $(OUT)* rm -f $(OUT)*
rm -f $(PYTHON.LIB) $(PYTHON.IMPLIB) $(PYTHON.EXEIMP) $(PYTHON.DLL) \ rm -f $(PYTHON.LIB) $(PYTHON.IMPLIB) $(PYTHON.EXEIMP) $(PYTHON.DLL) \
$(PYTHON.EXE) $(PYTHONPM.EXE) $(PGEN.EXE) *$(MODULE.EXT) $(PYTHON.EXE) $(PYTHONPM.EXE) $(PGEN.EXE) *$(MODULE.EXT)
find ../../Lib -name "*.py[co]" -exec rm {} ";"
lx: lx:
@echo Packing everything with lxLite... @echo Packing everything with lxLite...
@ -498,6 +504,9 @@ $(PYTHON.LIB): $(OBJ.LIB)
rm.exe -f $@ rm.exe -f $@
$(AR) $(ARFLAGS) $@ $^ $(AR) $(ARFLAGS) $@ $^
# the Python core DLL .def file needs to have a number of non-static
# symbols that aren't part of the Python C API removed (commented out)
# from the DLL export list.
$(PYTHON.DEF): $(PYTHON.LIB) $(PYTHON.DEF): $(PYTHON.LIB)
@echo Creating .DEF file: $@ @echo Creating .DEF file: $@
@echo LIBRARY $(PYTHON_LIB) INITINSTANCE TERMINSTANCE >$@ @echo LIBRARY $(PYTHON_LIB) INITINSTANCE TERMINSTANCE >$@
@ -505,7 +514,29 @@ $(PYTHON.DEF): $(PYTHON.LIB)
@echo PROTMODE >>$@ @echo PROTMODE >>$@
@echo DATA MULTIPLE NONSHARED >>$@ @echo DATA MULTIPLE NONSHARED >>$@
@echo EXPORTS >>$@ @echo EXPORTS >>$@
$(EXPLIB) -u $(PYTHON.LIB) >>$@ $(EXPLIB) -u $(PYTHON.LIB) |\
sed -e "/ .init.*/s/^ /; /" \
-e "/ .pcre_.*/s/^ /; /" \
-e "/ .array_methods/s/^ /; /" \
-e "/ .fast_save_leave/s/^ /; /" \
-e "/ .dlopen/s/^ /; /" \
-e "/ .dlsym/s/^ /; /" \
-e "/ .dlclose/s/^ /; /" \
-e "/ .dlerror/s/^ /; /" \
-e "/ .cycle_type/s/^ /; /" \
-e "/ .dropwhile_type/s/^ /; /" \
-e "/ .takewhile_type/s/^ /; /" \
-e "/ .islice_type/s/^ /; /" \
-e "/ .starmap_type/s/^ /; /" \
-e "/ .imap_type/s/^ /; /" \
-e "/ .chain_type/s/^ /; /" \
-e "/ .ifilter_type/s/^ /; /" \
-e "/ .ifilterfalse_type/s/^ /; /" \
-e "/ .count_type/s/^ /; /" \
-e "/ .izip_type/s/^ /; /" \
-e "/ .repeat_type/s/^ /; /" \
-e "/ ._Py_re_.*/s/^ /; /" \
-e "/ ._Py_MD5.*/s/^ /; /" >>$@
$(PYTHON.IMPLIB): $(PYTHON.DEF) $(PYTHON.IMPLIB): $(PYTHON.DEF)
$(IMPLIB) -o $@ $^ $(IMPLIB) -o $@ $^
@ -627,7 +658,7 @@ readline$(MODULE.EXT): $(OUT)readline$O $(OUT)readline_m.def $(PYTHON.IMPLIB)
#_tkinter$(MODULE.EXT): $(OUT)_tkinter$O $(OUT)tclNotify$O $(OUT)tkappinit$O #_tkinter$(MODULE.EXT): $(OUT)_tkinter$O $(OUT)tclNotify$O $(OUT)tkappinit$O
_tkinter$(MODULE.EXT): $(OUT)_tkinter$O $(OUT)tclNotify$O \ _tkinter$(MODULE.EXT): $(OUT)_tkinter$O $(OUT)tclNotify$O \
$(OUT)_tkinter_m.def $(PYTHON.IMPLIB) $(OUT)_tkinter_m.def $(PYTHON.IMPLIB)
$(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS) $(TK_LIBS) $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS) $(TK_LIBS)
zlib$(MODULE.EXT): $(OUT)zlibmodule$O $(OUT)zlib_m.def $(PYTHON.IMPLIB) zlib$(MODULE.EXT): $(OUT)zlibmodule$O $(OUT)zlib_m.def $(PYTHON.IMPLIB)

View File

@ -26,6 +26,18 @@
/*#define Py_DEBUG 1*/ /*#define Py_DEBUG 1*/
#endif #endif
/* if building an extension or wrapper executable,
* mark Python API symbols "extern" so that symbols
* imported from the Python core DLL aren't duplicated.
*/
#ifdef Py_BUILD_CORE
# define PyAPI_FUNC(RTYPE) RTYPE
#else
# define PyAPI_FUNC(RTYPE) extern RTYPE
#endif
#define PyAPI_DATA(RTYPE) extern RTYPE
#define PyMODINIT_FUNC void
/* Use OS/2 flavour of threads */ /* Use OS/2 flavour of threads */
#define WITH_THREAD 1 #define WITH_THREAD 1
#define OS2_THREADS 1 #define OS2_THREADS 1

File diff suppressed because it is too large Load Diff