1# Description: Remove duplicate CFLAGS, CPPFLAGS, LDFLAGS by stripping CONFIGURE_*
2# Submitted by: koobs (r326729)
3# TODO: Upstream
4--- Makefile.pre.in.orig	2021-12-21 21:06:26 UTC
5+++ Makefile.pre.in
6@@ -81,7 +81,6 @@ MAKESETUP=      $(srcdir)/Modules/makesetup
7 OPT=		@OPT@
8 BASECFLAGS=	@BASECFLAGS@
9 BASECPPFLAGS=	@BASECPPFLAGS@
10-CONFIGURE_CFLAGS=	@CFLAGS@
11 # CFLAGS_NODIST is used for building the interpreter and stdlib C extensions.
12 # Use it when a compiler flag should _not_ be part of the distutils CFLAGS
13 # once Python is installed (Issue #21121).
14@@ -93,18 +92,16 @@ CONFIGURE_LDFLAGS_NODIST=@LDFLAGS_NODIST@
15 # LDFLAGS_NOLTO is an extra flag to disable lto. It is used to speed up building
16 # of _bootstrap_python and _freeze_module tools, which don't need LTO.
17 CONFIGURE_LDFLAGS_NOLTO=@LDFLAGS_NOLTO@
18-CONFIGURE_CPPFLAGS=	@CPPFLAGS@
19-CONFIGURE_LDFLAGS=	@LDFLAGS@
20 # Avoid assigning CFLAGS, LDFLAGS, etc. so users can use them on the
21 # command line to append to these values without stomping the pre-set
22 # values.
23-PY_CFLAGS=	$(BASECFLAGS) $(OPT) $(CONFIGURE_CFLAGS) $(CFLAGS) $(EXTRA_CFLAGS)
24+PY_CFLAGS=	$(BASECFLAGS) $(OPT) $(CFLAGS) $(EXTRA_CFLAGS)
25 PY_CFLAGS_NODIST=$(CONFIGURE_CFLAGS_NODIST) $(CFLAGS_NODIST) -I$(srcdir)/Include/internal
26 # Both CPPFLAGS and LDFLAGS need to contain the shell's value for setup.py to
27 # be able to build extension modules using the directories specified in the
28 # environment variables
29-PY_CPPFLAGS=	$(BASECPPFLAGS) -I. -I$(srcdir)/Include $(CONFIGURE_CPPFLAGS) $(CPPFLAGS)
30-PY_LDFLAGS=	$(CONFIGURE_LDFLAGS) $(LDFLAGS)
31+PY_CPPFLAGS=	$(BASECPPFLAGS) -I. -I$(srcdir)/Include $(CPPFLAGS)
32+PY_LDFLAGS=	$(LDFLAGS)
33 PY_LDFLAGS_NODIST=$(CONFIGURE_LDFLAGS_NODIST) $(LDFLAGS_NODIST)
34 PY_LDFLAGS_NOLTO=$(PY_LDFLAGS) $(CONFIGURE_LDFLAGS_NOLTO) $(LDFLAGS_NODIST)
35 NO_AS_NEEDED=	@NO_AS_NEEDED@
36@@ -1768,14 +1765,6 @@ bininstall: altbininstall
37 	else true; \
38 	fi
39 	(cd $(DESTDIR)$(BINDIR); $(LN) -s python$(VERSION)$(EXE) python3$(EXE))
40-	-if test "$(VERSION)" != "$(LDVERSION)"; then \
41-		rm -f $(DESTDIR)$(BINDIR)/python$(VERSION)-config; \
42-		(cd $(DESTDIR)$(BINDIR); $(LN) -s python$(LDVERSION)-config python$(VERSION)-config); \
43-		rm -f $(DESTDIR)$(LIBPC)/python-$(LDVERSION).pc; \
44-		(cd $(DESTDIR)$(LIBPC); $(LN) -s python-$(VERSION).pc python-$(LDVERSION).pc); \
45-		rm -f $(DESTDIR)$(LIBPC)/python-$(LDVERSION)-embed.pc; \
46-		(cd $(DESTDIR)$(LIBPC); $(LN) -s python-$(VERSION)-embed.pc python-$(LDVERSION)-embed.pc); \
47-	fi
48 	-rm -f $(DESTDIR)$(BINDIR)/python3-config
49 	(cd $(DESTDIR)$(BINDIR); $(LN) -s python$(VERSION)-config python3-config)
50 	-rm -f $(DESTDIR)$(LIBPC)/python3.pc
51@@ -2129,6 +2118,14 @@ libainstall:	@DEF_MAKE_RULE@ python-config
52 	$(INSTALL_SCRIPT) $(srcdir)/install-sh $(DESTDIR)$(LIBPL)/install-sh
53 	$(INSTALL_SCRIPT) python-config.py $(DESTDIR)$(LIBPL)/python-config.py
54 	$(INSTALL_SCRIPT) python-config $(DESTDIR)$(BINDIR)/python$(LDVERSION)-config
55+	-if test "$(VERSION)" != "$(LDVERSION)"; then \
56+		rm -f $(DESTDIR)$(BINDIR)/python$(VERSION)-config; \
57+		(cd $(DESTDIR)$(BINDIR); $(LN) -s python$(LDVERSION)-config python$(VERSION)-config); \
58+		rm -f $(DESTDIR)$(LIBPC)/python-$(LDVERSION).pc; \
59+		(cd $(DESTDIR)$(LIBPC); $(LN) -s python-$(VERSION).pc python-$(LDVERSION).pc); \
60+		rm -f $(DESTDIR)$(LIBPC)/python-$(LDVERSION)-embed.pc; \
61+		(cd $(DESTDIR)$(LIBPC); $(LN) -s python-$(VERSION)-embed.pc python-$(LDVERSION)-embed.pc); \
62+	fi
63 	@if [ -s Modules/python.exp -a \
64 		"`echo $(MACHDEP) | sed 's/^\(...\).*/\1/'`" = "aix" ]; then \
65 		echo; echo "Installing support files for building shared extension modules on AIX:"; \
66