# This file is part of "scramble", a filter plugin for Adobe Photoshop # Copyright (C) 2006 Toby Thain, toby@telegraphics.com.au # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # GNU Makefile # builds Win32 DLL and CS2/Mac Mach-O plugin bundle # by Toby Thain # ---------- variables & flags ---------- EXEC = Scramble MINGW_CC = i386-mingw32msvc-gcc DLLWRAP = i386-mingw32msvc-dllwrap WINDRES = i386-mingw32msvc-windres PSAPI = ../PhotoshopAPI CFLAGS += -O2 -W -Wall -Wno-main -Wno-unused-parameter CPPFLAGS += -I$(PSAPI)/Pica_sp -I$(PSAPI)/Photoshop -I$(PSAPI)/General \ -I../common/adobeplugin -I../common/tt # ---------- source & object files ---------- # where to find .c source files vpath %.c ../common/tt ../common/adobeplugin # list of source files SRC_COMMON = main.c process.c ui.c str.c dprintf.c sprintf_tiny.c SRC_OSX = dbg_mac.c ui_mac.c ui_compat_mac.c SRC_W32 = dbg_win.c ui_win.c ui_compat_win.c compat_string.c compat_win.c dllmain.c # derive lists of object files, separate for each platform OBJ_OSX := $(patsubst %.c, obj/%.o, $(SRC_COMMON) $(SRC_OSX)) OBJ_W32 := $(patsubst %.c, obj_w32/%.o, $(SRC_COMMON) $(SRC_W32)) # ---------- executables ---------- # parts of Mac OS X plugin bundle to build # Adobe's plugs use .plugin extension BUNDLE = $(EXEC)_cs2.plugin PLUGIN_OSX = $(BUNDLE)/Contents/MacOS/$(EXEC) PLUGIN_RSRC = $(BUNDLE)/Contents/Resources/$(EXEC).rsrc $(PLUGIN_OSX) : CPPFLAGS += -DMAC_ENV -DMACMACHO -Dmacintosh \ -I/Developer/Headers/FlatCarbon # Win32 plugin DLL to build PLUGIN_W32 = $(EXEC).8bf DISTARCHIVE = dist/$(EXEC)-win.zip $(PLUGIN_W32) : CPPFLAGS += -DWIN_ENV # ---------- targets ---------- # build everything all : dll osx dll : $(PLUGIN_W32) osx : $(BUNDLE) $(PLUGIN_OSX) $(PLUGIN_RSRC) $(BUNDLE)/Contents/Info.plist $(BUNDLE) : mkdir -p $@ /Developer/Tools/SetFile -a B $(BUNDLE) # insert correct executable name and version string in bundle's Info.plist $(BUNDLE)/Contents/Info.plist : Info.plist version.h V=`sed -n -E 's/^.*VERSION_STR[[:blank:]]+\"([^"]*)\"/\1/p' version.h` ;\ cat $< | sed -e s/VERSION_STR/$$V/ -e s/EXEC/$(EXEC)/ > $@ clean : rm -fr *.[ox] obj/* obj_w32/* $(PLUGIN_W32) $(BUNDLE) dist : $(DISTARCHIVE) $(DISTARCHIVE) : $(PLUGIN_W32) dist/COPYING zip -j -9 -r $@ $^ ls -l $@ dist/gpl.html : curl http://www.gnu.org/licenses/gpl.html | \ sed 's%% %' > $@ # ---------- compile rules ---------- obj/%.o : %.c $(CC) -o $@ -c $< $(CFLAGS) $(CPPFLAGS) obj_w32/%.o : %.c $(MINGW_CC) -o $@ -c $< $(CFLAGS) $(CPPFLAGS) # note dependencies on version.h: obj_w32/res.o : PiPL.rc ui_win.rc ui.h version.h $(WINDRES) -o $@ -i $< $(CPPFLAGS) obj_w32/ui_win.o : version.h # compile Mac resources (into data fork of .rsrc file) $(PLUGIN_RSRC) : PiPL_macho.r ui_mac.r ui.h version.h mkdir -p $(dir $@) /Developer/Tools/Rez -o $@ -useDF $(filter %.r,$^) \ -i /Developer/Headers/FlatCarbon \ -i $(PSAPI)/Resources \ -i $(PSAPI)/Photoshop ls -l $@ # ---------- link rules ---------- # link OS X Mach-O executable $(PLUGIN_OSX) : exports.exp $(OBJ_OSX) $(PLUGIN_RSRC) mkdir -p $(dir $@) $(CC) -bundle -o $@ $(OBJ_OSX) -exported_symbols_list exports.exp \ -framework Carbon -framework System ls -l $@ # link Win32 DLL $(PLUGIN_W32) : exports.def $(OBJ_W32) obj_w32/res.o $(DLLWRAP) -o $@ -def $^ -mwindows -s ls -l $@ # --------------------