summaryrefslogtreecommitdiff
path: root/project/pycompile.mk
blob: 8cf2ac4d5dbed0f3a980ee0bde12e7d008b65f2d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
PYCOMPILE_DIR		 = build.pycompile
PYCOMPILE_CFGHOST	 = $(NATIVE_CC_CFGHOST)
PYCOMPILE_PREFIX	 = $(CURDIR)/$(PYCOMPILE_DIR)
PYCOMPILE_PATH		 =
PYCOMPILE		 = $(PYCOMPILE_DIR)/bin/pycompile

PYCOMPILE_APP_SRCS	 = $(APP_SRCS)
PYCOMPILE_CONFIG_SRCS	 = $(CONFIG_DEFAULT_SRCS)

PYCOMPILE_TAGS		+= $(PYCOMPILE_DIR)/tree.tag
PYCOMPILE_TAGS		+= $(PYCOMPILE_DIR)/config.tag

PYCOMPILE_CFLAGS	+= -std=c99
PYCOMPILE_CFLAGS	+= -I$(PYCOMPILE_DIR)/build
PYCOMPILE_CFLAGS	+= -I$(PROJECT_DIR)/profiles
PYCOMPILE_CFLAGS	+= -I$(SOURCE_DIR)/Include
PYCOMPILE_CFLAGS	+= -I$(SOURCE_DIR)/Modules/_decimal/libmpdec
PYCOMPILE_CFLAGS	+= -DPY_FOR_PYCOMPILE
PYCOMPILE_CFLAGS	+= -DVPATH=\"$(SOURCE_DIR)\"
PYCOMPILE_CFLAGS	+= -DVERSION=\"$(PYTHON_VER)\"
PYCOMPILE_CFLAGS	+= -DPLATFORM=\"$(NATIVE_OS)\"
PYCOMPILE_CFLAGS	+= -DPREFIX=\"$(PYCOMPILE_PREFIX)\"
PYCOMPILE_CFLAGS	+= -DEXEC_PREFIX=\"$(PYCOMPILE_PREFIX)\"
PYCOMPILE_CFLAGS	+= -DPYTHONPATH=\"$(PYCOMPILE_PATH)\"
PYCOMPILE_CFLAGS	+= -DSOABI=\"$(PYTHON_SOABI)\"
PYCOMPILE_CFLAGS	+= -DABIFLAGS=\"\"
PYCOMPILE_CFLAGS	+= $(NATIVE_CC_CFLAGS)

PYCOMPILE_LDFLAGS	+= -lreadline -lm -lutil -lpthread
PYCOMPILE_LDFLAGS	+= $(NATIVE_CC_LDFLAGS)
PYCOMPILE_LDFLAGS	+= -lreadline -lm -lutil -lpthread

$(PYCOMPILE_DIR)/tree.tag:
		mkdir -p $(PYCOMPILE_DIR)/bin
		mkdir -p $(PYCOMPILE_DIR)/lib
		mkdir -p $(PYCOMPILE_DIR)/core
		mkdir -p $(PYCOMPILE_DIR)/core/Modules
		mkdir -p $(PYCOMPILE_DIR)/core/Modules/_io
		mkdir -p $(PYCOMPILE_DIR)/core/Objects
		mkdir -p $(PYCOMPILE_DIR)/core/Parser
		mkdir -p $(PYCOMPILE_DIR)/core/Python
		mkdir -p $(PYCOMPILE_DIR)/core/Programs
		mkdir -p $(PYCOMPILE_DIR)/pyext
		mkdir -p $(PYCOMPILE_DIR)/pyext/obj
		mkdir -p $(PYCOMPILE_DIR)/pyext/obj/_decimal
		mkdir -p $(PYCOMPILE_DIR)/pyext/obj/_decimal/libmpdec
		mkdir -p $(PYCOMPILE_DIR)/lib/$(NICKNAME)
		mkdir -p $(PYCOMPILE_DIR)/lib/$(NICKNAME)/collections
		mkdir -p $(PYCOMPILE_DIR)/lib/$(NICKNAME)/encodings
		mkdir -p $(PYCOMPILE_DIR)/lib/$(NICKNAME)/importlib
		mkdir -p $(PYCOMPILE_DIR)/lib/$(NICKNAME)/urllib
		mkdir -p $(PYCOMPILE_DIR)/lib/$(NICKNAME)/lib-dynload
		mkdir -p $(PYCOMPILE_DIR)/build
		touch $(PYCOMPILE_DIR)/tree.tag

ifeq ($(PYCOMPILE_CFGSTEP),)

$(PYCOMPILE_DIR)/config.tag:
	$(MAKE) PYCOMPILE_CFGSTEP=yes                  \
		PYCOMPILE_CFGHOST=$(PYCOMPILE_CFGHOST) \
		CFGHOST=$(PYCOMPILE_CFGHOST)           \
		$(PYCOMPILE_DIR)/config.tag
else

$(PYCOMPILE_DIR)/config.tag:
	mkdir -p $(PYCOMPILE_DIR)/build
	cp -p $(PROJECT_DIR)/config/$(CFGHOST)/config.c   $(PYCOMPILE_DIR)/build/
	cp -p $(PROJECT_DIR)/config/$(CFGHOST)/pyconfig.h $(PYCOMPILE_DIR)/build/
	touch $(PYCOMPILE_DIR)/config.tag
	touch $(PYCOMPILE_DIR)/build/config.c
	touch $(PYCOMPILE_DIR)/build/pyconfig.h

endif

$(PYCOMPILE_DIR)/core/%.o:		PYCOMPILE_CFLAGS += -DPy_BUILD_CORE

$(PYCOMPILE_DIR)/build/config.c:	$(PYCOMPILE_DIR)/config.tag
$(PYCOMPILE_DIR)/build/pyconfig.h:	$(PYCOMPILE_DIR)/config.tag

$(PYCOMPILE_DIR)/core/Modules/config.o:	$(PYCOMPILE_DIR)/build/config.c $(ALL_HEADERS) $(PYCOMPILE_TAGS)
					$(NATIVE_CC) -c -o $@ $< $(PYCOMPILE_CFLAGS)

$(PYCOMPILE_DIR)/core/%.o:	$(SOURCE_DIR)/%.c $(ALL_HEADERS) $(PYCOMPILE_TAGS)
				$(NATIVE_CC) -c -o $@ $< $(PYCOMPILE_CFLAGS)

$(PYCOMPILE_DIR)/pyext/obj/%.o:	$(SOURCE_DIR)/Modules/%.c $(ALL_HEADERS) $(PYCOMPILE_TAGS)
				$(NATIVE_CC) -c -o $@ $< $(PYCOMPILE_CFLAGS)

$(PYCOMPILE_DIR)/pyext/obj/_decimal/%.o: NATIVE_CC_CFLAGS += -DUNIVERSAL


PYCOMPILE_PYEXT_SRCS = \
	$(PYEXT_DECIMAL_SRCS)	        \
	$(PYEXT_ELEMENTTREE_SRCS)       \
	$(PYEXT_HEAPQ_SRCS)             \
	$(PYEXT_POSIXSUBPROCESS_SRCS)   \
	$(PYEXT_MATH_SRCS)              \
	$(PYEXT_READLINE_SRCS)          \
	$(PYEXT_SELECT_SRCS)            \
	$(PYEXT_TERMIOS_SRCS)           \


PYCOMPILE_SRCS =                    \
	$(PYCOMPILE_APP_SRCS)       \
	$(PYCOMPILE_CONFIG_SRCS)    \
	$(PYCOMPILE_PYEXT_SRCS)     \
	$(MODULE_SRCS)              \
	$(OBJECT_SRCS)              \
	$(PARSER_SRCS)              \
	$(PYTHON_SRCS)

PYCOMPILE_OBJS = $(PYCOMPILE_SRCS:%.c=$(PYCOMPILE_DIR)/%.o)

ifeq ($(PYCOMPILE_CFGSTEP),)

$(PYCOMPILE):	$(PYCOMPILE_OBJS)
	$(MAKE) PYCOMPILE_CFGSTEP=yes                  \
		PYCOMPILE_CFGHOST=$(PYCOMPILE_CFGHOST) \
		CFGHOST=$(PYCOMPILE_CFGHOST)           \
		pycompile
else

$(PYCOMPILE):	$(PYCOMPILE_OBJS)
		$(NATIVE_CC) -o $@ $^ $(PYCOMPILE_LDFLAGS)

endif


pycompile:	$(PYCOMPILE)

pycompile-objs:	$(PYCOMPILE_OBJS)

pycompile-clean-config:
	rm -f $(PYCOMPILE_DIR)/tree.tag
	rm -f $(PYCOMPILE_DIR)/config.tag
	rm -f $(PYCOMPILE_DIR)/build/config.c
	rm -f $(PYCOMPILE_DIR)/build/pyconfig.h

pycompile-clean-objs:
	rm -f $(PYCOMPILE_OBJS)

pycompile-clean-pycompile:
	rm -f $(PYCOMPILE)

pycompile-clean:pycompile-clean-objs
pycompile-clean:pycompile-clean-config
pycompile-clean:pycompile-clean-pycompile

clean:		pycompile-clean-objs
clean:		pycompile-clean-config
clean:		pycompile-clean-pycompile

.PHONY:		pycompile               pycompile-objs
		pycompile-clean         pycompile-clean-objs
		pycompile-clean-config  pycompile-clean-pycompile