Blob Blame History Raw
# build info
PYTHON_VER     = 2.7
PYTHON_MAJOR   = 2

CFLAGS_COMMON += -I$(PROJECT_DIR)/profiles
CFLAGS_COMMON += -I$(SOURCE_DIR)/Include

CFLAGS_CONFIG += -DPLATFORM=\"$(PYTHON_PLATFORM)\"
CFLAGS_CONFIG += -DVERSION=\"$(PYTHON_VER)\"
CFLAGS_CONFIG += -DPREFIX=\"$(PREFIX)\"
CFLAGS_CONFIG += -DEXEC_PREFIX=\"$(EXEC_PREFIX)\"
CFLAGS_CONFIG += -DVPATH=\"$(SOURCE_DIR)\"
CFLAGS_CONFIG += -DPYTHONPATH=\"$(PYTHON_PATH)\"

LDFLAGS_DEPS    += -Wl,--as-needed
LDFLAGS_DEPS    += -lm -lpthread -lutil -ldl -lcrypt
LDFLAGS_DEPS    += -Wl,--no-as-needed

LDFLAGS_CONFIG  += $(LDFLAGS_DEPS)
LDFLAGS_CONFIG  += -Wl,-rpath -Wl,$(LIBDIR)

ifeq ($(ALL_STATIC),yes)
	CFLAGS_STATIC	+= -DPY_ALL_STATIC

	LDFLAGS_STATIC	+= $(PYEXT_STATIC)

	LDFLAGS_STATIC	+= $(LDFLAGS_PYEXT_STATIC)

	LDFLAGS_STATIC	+= $(LDFLAGS_NCURSES_STATIC)
	LDFLAGS_STATIC	+= $(LDFLAGS_SQLITE_STATIC)
	LDFLAGS_STATIC	+= $(LDFLAGS_EXPAT_STATIC)
	LDFLAGS_STATIC	+= $(LDFLAGS_DBM_STATIC)

	LDFLAGS_STATIC	+= $(LDFLAGS_PYEXT_STATIC)
else
	COMMON_SRCS	+= $(DYNLOAD_SRCS)
	CFLAGS_CONFIG	+= -DHAVE_DYNAMIC_LOADING
endif

# dynamically loaded extension module
pyext/%$(OS_LIB_SUFFIX): LDFLAGS_SONAME =
pyext/%$(OS_LIB_SUFFIX): LDFLAGS_DSOEXT = -Wl,-soname -Wl,$(subst pyext/,,$@)
pyext/%$(OS_LIB_SUFFIX): LDFLAGS_DYNEXT = $(LDFLAGS_DSOEXT) $(LDFLAGS_PYEXT)

pyext/%$(OS_LIB_SUFFIX): $(DSO_REF_SOLINK)
	$(CC) -shared -o $@ $^ $(LDFLAGS_SHARED) $(LDFLAGS_DYNEXT) \
		-l$(PACKAGE) $(LDFLAGS_DEPS)


# statically linked extension
pyext/%$(OS_ARCHIVE_EXT):
	rm -f $@
	$(AR) rcs $@ $^


# compile rules for python's extension modules
Modules/cjkcodecs/%.lo:		$(SOURCE_DIR)/Modules/cjkcodecs/%.c $(ALL_HEADERS) host.tag tree.tag config.tag
				$(CC) -c -o $@ $< $(CFLAGS_SHARED)

Modules/cjkcodecs/%.o:		$(SOURCE_DIR)/Modules/cjkcodecs/%.c $(ALL_HEADERS) host.tag tree.tag config.tag
				$(CC) -c -o $@ $< $(CFLAGS_STATIC)

Modules/expat/%.lo:		$(SOURCE_DIR)/Modules/expat/%.c $(ALL_HEADERS) host.tag tree.tag config.tag
				$(CC) -c -o $@ $< $(CFLAGS_SHARED)

Modules/expat/%.o:		$(SOURCE_DIR)/Modules/expat/%.c $(ALL_HEADERS) host.tag tree.tag config.tag
				$(CC) -c -o $@ $< $(CFLAGS_STATIC)

Modules/zlib/%.lo:		$(SOURCE_DIR)/Modules/zlib/%.c $(ALL_HEADERS) host.tag tree.tag config.tag
				$(CC) -c -o $@ $< $(CFLAGS_SHARED)

Modules/zlib/%.o:		$(SOURCE_DIR)/Modules/zlib/%.c $(ALL_HEADERS) host.tag tree.tag config.tag
				$(CC) -c -o $@ $< $(CFLAGS_STATIC)

Modules/_ctypes/%.lo:		$(SOURCE_DIR)/Modules/_ctypes/%.c $(ALL_HEADERS) host.tag tree.tag config.tag
				$(CC) -c -o $@ $< $(CFLAGS_SHARED)

Modules/_ctypes/%.o:		$(SOURCE_DIR)/Modules/_ctypes/%.c $(ALL_HEADERS) host.tag tree.tag config.tag
				$(CC) -c -o $@ $< $(CFLAGS_STATIC)

Modules/_io/%.lo:		$(SOURCE_DIR)/Modules/_io/%.c $(ALL_HEADERS) host.tag tree.tag config.tag
				$(CC) -c -o $@ $< $(CFLAGS_SHARED)

Modules/_io/%.o:		$(SOURCE_DIR)/Modules/_io/%.c $(ALL_HEADERS) host.tag tree.tag config.tag
				$(CC) -c -o $@ $< $(CFLAGS_STATIC)

Modules/_multiprocessing/%.lo:	$(SOURCE_DIR)/Modules/_multiprocessing/%.c $(ALL_HEADERS) host.tag tree.tag config.tag
				$(CC) -c -o $@ $< $(CFLAGS_SHARED)

Modules/_multiprocessing/%.o:	$(SOURCE_DIR)/Modules/_multiprocessing/%.c $(ALL_HEADERS) host.tag tree.tag config.tag
				$(CC) -c -o $@ $< $(CFLAGS_STATIC)

Modules/_sqlite/%.lo:		$(SOURCE_DIR)/Modules/_sqlite/%.c $(ALL_HEADERS) host.tag tree.tag config.tag
				$(CC) -c -o $@ $< $(CFLAGS_SHARED)

Modules/_sqlite/%.o:		$(SOURCE_DIR)/Modules/_sqlite/%.c $(ALL_HEADERS) host.tag tree.tag config.tag
				$(CC) -c -o $@ $< $(CFLAGS_STATIC)

# build rules for python's extension modules
include $(PROJECT_DIR)/project/pyexts.mk


# shared extension modules: desired subset
$(SHARED_APP): $(PYEXT_SHARED)
$(STATIC_APP): $(PYEXT_STATIC)


# pycompile (core native python executable for .pyc generation)
include $(PROJECT_DIR)/project/pycompile.mk

# pydist (python's distributed .py scripts)
include $(PROJECT_DIR)/project/pydist.mk

# pycgen (python's distributed .pyc objects)
include $(PROJECT_DIR)/project/pycgen.mk

# pytools (python's {prefix}/bin script-based tools)
include $(PROJECT_DIR)/project/pytools.mk

# pyinst  (python's custom install bits)
include $(PROJECT_DIR)/project/pyinst.mk