# This file is part of patharea, a Filter plugin for Adobe(R) Illustrator(R) # Copyright (C) 2005-2013 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 # using gcc: builds Mac OS X Mach-O plugin for Adobe Illustrator CS2, CS3, CS4 # using MinGW (gcc cross-compiler): a Win32 DLL plugin # (DLL should be backwards compatible with Illustrator 8.0 if using v8/9/10 SDK, # or Illustrator 7.0 if using v7 SDK) # (Carbon bundle format plugins for Illustrator 10 on Mac OS X # can be built with Apple MPW, or CodeWarrior.) # by Toby Thain # ---------- variables & flags ---------- EXEC = PathArea VERSION := $(shell sed -n -E 's/^.*VERSION_STR[[:blank:]]+\"([^"]*)\"/\1/p' version.h) DISTARCHIVE = dist/$(EXEC)-$(VERSION)-win.zip # assumes MinGW binaries are found in a directory on your PATH # (e.g., in my case, 'export PATH=$PATH:/opt/mingw/bin' is in my ~/.bash_profile) MINGW_CC = i386-mingw32msvc-gcc DLLWRAP = i386-mingw32msvc-dllwrap WINDRES = i386-mingw32msvc-windres # where to find API in appropriate version of SDK (Mac OS X build) API = "../Adobe Illustrator CS5 SDK/illustratorapi" SDK = -I$(API)/illustrator -I$(API)/illustrator/legacy \ -I$(API)/pica_sp \ -I$(API)/adm -I$(API)/adm/legacy \ -I$(API)/ate # where to find AI7 SDK (Win32 build) #API = ../Illustrator70.SDK/AIPluginAPI #SDK = -I$(API7)/"ADM Headers" -I$(API7)/"Adobe Illustrator Headers" \ # -I$(API7)/"General Headers" -I$(API7)/"Legacy Headers" \ # -I$(API7)/"PICA SP Headers" -I$(API7)/"Undocumented Headers" # Fix glitch in CS4 SDK on case sensitive file systems: # in ../Adobe Illustrator CS4 SDK/illustratorapi/pica_sp/SPProps.h: # change #include "SPMdata.h" # to #include "SPMData.h" CFLAGS += -Wno-unknown-pragmas -O2 CXXFLAGS += -Wno-unknown-pragmas -O2 CPPFLAGS += -DISFILTER -I../common/adobeplugin -I../common/tt $(SDK) REZFLAGS += $(ARCH) \ -d TARGET=\"$(TARGET)\" \ -d PIPL_PLUGIN_NAME=\"$(EXEC)\" \ -i ../common/adobeplugin/aics3 # ---------- source & object files ---------- # where to find .c source files vpath %.c ../common/tt ../common/adobeplugin # list of source files SRC_COMMON = aipluginmain.c main.c str.c SRC_OSX = dbg_mac.c SRC_W32 = dbg_win.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 # .bundle is a good generic extension, but Adobe's plugs use .aip BUNDLE = $(EXEC)_osx.aip PLUGIN_OSX = $(BUNDLE)/Contents/MacOS/$(EXEC) PLUGIN_RSRC = $(BUNDLE)/Contents/Resources/$(EXEC).rsrc PLUGIN_PARTS = $(PLUGIN_OSX) $(PLUGIN_RSRC) $(BUNDLE)/Contents/Info.plist $(BUNDLE)/Contents/PkgInfo SHORTTARGET := $(shell grep -s -o 'CS[0-9,]' $(BUNDLE)/Contents/Info.plist) DISTDMG = dist/$(EXEC)-$(SHORTTARGET)-$(VERSION).dmg # use CS2 API for the OS X Mach-O build $(PLUGIN_OSX) : CPPFLAGS += -DMAC_ENV -DMACMACHO -I/Developer/Headers/FlatCarbon $(PLUGIN_OSX) : CXXFLAGS += $(ARCH) $(PLUGIN_OSX) : LDFLAGS += $(ARCH) # Win32 plugin DLL to build PLUGIN_W32 = $(EXEC).aip $(PLUGIN_W32) : CPPFLAGS += -DWIN_ENV # ---------- targets ---------- .PHONY : thin cs2 cs3 cs5 dll clean zip dmg thin cs2 cs3 cs5 : $(PLUGIN_PARTS) # See: http://developer.apple.com/documentation/Porting/Conceptual/PortingUnix/compiling/chapter_4_section_3.html#//apple_ref/doc/uid/TP40002850-BAJCFEBA # Note that SDKs may be installed under /SDKs rather then /Developer/SDKs # CS2 Min system req: 10.2.8, 10.3 + G4/G5 cs2 : ARCH = -arch ppc cs2 : CXXFLAGS += -isystem /Developer/SDKs/MacOSX10.2.8.sdk cs2 : LDFLAGS += -Wl,-syslibroot,/Developer/SDKs/MacOSX10.2.8.sdk cs2 : TARGET = "Built for Illustrator CS2 (PowerPC)" # CS3 Min system req: 10.4.8, 10.5 + G4/G5/Intel # CS4 Min system req: 10.4.11, 10.5.4 + G4/G5/Intel cs3 : ARCH = -arch ppc -arch i386 cs3 : CXXFLAGS += -isysroot /Developer/SDKs/MacOSX10.4u.sdk cs3 : LDFLAGS += -Wl,-syslibroot,/Developer/SDKs/MacOSX10.4u.sdk cs3 : TARGET = "For Illustrator CS3,4 (Intel, PowerPC)" # CS5 Min system req: 10.5.7, 10.6 + Intel cs5 : ARCH = -arch i386 cs5 : CXXFLAGS += -isysroot /Developer/SDKs/MacOSX10.5.sdk cs5 : LDFLAGS += -Wl,-syslibroot,/Developer/SDKs/MacOSX10.5.sdk cs5 : TARGET = "For Illustrator CS5 (Intel)" # CS6 Min system req: 10.6.8, 10.7 + Intel 64 bit #cs6 : ARCH = -arch x86_64 #cs6 : TARGET = "For Illustrator CS6 (Intel 64-bit)" # build OS X Mach-O (bundle) format plugin #thin cs2 cs3 cs5 cs6 : $(PLUGIN_PARTS) $(BUNDLE) : mkdir $@ /Developer/Tools/SetFile -a B $@ # insert correct executable name and version string in bundle's Info.plist $(BUNDLE)/Contents/Info.plist : Info.plist.tmpl version.h $(BUNDLE) mkdir -p $(dir $@) sed -e s/%VERSION_STR%/$(VERSION)/ \ -e s/%EXEC%/$(EXEC)/ \ -e s@%TARGET%@$(TARGET)@ \ $< > $@ $(BUNDLE)/Contents/PkgInfo : $(BUNDLE) mkdir -p $(dir $@) printf ARPIART5 > $@ dll : $(PLUGIN_W32) zip : $(DISTARCHIVE) $(DISTARCHIVE) : $(PLUGIN_W32) dist/README.html dist/COPYING.txt zip -9 $@ $^ ls -l $@ clean : rm -fr obj/* obj_w32/* $(PLUGIN_W32) $(BUNDLE) dmg : $(DISTDMG) # create an Apple disk image (dmg) archive of the distribution kit $(DISTDMG) : $(PLUGIN_PARTS) dist/README.html dist/COPYING.txt DIR=`mktemp -d $(EXEC)-XXXX`; \ cp -p dist/README.html dist/COPYING.txt $$DIR; \ cp -Rp $(BUNDLE) $$DIR/"$(EXEC) ($(SHORTTARGET)).aip"; \ hdiutil create -srcfolder $$DIR -ov -volname "$(EXEC) $(VERSION)" $@; \ rm -fr $$DIR @ ls -l $@ # ---------- compile rules ---------- obj/%.o : %.c $(CXX) -o $@ -c $< $(CXXFLAGS) $(CPPFLAGS) obj_w32/%.o : %.c $(MINGW_CC) -o $@ -c $< $(CFLAGS) $(CPPFLAGS) # compile Windows 'PIPL' resource (including version info) obj_w32/res.o : PiPL.rc version.h $(WINDRES) -i $< -o $@ obj/main.o : common.h version.h obj_w32/main.o : common.h version.h # compile Mac resources (into data fork of .rsrc file) $(PLUGIN_RSRC) : $(BUNDLE) PiPL_macho.r version.r version.h mkdir -p $(dir $@) /Developer/Tools/Rez -o $@ $(filter %.r,$^) -useDF \ $(REZFLAGS) \ -i /Developer/Headers/FlatCarbon # ---------- link rules ---------- # final link step for OS X Mach-O executable $(PLUGIN_OSX) : $(BUNDLE) exports.exp $(OBJ_OSX) mkdir -p $(dir $@) $(CXX) -bundle -o $@ $(OBJ_OSX) $(LDFLAGS) \ -exported_symbols_list exports.exp \ -framework Carbon -framework System ls -l $@ # final link step for Win32 DLL $(PLUGIN_W32) : exports.def $(OBJ_W32) obj_w32/res.o $(DLLWRAP) -o $@ -def $^ --driver-name=$(MINGW_CC) -s -mwindows ls -l $@ # --------------------