Skip to content

Commit

Permalink
build: link win resource files and build pythonw
Browse files Browse the repository at this point in the history
Co-authored-by: Алексей <alexey.pawlow@gmail.com>
  • Loading branch information
lazka and Alexpux committed Aug 25, 2023
1 parent b67ad50 commit f834541
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 5 deletions.
26 changes: 21 additions & 5 deletions Makefile.pre.in
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ CXX= @CXX@
MAINCC= @MAINCC@
LINKCC= @LINKCC@
AR= @AR@
WINDRES= @WINDRES@
READELF= @READELF@
SOABI= @SOABI@
LDVERSION= @LDVERSION@
Expand Down Expand Up @@ -123,6 +124,7 @@ PY_CORE_CFLAGS= $(PY_STDMODULE_CFLAGS) -DPy_BUILD_CORE
PY_CORE_LDFLAGS=$(PY_LDFLAGS) $(PY_LDFLAGS_NODIST)
# Strict or non-strict aliasing flags used to compile dtoa.c, see above
CFLAGS_ALIASING=@CFLAGS_ALIASING@
RCFLAGS=@RCFLAGS@


# Machine-dependent subdirectories
Expand Down Expand Up @@ -291,6 +293,7 @@ LIBOBJS= @LIBOBJS@

PYTHON= python$(EXE)
BUILDPYTHON= python$(BUILDEXE)
BUILDPYTHONW= pythonw$(BUILDEXE)

HOSTRUNNER= @HOSTRUNNER@

Expand Down Expand Up @@ -592,7 +595,7 @@ LIBEXPAT_HEADERS= \

# Default target
all: @DEF_MAKE_ALL_RULE@
build_all: check-clean-src $(BUILDPYTHON) platform oldsharedmods sharedmods \
build_all: check-clean-src $(BUILDPYTHON) $(BUILDPYTHONW) platform oldsharedmods sharedmods \
gdbhooks Programs/_testembed python-config
build_wasm: check-clean-src $(BUILDPYTHON) platform oldsharedmods python-config

Expand Down Expand Up @@ -708,9 +711,21 @@ coverage-report: regen-token regen-frozen
clinic: check-clean-src $(srcdir)/Modules/_blake2/blake2s_impl.c
$(PYTHON_FOR_REGEN) $(srcdir)/Tools/clinic/clinic.py --make --srcdir $(srcdir)

python_exe.o: $(srcdir)/PC/python_exe.rc
$(WINDRES) $(RCFLAGS) -I$(srcdir)/Include -I$(srcdir)/PC -I. $(srcdir)/PC/python_exe.rc $@

pythonw_exe.o: $(srcdir)/PC/pythonw_exe.rc
$(WINDRES) $(RCFLAGS) -I$(srcdir)/Include -I$(srcdir)/PC -I. $(srcdir)/PC/pythonw_exe.rc $@

python_nt.o: $(srcdir)/PC/python_nt.rc
$(WINDRES) $(RCFLAGS) -DORIGINAL_FILENAME=\\\"$(DLLLIBRARY)\\\" -I$(srcdir)/Include -I$(srcdir)/PC -I. $(srcdir)/PC/python_nt.rc $@

$(BUILDPYTHONW): Programs/python.o $(LIBRARY) $(LDLIBRARY) $(PY3LIBRARY) pythonw_exe.o
$(LINKCC) $(PY_CORE_LDFLAGS) $(LINKFORSHARED) -municode -mwindows -o $@ Programs/python.o $(BLDLIBRARY) $(LIBS) $(MODLIBS) $(SYSLIBS) pythonw_exe.o

# Build the interpreter
$(BUILDPYTHON): Programs/python.o $(LINK_PYTHON_DEPS)
$(LINKCC) $(PY_CORE_LDFLAGS) $(LINKFORSHARED) -o $@ Programs/python.o $(LINK_PYTHON_OBJS) $(LIBS) $(MODLIBS) $(SYSLIBS)
$(BUILDPYTHON): Programs/python.o $(LINK_PYTHON_DEPS) python_exe.o
$(LINKCC) $(PY_CORE_LDFLAGS) $(LINKFORSHARED) -municode -o $@ Programs/python.o $(LINK_PYTHON_OBJS) $(LIBS) $(MODLIBS) $(SYSLIBS) python_exe.o

platform: $(PYTHON_FOR_BUILD_DEPS) pybuilddir.txt
$(RUNSHARED) $(PYTHON_FOR_BUILD) -c 'import sys ; from sysconfig import get_platform ; print("%s-%d.%d" % (get_platform(), *sys.version_info[:2]))' >platform
Expand Down Expand Up @@ -814,10 +829,10 @@ $(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK): \

# This rule builds the Cygwin Python DLL and import library if configured
# for a shared core library; otherwise, this rule is a noop.
$(DLLLIBRARY) libpython$(LDVERSION).dll.a: $(LIBRARY_OBJS)
$(DLLLIBRARY) libpython$(LDVERSION).dll.a: $(LIBRARY_OBJS) python_nt.o
if test -n "$(DLLLIBRARY)"; then \
$(LDSHARED) -Wl,--out-implib=$@ -o $(DLLLIBRARY) $^ \
$(LIBS) $(MODLIBS) $(SYSLIBS); \
$(LIBS) $(MODLIBS) $(SYSLIBS) python_nt.o; \
else true; \
fi

Expand Down Expand Up @@ -1815,6 +1830,7 @@ altbininstall: $(BUILDPYTHON) @FRAMEWORKPYTHONW@
done
if test "$(PYTHONFRAMEWORKDIR)" = "no-framework" ; then \
$(INSTALL_PROGRAM) $(BUILDPYTHON) $(DESTDIR)$(BINDIR)/python$(LDVERSION)$(EXE); \
$(INSTALL_PROGRAM) $(BUILDPYTHONW) $(DESTDIR)$(BINDIR)/python3w$(EXE); \
else \
$(INSTALL_PROGRAM) $(STRIPFLAG) Mac/pythonw $(DESTDIR)$(BINDIR)/python$(LDVERSION)$(EXE); \
fi
Expand Down
27 changes: 27 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -1730,6 +1730,10 @@ AC_SUBST(LINK_PYTHON_OBJS)
AC_SUBST(AR)
AC_CHECK_TOOLS(AR, ar aal, ar)

# windres program
AC_SUBST(WINDRES)
AC_CHECK_TOOL(WINDRES, windres)

# tweak ARFLAGS only if the user didn't set it on the command line
AC_SUBST(ARFLAGS)
if test -z "$ARFLAGS"
Expand Down Expand Up @@ -6661,10 +6665,33 @@ AC_MSG_RESULT(done)
case $host in
*-*-mingw*)
LIBS="$LIBS -lversion -lshlwapi -lpathcch"
AC_PROG_AWK
if test "$AWK" = "gawk"; then
awk_extra_flag="--non-decimal-data"
fi
AC_MSG_CHECKING([FIELD3])
FIELD3=$($AWK $awk_extra_flag '\
/^#define PY_RELEASE_LEVEL_/ {levels[$2]=$3} \
/^#define PY_MICRO_VERSION[[:space:]]+/ {micro=$3} \
/^#define PY_RELEASE_LEVEL[[:space:]]+/ {level=levels[$3]} \
/^#define PY_RELEASE_SERIAL[[:space:]]+/ {serial=$3} \
END {print micro * 1000 + level * 10 + serial}' \
$srcdir/Include/patchlevel.h
)

AC_MSG_RESULT([${FIELD3}])
RCFLAGS="$RCFLAGS -DFIELD3=$FIELD3 -O COFF"

case $host in
i686*) RCFLAGS="$RCFLAGS --target=pe-i386" ;;
x86_64*) RCFLAGS="$RCFLAGS --target=pe-x86-64" ;;
*) ;;
esac
;;
*)
;;
esac
AC_SUBST(RCFLAGS)

# Availability of -O2:
AC_CACHE_CHECK([for -O2], [ac_cv_compile_o2], [
Expand Down

0 comments on commit f834541

Please sign in to comment.