makefile.mingw 12 KB
Newer Older
1
2
3
4
5
6
# makefile to compile for windows using the mingw suite.
# To use this makefile to cross-compile from linux, type for example:
# make -f makefile.mingw CC=i686-w64-mingw32-gcc CXX=i686-w64-mingw32-c++ \
#  WINDRES=i686-w64-mingw32-windres

# Miller's Windows build uses Microsoft Visual C and makefile.msvc:
Hans-Christoph Steiner's avatar
Hans-Christoph Steiner committed
7
8
9
10
# http://lists.puredata.info/pipermail/pd-dev/2004-10/002981.html

CC = gcc
CXX = g++
11
WINDRES = windres
Hans-Christoph Steiner's avatar
Hans-Christoph Steiner committed
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

cvs_root_dir = ../..
pd_src = $(cvs_root_dir)/pd
DLL_DIR = $(pd_src)/src

BIN_DIR = $(pd_src)/bin

VPATH = $(pd_src)/src

prefix = ..
exec_prefix = $(prefix)
includedir = $(prefix)/include
libdir = $(exec_prefix)/lib
mandir = $(prefix)/man
bindir = $(exec_prefix)/bin

GFLAGS = -DINSTALL_PREFIX=\"$(prefix)\"

# varibles to match packages/Makefile.buildlayout so that they can be easily
# overridden when building Pd-extended builds. <hans@at.or.at>
libpddir = $(DESTDIR)$(prefix)
pddocdir = $(libpddir)/doc
libpdbindir = $(libpddir)/bin

PDEXEC = pd.exe
PDDLL = pd.dll

DLLWRAP= dllwrap

MORECFLAGS = -O3 -funroll-loops -fomit-frame-pointer 

PADIR = $(pd_src)/portaudio
44
45
46
47
ASIODIR = $(pd_src)/lib/ASIOSDK2.3
ASIOINC = -I$(ASIODIR)/common -I$(ASIODIR)/host -I$(ASIODIR)/host/pc
INCPA = -I$(PADIR)/include -I$(PADIR)/src/common -I$(PADIR)/src/os/win \
      $(ASIOINC)
Hans-Christoph Steiner's avatar
Hans-Christoph Steiner committed
48
49
50
51
INCLUDE = -I$(pd_src)/src 
GINCLUDE = -I/usr/local/include $(INCLUDE)

LDFLAGS = 
52
LIBS = -lm -lwsock32 -lwinmm -lole32 -lpthread
Hans-Christoph Steiner's avatar
Hans-Christoph Steiner committed
53
54
55
56
57

OPT_CFLAGS = 

WARN_CFLAGS = -Wall -W -Wstrict-prototypes -Wno-unused \
    -Wno-unused-parameter -Wno-parentheses -Wno-switch
58
59
60
61
62
# Some old code in asio/ASIOSDK2/common/combase.h needs to be ignored,
# we do this by setting the WINVER macro to min Windows XP aka 5.1.
# Also, for SetDllDirectory() s_loader.c, we need a minium of Windows
# XP SP1.  WINVER isnt' fine-grained enough for that, so we use the
# next minor version of Windows, 5.2.
63
64
65
ARCH_CFLAGS = -DPD -DPD_INTERNAL -DMSW -DPA_USE_ASIO -DPA_USE_WMME \
	-DWINVER=0x0502 -DUSEAPI_MMIO -DUSEAPI_PORTAUDIO -mms-bitfields \
	-DWISHAPP='"wish85.exe"'
Hans-Christoph Steiner's avatar
Hans-Christoph Steiner committed
66
67
68
69
70
71
72

CFLAGS += $(ARCH_CFLAGS) $(WARN_CFLAGS) $(OPT_CFLAGS) $(MORECFLAGS)

STRIP = strip --strip-unneeded -R .note -R .comment

# the sources

73
74
PASRC = s_audio_pa.c s_audio_paring.c \
	s_audio_mmio.c \
Hans-Christoph Steiner's avatar
Hans-Christoph Steiner committed
75
76
77
78
79
80
81
82
83
	$(PADIR)/src/common/pa_stream.c \
        $(PADIR)/src/common/pa_trace.c \
        $(PADIR)/src/common/pa_process.c \
        $(PADIR)/src/common/pa_front.c \
        $(PADIR)/src/common/pa_dither.c \
        $(PADIR)/src/common/pa_cpuload.c \
        $(PADIR)/src/common/pa_converters.c \
        $(PADIR)/src/common/pa_allocation.c \
        $(PADIR)/src/common/pa_ringbuffer.c \
84
        $(PADIR)/src/os/win/pa_win_coinitialize.c \
Hans-Christoph Steiner's avatar
Hans-Christoph Steiner committed
85
86
87
88
89
90
        $(PADIR)/src/os/win/pa_win_hostapis.c \
        $(PADIR)/src/os/win/pa_win_util.c \
        $(PADIR)/src/os/win/pa_win_waveformat.c \
        $(PADIR)/src/hostapi/wmme/pa_win_wmme.c

ASIOSRC = $(PADIR)/src/hostapi/asio/iasiothiscallresolver.cpp \
91
92
	$(PADIR)/src/hostapi/asio/pa_asio.cpp $(ASIODIR)/common/asio.cpp \
	$(ASIODIR)/host/asiodrivers.cpp $(ASIODIR)/host/pc/asiolist.cpp
Hans-Christoph Steiner's avatar
Hans-Christoph Steiner committed
93
94
95
96
#VSRC =  s_audio_vst.c

PMDIR = ../portmidi
PMINCLUDE = -I$(PMDIR)/pm_common -I$(PMDIR)/pm_win -I$(PMDIR)/porttime -DNEWBUFFER
97
98
PMSRC = s_midi_pm.c \
        $(PMDIR)/pm_common/portmidi.c \
Hans-Christoph Steiner's avatar
Hans-Christoph Steiner committed
99
100
101
102
103
104
105
106
        $(PMDIR)/pm_common/pmutil.c \
        $(PMDIR)/porttime/porttime.c \
        $(PMDIR)/porttime/ptwinmm.c \
        $(PMDIR)/pm_win/pmwin.c \
        $(PMDIR)/pm_win/pmwinmm.c

PMOBJ =  $(PMSRC:.c=.o)

Jonathan Wilkes's avatar
Jonathan Wilkes committed
107
GSRC =
Hans-Christoph Steiner's avatar
Hans-Christoph Steiner committed
108

109
HEADERS = g_all_guis.h m_imp.h g_canvas.h g_magicglass.h m_pd.h s_stuff.h \
110
	g_undo.h x_preset.h s_utf8.h \
111
	$(wildcard ../portaudio/common/*.h) s_audio_paring.h
Hans-Christoph Steiner's avatar
Hans-Christoph Steiner committed
112
113

SRC = g_canvas.c g_graph.c g_text.c g_rtext.c g_array.c g_template.c g_io.c \
114
    g_scalar.c g_traversal.c g_guiconnect.c g_readwrite.c g_editor.c g_clone.c \
115
116
    g_all_guis.c g_bang.c g_radio.c g_mycanvas.c g_numbox.c g_toggle.c \
    g_vumeter.c m_pd.c m_class.c m_obj.c m_atom.c m_memory.c \
Hans-Christoph Steiner's avatar
Hans-Christoph Steiner committed
117
118
119
120
121
    m_binbuf.c m_conf.c m_glob.c m_sched.c s_main.c s_inter.c s_file.c \
    s_print.c s_loader.c s_path.c s_entry.c s_audio.c s_midi.c \
    d_ugen.c d_ctl.c d_arithmetic.c d_osc.c d_filter.c d_dac.c d_misc.c \
    d_math.c d_fft.c d_fft_mayer.c d_fftroutine.c d_array.c d_global.c \
    d_delay.c d_resample.c x_arithmetic.c x_connective.c x_interface.c \
122
    x_midi.c x_misc.c x_time.c x_acoustics.c x_net.c x_text.c x_gui.c \
123
    x_list.c x_array.c d_soundfile.c g_slider.c import.c \
124
    x_scalar.c x_vexp.c x_vexp_if.c x_vexp_fun.c \
125
    g_undo.c s_utf8.c x_preset.c g_magicglass.c
Hans-Christoph Steiner's avatar
Hans-Christoph Steiner committed
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

SRSRC = u_pdsend.c u_pdreceive.c

OBJ = $(SRC:.c=.o) 
GOBJ = $(GSRC:.c=.o)
SROBJ = $(SRSRC:.c=.o) 
PAOBJ = $(PASRC:.c=.o)
ASIOOBJ = $(ASIOSRC:.cpp=.o)
#VOBJ = $(VSRC:.c=.o)
OBJC = $(OBJ) $(PAOBJ) $(ASIOOBJ) $(PMOBJ)


# get version from m_pd.h to use in doc/1.manual/1.introduction.txt
PD_MAJOR_VERSION := $(shell grep PD_MAJOR_VERSION m_pd.h | \
	sed 's|^.define *PD_MAJOR_VERSION *\([0-9]*\).*|\1|' )
PD_MINOR_VERSION := $(shell grep PD_MINOR_VERSION m_pd.h | \
	sed 's|^.define *PD_MINOR_VERSION *\([0-9]*\).*|\1|' )
PD_BUGFIX_VERSION := $(shell grep PD_BUGFIX_VERSION m_pd.h | \
	sed 's|^.define *PD_BUGFIX_VERSION *\([0-9]*\).*|\1|' )
PD_TEST_VERSION := $(shell grep PD_TEST_VERSION m_pd.h | \
	sed 's|^.define *PD_TEST_VERSION *"\(.*\)".*|\1|' )
PD_VERSION := $(PD_MAJOR_VERSION).$(PD_MINOR_VERSION).$(PD_BUGFIX_VERSION)
ifneq ($(PD_TEST_VERSION),)
	PD_VERSION := $(PD_VERSION)-$(PD_TEST_VERSION)
endif
151
152
153
# AG: Pd-l2ork version number
PD_L2ORK_VERSION := $(shell grep PD_L2ORK_VERSION m_pd.h | \
	sed 's|^.define *PD_L2ORK_VERSION *"\(.*\)".*|\1|' )
154
PD_BUILD_VERSION := $(shell git log -1 --format=%cd --date=short | sed -e 's/-//g')-rev.$(shell git rev-parse --short HEAD)
Hans-Christoph Steiner's avatar
Hans-Christoph Steiner committed
155
156
157
158
159
160
161
162


#
#  ------------------ targets ------------------------------------
#

.PHONY: all install clean externs testbin

Jonathan Wilkes's avatar
Jonathan Wilkes committed
163
all: config.h $(PDDLL) $(PDEXEC) pdsend.exe pdreceive.exe pd.com externs
Hans-Christoph Steiner's avatar
Hans-Christoph Steiner committed
164
165
166
167

config.h: config.h.in
	cp config.h.in config.h

168
169
170
s_stuff.h: s_stuff.h.in
	sed 's|^\(#define PD_BUILD_VERSION "\).*"|\1$(PD_BUILD_VERSION)"|' $< > $@

Hans-Christoph Steiner's avatar
Hans-Christoph Steiner committed
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
$(OBJ) : %.o : %.c
	$(CC) $(CFLAGS) $(GFLAGS) $(INCLUDE) -c -o $*.o $*.c 

$(GOBJ) : %.o : %.c
	$(CC) $(CFLAGS) $(GFLAGS) $(GINCLUDE) -c -o $*.o $*.c 

$(SROBJ) : %.o : %.c
	$(CC) $(CFLAGS) $(GFLAGS) $(INCLUDE) -c -o $*.o $*.c 

$(PAOBJ) : %.o : %.c
	$(CC) $(CFLAGS) $(GFLAGS) $(INCPA) -c -o $*.o $*.c 

$(ASIOOBJ) : %.o : %.cpp
	$(CXX) $(CFLAGS) $(INCPA) -c -o $*.o $*.cpp

$(PMOBJ) : %.o : %.c
	$(CC) $(CFLAGS) $(GFLAGS) $(PMINCLUDE) -c -o $*.o $*.c 

$(VOBJ) : %.o : %.c
	$(CC) $(CFLAGS) $(GFLAGS) $(INCLUDE) -c -o $*.o $*.c 

pdsend.exe: u_pdsend.o
	$(CC) $(CFLAGS) $(LDFLAGS) -o pdsend.exe u_pdsend.o $(LIBS)
	$(STRIP) pdsend.exe

pdreceive.exe: u_pdreceive.o
	$(CC) $(CFLAGS) $(LDFLAGS) -o pdreceive.exe u_pdreceive.o $(LIBS)
	$(STRIP) pdreceive.exe

$(PDEXEC): s_entry.o pd.res
	$(CC) $(LDFLAGS) -mwindows -o $(PDEXEC) s_entry.o pd.res $(LIBS) -L. -lpd
	$(STRIP) -s $(PDEXEC)

pd.com: s_entry.o
	$(CC) $(LDFLAGS) -o pd.com s_entry.o $(LIBS) -L. -lpd
	$(STRIP) -s pd.com

$(PDDLL): $(OBJC)
	$(CXX) -shared $(LDFLAGS) -o $(PDDLL) $(OBJC) $(LIBS) \
		-Wl,--export-all-symbols -Wl,--out-implib=pd.a -Wl,--output-def=pddll.def
	$(STRIP) $(PDDLL)

pdtcl.dll: t_tkcmd.o
	$(DLLWRAP) --export-all-symbols --output-def=pdtcl.def \
		--output-lib=pdtcl.a --dllname=pdtcl.dll t_tkcmd.o $(LIBS)
	$(STRIP) pdtcl.dll

pd.res: pd.rc
	windres pd.rc -O coff -o pd.res

#vstschedlib.dll: $(VOBJ)
#	$(DLLWRAP) --export-all-symbols --output-def vst.def \
#	--output-lib=vst.a --dllname=vstschedlib.dll s_audio_vst.o pd.a $(LIBS)

# for making objects included with Pd, [expr] is whacky, so its built
# separately, and pd~ doesn't build on Windows yet
227
EXTERNALS_SRC := $(wildcard $(pd_src)/extra/[a-df-oq-z]*/*.c)
228
229
230
231
232
233
#EXPR_SRC = vexp.c vexp_fun.c vexp_if.c
#EXPR_OBJ =  $(patsubst %.c, $(pd_src)/extra/expr~/%.o, $(EXPR_SRC))
#expr_src = $(pd_src)/extra/expr~

#externs: $(EXTERNALS_SRC:.c=.dll) $(expr_src)/expr.dll $(expr_src)/expr~.dll \
#      $(expr_src)/fexpr~.dll
234
externs: $(EXTERNALS_SRC:.c=.dll)
235
236
237
238
239
240
241
242
243
244

#$(expr_src)/expr.dll: $(EXPR_OBJ)
#      $(CC) $(CFLAGS) $(INCLUDE) $(LDFLAGS) -s -shared --enable-auto-import \
#              -o $(expr_src)/expr.dll $(EXPR_OBJ) $(LIBS) -L$(DLL_DIR) -lpd
#$(expr_src)/expr~.dll: $(EXPR_OBJ)
#      $(CC) $(CFLAGS) $(INCLUDE) $(LDFLAGS) -s -shared --enable-auto-import \
#              -o $(expr_src)/expr~.dll $(EXPR_OBJ) $(LIBS) -L$(DLL_DIR) -lpd
#$(expr_src)/fexpr~.dll: $(EXPR_OBJ)
#      $(CC) $(CFLAGS) $(INCLUDE) $(LDFLAGS) -s -shared --enable-auto-import \
#              -o $(expr_src)/fexpr~.dll $(EXPR_OBJ) $(LIBS) -L$(DLL_DIR) -lpd
Hans-Christoph Steiner's avatar
Hans-Christoph Steiner committed
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267

%.o: %.c
	$(CC) $(CFLAGS) $(INCLUDE) -c -o $*.o $*.c

%.dll: %.o
	$(CC) $(CFLAGS) $(INCLUDE) $(LDFLAGS) -s -shared --enable-auto-import \
		-o $*.dll $*.o $(LIBS) -L$(DLL_DIR) -lpd
#	$(STRIP) $*.dll

# kludge to put stuff into the pd/bin dir for testing
testbin: $(PDEXEC) $(PDDLL) pd.com
	echo "Copying files to $(BIN_DIR)"
	install -d $(BIN_DIR)
	install -p pd.tk $(BIN_DIR)
	install -p $(PDDLL) $(BIN_DIR)
	install -p pd.ico $(BIN_DIR)
	install -p pd.com $(BIN_DIR)
	install -p $(PDEXEC) $(BIN_DIR)

ABOUT_FILE=$(pddocdir)/1.manual/1.introduction.txt
install:  all
# the real install
	install -d $(DESTDIR)$(bindir)
268
# rsync the nw directory, which includes the nw binary itself
269
	rsync -ax --exclude=.git --exclude=.svn ../nw/* $(DESTDIR)$(bindir)
Hans-Christoph Steiner's avatar
Hans-Christoph Steiner committed
270
271
272
273
274
275
276
277
	install -p $(PDEXEC) $(DESTDIR)$(bindir)/$(PDEXEC)
	install -p pd.com $(DESTDIR)$(bindir)/pd.com
	install -p pd.dll $(DESTDIR)$(bindir)/pd.dll
	install -p pddll.def $(DESTDIR)$(bindir)/pddll.def
	install -p pd.a $(DESTDIR)$(bindir)/pd.lib
	install -p pd.ico $(DESTDIR)$(bindir)/pd.ico
	install -p pdsend.exe $(DESTDIR)$(bindir)/pdsend.exe
	install -p pdreceive.exe $(DESTDIR)$(bindir)/pdreceive.exe
278
279
280
281
282
283
	install -d $(DESTDIR)$(includedir)/pdl2ork
	install -p m_pd.h $(DESTDIR)$(includedir)/pdl2ork/m_pd.h
	install -p m_imp.h $(DESTDIR)$(includedir)/pdl2ork/m_imp.h
	install -p g_canvas.h $(DESTDIR)$(includedir)/pdl2ork/g_canvas.h
	install -p s_stuff.h $(DESTDIR)$(includedir)/pdl2ork/s_stuff.h
	install -p g_all_guis.h $(DESTDIR)$(includedir)/pdl2ork/g_all_guis.h
Hans-Christoph Steiner's avatar
Hans-Christoph Steiner committed
284
285
# since Pd-vanilla on Mac OS X doesn't have an 'include/pd' folder,
# Pd-extended will mimic Pd-vanilla's include/pd until Pd-vanilla gets one
286
	cp -pr $(DESTDIR)$(includedir)/pdl2ork $(DESTDIR)$(includedir)/pd
Hans-Christoph Steiner's avatar
Hans-Christoph Steiner committed
287
	install -p m_pd.h $(DESTDIR)$(includedir)
288
	rsync -ax --exclude=.git --exclude=.svn ../doc/* $(pddocdir)
Albert Gräf's avatar
Albert Gräf committed
289
	cp -rf ../doc/about $(pddocdir)/
Hans-Christoph Steiner's avatar
Hans-Christoph Steiner committed
290
	mv $(ABOUT_FILE) $(ABOUT_FILE).tmp
291
	cat $(ABOUT_FILE).tmp | sed 's|PD_VERSION|Pd version $(PD_L2ORK_VERSION) ($(PD_BUILD_VERSION))|' \
Hans-Christoph Steiner's avatar
Hans-Christoph Steiner committed
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
		> $(ABOUT_FILE)
	rm $(ABOUT_FILE).tmp
	install -d $(libpddir)/extra
	install -p $(pd_src)/extra/*/*.dll $(libpddir)/extra
	install -p $(pd_src)/extra/*.pd $(libpddir)/extra
	install -d $(pddocdir)/5.reference
	install -p ../extra/*/*.pd $(pddocdir)/5.reference
	install -p ../extra/*-help.pd $(pddocdir)/5.reference
	install -d $(DESTDIR)$(includedir)
	install -p m_pd.h $(DESTDIR)$(includedir)/m_pd.h
	install -p s_stuff.h $(DESTDIR)$(includedir)/s_stuff.h
	@echo "Pd install succeeded."


clean:
	-rm -f -- $(BIN_DIR)/*.*
	-rm -f -- $(PDEXEC) pdsend.exe pdreceive.exe pd.com
	-rm -f -- $(PDDLL) pdtcl.dll pdtcl.a pdtcl.def
	-rm -f -- $(OBJ) $(GOBJ) $(SROBJ) $(PAOBJ) $(ASIOOBJ) $(PMOBJ)
	-rm -f -- $(pd_src)/extra/*/*.dll $(pd_src)/extra/*/*.o
	-rm -f makefile.dependencies

distclean: clean
315
	rm -rf -- s_stuff.h config.cache config.log config.status makefile tags \
Hans-Christoph Steiner's avatar
Hans-Christoph Steiner committed
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
	     autom4te-*.cache

tags: $(SRC) $(GSRC); ctags *.[ch]

depend: makefile.dependencies

makefile.dependencies: config.h $(SRC) $(GSRC) $(PASRC) $(HEADERS)
	$(CC) $(INCLUDE) $(INCPA) $(CFLAGS) -M $(SRC) $(GSRC) $(PASRC) $(HEADERS) \
		> makefile.dependencies

uninstall:
	-rm $(prefix)/bin/pd*.exe
	-rm $(prefix)/bin/pd*.com
	-rm $(prefix)/bin/pd*.dll
	-rm $(prefix)/bin/*.tk


test_locations:
	@echo "PD_VERSION: $(PD_VERSION)"
	@echo "PACKAGE_VERSION: $(PACKAGE_VERSION)"
	@echo "CWD $(CWD)"
	@echo "DESTDIR $(DESTDIR)"
	@echo "PREFIX $(prefix)"
	@echo "BINDIR  $(bindir)"
	@echo "LIBDIR  $(libdir)"
	@echo "OBJECTSDIR  $(objectsdir)"
	@echo "PDDOCDIR  $(pddocdir)"
	@echo "LIBPDDIR  $(libpddir)"
	@echo "LIBPDBINDIR  $(libpdbindir)"
	@echo "HELPDIR  $(helpdir)"
	@echo "MANUALSDIR  $(manualsdir)"
	@echo "EXAMPLESDIR  $(examplesdir)"


include makefile.dependencies