Blob Blame History Raw
# build info
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)\"

# python's front-end utility
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
else
	COMMON_SRCS	+= $(DYNLOAD_SRCS)
	CFLAGS_CONFIG	+= -DHAVE_DYNAMIC_LOADING -DSOABI=\"$(PYTHON_SOABI)\"
endif

# extension objects
pyext/obj/%.lo:	$(SOURCE_DIR)/Modules/%.c $(ALL_HEADERS) host.tag tree.tag config.tag
		$(CC) -c -o $@ $< $(CFLAGS_SHARED)

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

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

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

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

# 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)