Subversion Repositories filter_foundry

Rev

Rev 67 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
18 toby 1
# This file is part of "Filter Foundry", a filter plugin for Adobe Photoshop
65 toby 2
# Copyright (C) 2003-7 Toby Thain, toby@telegraphics.com.au
2 toby 3
 
4
# This program is free software; you can redistribute it and/or modify
5
# it under the terms of the GNU General Public License as published by  
6
# the Free Software Foundation; either version 2 of the License, or
7
# (at your option) any later version.
8
 
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
# GNU General Public License for more details.
13
 
14
# You should have received a copy of the GNU General Public License  
15
# along with this program; if not, write to the Free Software
16
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17
 
8 toby 18
# GNU Makefile
19
# builds Win32 DLL and CS2/Mac Mach-O plugin bundle
2 toby 20
 
8 toby 21
# by Toby Thain <toby@telegraphics.com.au>
2 toby 22
 
8 toby 23
 
24
# ---------- variables & flags ----------
25
 
26
EXEC = FilterFoundry
27
 
67 toby 28
VERSION = $(shell perl -n -e 'm/^.*VERSION_STR[[:blank:]]+\"([^"]*)\"/ && print $$1;' version.h)
29
 
8 toby 30
MINGW_CC = i386-mingw32msvc-gcc
31
DLLWRAP  = i386-mingw32msvc-dllwrap
32
WINDRES  = i386-mingw32msvc-windres
33
 
52 toby 34
# use GNU flex and bison
35
# these lines can be commented to use system lex and yacc
36
# although this may result in a larger overall executable
2 toby 37
LEX = flex
38
YACC = bison -y
39
YFLAGS = -d
40
 
64 toby 41
PSAPI = "../Adobe Photoshop CS3 Public Beta SDK/photoshopapi"
8 toby 42
 
23 toby 43
CFLAGS += -O2 -W -Wall -Wno-main -Wno-unused-parameter -Wno-multichar
8 toby 44
CPPFLAGS += -I$(PSAPI)/Pica_sp -I$(PSAPI)/Photoshop -I$(PSAPI)/General \
2 toby 45
	-I../common/adobeplugin -I../common/tt
46
 
47
 
8 toby 48
# ---------- source & object files ----------
2 toby 49
 
8 toby 50
# where to find .c source files
51
vpath %.c ../common/tt ../common/adobeplugin ../MoreFiles/Sources
2 toby 52
 
8 toby 53
# list of source files
54
SRC_COMMON = main.c funcs.c trigtab.c process.c node.c symtab.c sprintf_tiny.c \
55
	ui.c ui_build.c preview.c read.c save.c make.c scripting.c y.tab.c lex.yy.c str.c
56
SRC_OSX = dbg_mac.c ui_mac.c make_mac.c load_mac.c ui_compat_mac.c choosefile_nav.c \
57
	MoreFilesExtras.c MoreFiles.c MoreDesktopMgr.c FileCopy.c Search.c
58
SRC_W32 = dbg_win.c ui_win.c make_win.c load_win.c ui_compat_win.c choosefile_win.c \
59
	ui_build_win.c compat_string.c compat_win.c file_compat_win.c dllmain.c
2 toby 60
 
8 toby 61
# derive lists of object files, separate for each platform
62
OBJ_OSX := $(patsubst %.c, obj/%.o,     $(SRC_COMMON) $(SRC_OSX))
66 toby 63
OBJ_W32 := $(patsubst %.c, obj_w32/%.o, $(SRC_COMMON) $(SRC_W32)) obj_w32/res.o
2 toby 64
 
8 toby 65
 
66
# ---------- executables ----------
67
 
68
# parts of Mac OS X plugin bundle to build
69
# Adobe's plugs use .plugin extension
70
BUNDLE = $(EXEC)_cs2.plugin
71
PLUGIN_OSX  = $(BUNDLE)/Contents/MacOS/$(EXEC)
72
PLUGIN_RSRC = $(BUNDLE)/Contents/Resources/$(EXEC).rsrc
67 toby 73
PLUGIN_PARTS = $(PLUGIN_OSX) $(PLUGIN_RSRC) $(BUNDLE)/Contents/Info.plist $(BUNDLE)/Contents/PkgInfo
74
DISTDMG = dist/$(EXEC)-$(VERSION)-mac_cs2.dmg
8 toby 75
 
66 toby 76
$(PLUGIN_OSX) : CPPFLAGS += -DMAC_ENV -Dmacintosh \
8 toby 77
	-I/Developer/Headers/FlatCarbon \
78
	-I../MoreFiles/CHeaders -I../MoreFiles/Sources
79
 
80
# Win32 plugin DLL to build
23 toby 81
PLUGIN_W32 = $(EXEC).8bf
67 toby 82
DISTZIP = dist/$(EXEC)-$(VERSION)-win.zip
8 toby 83
 
84
$(PLUGIN_W32) : CPPFLAGS += -DWIN_ENV
85
 
86
 
87
# ---------- targets ----------
88
 
89
# build everything
90
all : dll osx
91
 
92
dll : $(PLUGIN_W32)
93
 
66 toby 94
osx fat : $(BUNDLE) $(PLUGIN_OSX) $(PLUGIN_RSRC) $(BUNDLE)/Contents/Info.plist $(BUNDLE)/Contents/PkgInfo
8 toby 95
 
64 toby 96
# See: http://developer.apple.com/documentation/Porting/Conceptual/PortingUnix/compiling/chapter_4_section_3.html#//apple_ref/doc/uid/TP40002850-BAJCFEBA
97
fat : CFLAGS += -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch ppc -arch i386
98
fat : LDFLAGS += -Wl,-syslibroot,/Developer/SDKs/MacOSX10.4u.sdk -arch ppc -arch i386
99
fat : REZFLAGS += -arch ppc -arch i386
100
 
8 toby 101
$(BUNDLE) :
102
	mkdir -p $@
66 toby 103
	/Developer/Tools/SetFile -a B $@
8 toby 104
 
105
# insert correct executable name and version string in bundle's Info.plist
65 toby 106
$(BUNDLE)/Contents/Info.plist : Info.plist $(BUNDLE) version.h
64 toby 107
	mkdir -p $(dir $@)
8 toby 108
	V=`sed -n -E 's/^.*VERSION_STR[[:blank:]]+\"([^"]*)\"/\1/p' version.h` ;\
52 toby 109
		sed -e s/VERSION_STR/$$V/ -e s/EXEC/$(EXEC)/ $< > $@
8 toby 110
 
66 toby 111
$(BUNDLE)/Contents/PkgInfo : $(BUNDLE)
112
	mkdir -p $(dir $@)
113
	echo -n 8BIF8BIM > $@
114
 
2 toby 115
clean :
66 toby 116
	rm -fr *.[ox] $(OBJ_OSX) $(OBJ_W32) $(PLUGIN_W32) $(BUNDLE) \
18 toby 117
	       gentab trigtab.c lex.yy.[ch] y.tab.[ch] temp
2 toby 118
 
8 toby 119
 
67 toby 120
dmg : $(DISTDMG)
2 toby 121
 
67 toby 122
# create an Apple disk image (dmg) archive of the distribution kit
123
$(DISTDMG) : $(PLUGIN_PARTS) dist/README.html dist/gpl.html
124
	@ DIR=`mktemp -d $(EXEC)-XXXX`; \
125
	cp -Rp dist/README.html dist/gpl.html $(BUNDLE) $$DIR; \
126
	mkdir -p $$DIR/examples; \
127
	cp dist/examples/*.afs $$DIR/examples; \
128
	/Developer/Tools/SetFile -t TEXT -c ttxt $$DIR/examples/*; \
129
	hdiutil create -srcfolder $$DIR -ov -volname "$(EXEC) $(VERSION)" $@; \
130
	rm -fr $$DIR
131
	@ ls -l $@
132
 
133
 
134
zip : $(DISTZIP)
135
 
136
$(DISTZIP) : $(PLUGIN_W32) dist/README.html dist/gpl.html dist/examples/*.afs
20 toby 137
	zip -j -9 -r $@ $^
2 toby 138
	ls -l $@
139
 
8 toby 140
dist/gpl.html : 
141
	curl http://www.gnu.org/licenses/gpl.html | \
66 toby 142
		sed -e 's%</HEAD>%<BASE HREF="http://www.gnu.org/"> </HEAD>%' \
143
			-e 's%</head>%<BASE HREF="http://www.gnu.org/"> </HEAD>%' > $@
2 toby 144
 
145
 
8 toby 146
# ---------- compile rules ----------
147
 
148
obj/%.o : %.c
9 toby 149
	$(CC) -o $@ -c $< $(CFLAGS) $(CPPFLAGS) -fpascal-strings
8 toby 150
obj_w32/%.o : %.c
151
	$(MINGW_CC) -o $@ -c $< $(CFLAGS) $(CPPFLAGS)
152
 
153
# note dependencies on version.h:
154
 
155
obj_w32/res.o : win_res.rc PiPL.rc PiPL_body.rc ui_win.rc caution.ico ui.h version.h
156
	$(WINDRES) -o $@ -i $< --language=0 $(CPPFLAGS)
157
 
70 toby 158
lex.yy.c : lexer.l y.tab.h
8 toby 159
	$(LEX) $<
70 toby 160
y.tab.c y.tab.h : parser.y
8 toby 161
	$(YACC) $< $(YFLAGS)
162
 
70 toby 163
obj_w32/funcs.o : ff.h funcs.h symtab.h ui.h PARM.h y.tab.h
164
obj_w32/lex.yy.o : node.h symtab.h y.tab.h
8 toby 165
obj_w32/load_win.o : ff.h funcs.h symtab.h ui.h PARM.h
70 toby 166
obj_w32/main.o : ff.h funcs.h symtab.h ui.h PARM.h node.h scripting.h y.tab.h 
8 toby 167
obj_w32/make.o : ff.h funcs.h symtab.h ui.h PARM.h
168
obj_w32/make_win.o : ff.h funcs.h symtab.h ui.h PARM.h
70 toby 169
obj_w32/node.o : node.h y.tab.h funcs.h symtab.h ui.h PARM.h
170
obj_w32/y.tab.o : node.h y.tab.h
171
obj_w32/preview.o : ff.h funcs.h symtab.h ui.h PARM.h node.h y.tab.h
172
obj_w32/process.o : ff.h funcs.h symtab.h ui.h PARM.h node.h y.tab.h
8 toby 173
obj_w32/read.o : ff.h funcs.h symtab.h ui.h PARM.h
174
obj_w32/save.o : ff.h funcs.h symtab.h ui.h PARM.h
175
obj_w32/scripting.o : ff.h funcs.h symtab.h ui.h PARM.h scripting.h
176
obj_w32/symtab.o : symtab.h
70 toby 177
obj_w32/ui.o : ff.h funcs.h symtab.h ui.h PARM.h node.h y.tab.h
8 toby 178
obj_w32/ui_build.o : ff.h funcs.h symtab.h ui.h PARM.h
179
obj_w32/ui_build_win.o : ff.h funcs.h symtab.h ui.h PARM.h version.h
180
obj_w32/ui_win.o : ff.h funcs.h symtab.h ui.h PARM.h version.h
181
 
70 toby 182
obj/funcs.o : ff.h funcs.h symtab.h ui.h PARM.h y.tab.h
183
obj/lex.yy.o : node.h symtab.h y.tab.h
8 toby 184
obj/load_mac.o : ff.h funcs.h symtab.h ui.h PARM.h
70 toby 185
obj/main.o : ff.h funcs.h symtab.h ui.h PARM.h node.h scripting.h y.tab.h 
8 toby 186
obj/make.o : ff.h funcs.h symtab.h ui.h PARM.h
187
obj/make_mac.o : ff.h funcs.h symtab.h ui.h PARM.h
70 toby 188
obj/node.o : node.h y.tab.h funcs.h symtab.h ui.h PARM.h
189
obj/y.tab.o : node.h symtab.h y.tab.h
190
obj/preview.o : ff.h funcs.h symtab.h ui.h PARM.h node.h y.tab.h
191
obj/process.o : ff.h funcs.h symtab.h ui.h PARM.h node.h y.tab.h
8 toby 192
obj/read.o : ff.h funcs.h symtab.h ui.h PARM.h
193
obj/save.o : ff.h funcs.h symtab.h ui.h PARM.h
194
obj/scripting.o : ff.h funcs.h symtab.h ui.h PARM.h scripting.h
195
obj/symtab.o : symtab.h
70 toby 196
obj/ui.o : ff.h funcs.h symtab.h ui.h PARM.h node.h y.tab.h
8 toby 197
obj/ui_build.o : ff.h funcs.h symtab.h ui.h PARM.h
198
obj/ui_mac.o : ff.h funcs.h symtab.h ui.h PARM.h
199
 
200
gentab : gentab.c funcs.h ; $(CC) -o $@ $< -lm
201
trigtab.c : gentab ; ./gentab > $@
202
 
203
# compile Mac resources (into data fork of .rsrc file)
64 toby 204
$(PLUGIN_RSRC) : $(BUNDLE) PiPL_macho.r ui_mac.r scripting.r ui.h version.h
8 toby 205
	mkdir -p $(dir $@)
64 toby 206
	/Developer/Tools/Rez -o $@ -useDF $(REZFLAGS) $(filter %.r,$^) \
8 toby 207
		-i /Developer/Headers/FlatCarbon \
208
		-i $(PSAPI)/Resources \
209
		-i $(PSAPI)/Photoshop
2 toby 210
	ls -l $@
211
 
212
 
8 toby 213
# ---------- link rules ----------
2 toby 214
 
8 toby 215
# link OS X Mach-O executable
66 toby 216
$(PLUGIN_OSX) : $(BUNDLE) exports.exp $(OBJ_OSX)
8 toby 217
	mkdir -p $(dir $@)
64 toby 218
	$(CC) -bundle -o $@ $(OBJ_OSX) \
219
		$(LDFLAGS) -exported_symbols_list exports.exp \
8 toby 220
		-framework Carbon -framework System
221
	ls -l $@
64 toby 222
	file $@
2 toby 223
 
8 toby 224
# link Win32 DLL
66 toby 225
$(PLUGIN_W32) : exports.def $(OBJ_W32)
8 toby 226
	$(DLLWRAP) -o $@ -def $^ -mwindows -s
227
	ls -l $@
2 toby 228
 
229
 
8 toby 230
# --------------------