Skip to content

Commit 64a0110

Browse files
committed
unify/clarify/simplify makefiles
- there is now only one Makefile, at top level - it knows how to build pkg/python and cmd/go-python, but not tests (the old Makefile didn't work) - simplify Python code to query distutils - change so "make" output just shows CGO_* values, not the big hairy "python -c" command lines, eg. $ make (cd pkg/python && CGO_LDFLAGS="..." CGO_CFLAGS="..." go install -compiler="gc" .)
1 parent c0e58a2 commit 64a0110

4 files changed

Lines changed: 22 additions & 85 deletions

File tree

‎Makefile‎

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,29 @@
22
# Use of this source code is governed by a BSD-style
33
# license that can be found in the LICENSE file.
44

5-
#include ${GOROOT}/src/Make.inc
5+
PYTHON := python2
6+
PYTHON_CFLAGS := $(shell $(PYTHON) -c "from distutils import sysconfig; print(sysconfig.get_config_var('CFLAGS'))")
7+
PYTHON_CPPFLAGS := $(shell $(PYTHON) -c "from distutils import sysconfig; print(sysconfig.get_python_inc())")
8+
PYTHON_LDFLAGS := $(shell $(PYTHON) -c "from distutils import sysconfig; print('-L' + sysconfig.get_python_lib(0,1) + ' -lpython' + sysconfig.get_python_version())")
69

7-
all: install
10+
CGO_LDFLAGS := "$(PYTHON_LDFLAGS)"
11+
CGO_CFLAGS := "-I$(PYTHON_CPPFLAGS) $(PYTHON_CFLAGS)"
12+
13+
# default to gc, but allow caller to override on command line
14+
GO_COMPILER:=$(GC)
15+
ifeq ($(GO_COMPILER),)
16+
GO_COMPILER:="gc"
17+
endif
818

9-
DIRS=\
10-
pkg/python\
11-
tests\
12-
cmd/go-python\
19+
build_cwd = CGO_LDFLAGS=$(CGO_LDFLAGS) CGO_CFLAGS=$(CGO_CFLAGS) go build -compiler=$(GO_COMPILER) .
20+
install_cwd = CGO_LDFLAGS=$(CGO_LDFLAGS) CGO_CFLAGS=$(CGO_CFLAGS) go install -compiler=$(GO_COMPILER) .
21+
22+
all: install
1323

1424
install:
15-
(cd pkg/python && make install) && (cd cmd/go-python && make install)
25+
(cd pkg/python && $(install_cwd))
26+
(cd cmd/go-python && $(install_cwd))
27+
28+
build:
29+
(cd pkg/python && $(build_cwd))
30+
(cd cmd/go-python && $(build_cwd))

‎cmd/go-python/Makefile‎

Lines changed: 0 additions & 32 deletions
This file was deleted.

‎pkg/python/Makefile‎

Lines changed: 0 additions & 35 deletions
This file was deleted.

‎tests/Makefile‎

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)