Debian Codegraph @

macosx/build/Makefile

raw
1 # tools
2
3 MAKE=make
4 XCODEBUILD=xcodebuild
5 PRODUCTBUILD=productbuild
6 PKGBUILD=pkgbuild
7
8 # prefix
9
10 PREFIX=/usr/local/graphviz
11 ifeq "$(PREFIX)" "/Applications/Graphviz.app/Contents/Frameworks"
12 RPATH=@executable_path/../Frameworks/lib
13 else
14 RPATH="$(PREFIX)/lib"
15 endif
16
17 # base
18
19 GV_DIR=../..
20 DOT=dot
21
22 UNAME_M:=$(shell uname -m)
23 ARCH=-arch $(UNAME_M)
24
25 #
26 # Graphviz and App installer package
27 #
28 # Note: the check function in Distribution.xml specifies the minimum macOS
29 # version, which should match the Graphviz.app project's deployment target.
30 #
31 # Note: the Component.plist file specifies BundleIsRelocatable = false,
32 # which forces the app bundle into /Applications. Otherwise, the macOS
33 # installer, finding the Release build of Graphviz.app registered and
34 # acceptable, DOES NOT install Graphviz.app into /Applications, and WORSE
35 # sets the Release build app's user/group to root/wheel!! Subsequently,
36 # cleanup requires sudo to remove the Release build >:(
37 #
38
39 graphviz-$(UNAME_M).pkg: Distribution.xml app.pkg dot.pkg
40 @echo
41 @echo PACKAGING GRAPHVIZ...
42 @echo
43 "$(PRODUCTBUILD)" --package-path . --distribution $< $@
44
45 app.pkg: Component.plist Release/Graphviz.app
46 @echo
47 @echo PACKAGING APP...
48 @echo
49 rm -rf Release/Graphviz.app.dSYM
50 "$(PKGBUILD)" --root Release --install-location /Applications --identifier com.att.graphviz.app --component-plist $< $@
51
52 dot.pkg: .$(PREFIX)/bin/$(DOT) Scripts/postinstall
53 @echo
54 @echo PACKAGING DOT...
55 @echo
56 "$(PKGBUILD)" --root .$(PREFIX) --install-location $(PREFIX) --scripts Scripts --identifier com.att.graphviz $@
57
58 .$(PREFIX)/bin/$(DOT): $(GV_DIR)/cmd/dot/.libs/$(DOT)
59 @echo
60 @echo INSTALLING GRAPHVIZ...
61 @echo
62 $(MAKE) DESTDIR=$(CURDIR) -C $(GV_DIR) install-strip
63 rm -rf .$(PREFIX)/lib/*.la
64 rm -rf .$(PREFIX)/lib/graphviz/*.la
65 rm -rf .$(PREFIX)/lib/graphviz/tcl/libtcldot_builtin.*
66 cd .$(PREFIX)/bin; find . -type f -maxdepth 1 | while read a;do dyld_info -linked_dylibs $$a | sed -n -E "s|($(PREFIX))(.*)|\1\2 @executable_path/..\2 $$a|p";done | xargs -t -L1 install_name_tool -change
67 cd .$(PREFIX)/lib; find . -type f -maxdepth 1 | while read a;do dyld_info -linked_dylibs $$a | sed -n -E "s|($(PREFIX)/lib)(.*)|\1\2 @loader_path\2 $$a|p";done | xargs -t -L1 install_name_tool -change
68 cd .$(PREFIX)/lib/graphviz; find . -type f -maxdepth 1 | while read a;do dyld_info -linked_dylibs $$a | sed -n -E "s|($(PREFIX)/lib)(.*)|\1\2 @loader_path/..\2 $$a|p";done | xargs -t -L1 install_name_tool -change
69
70 Release/Graphviz.app: ../*.m ../*.h $(GV_DIR)/cmd/dot/.libs/$(DOT)
71 @echo
72 @echo BUILDING GRAPHVIZ GUI...
73 @echo
74 "$(XCODEBUILD)" -project ../graphviz.xcodeproj -configuration Release VALID_ARCHS=$(UNAME_M) ALWAYS_SEARCH_USER_PATHS=NO MACOSX_DEPLOYMENT_TARGET=10.13 LD_RUNPATH_SEARCH_PATHS=$(RPATH)
75 cd $@/Contents/MacOS; dyld_info -linked_dylibs Graphviz | sed -n -E "s|($(PREFIX)/lib)(.*)|\1\2 @rpath\2 Graphviz|p" | xargs -t -L1 install_name_tool -change
76 codesign -s "-" -fv $@/Contents/MacOS/Graphviz
77
78 Scripts/postinstall:
79 @echo
80 @echo SCRIPTING POSTINSTALL...
81 @echo
82 mkdir -p $(@D)
83 echo '#!/bin/sh' >$@
84 echo 'logger -is -t "Graphviz Install" "register dot plugins"' >>$@
85 echo '"$(PREFIX)/bin/dot" -c' >>$@
86 ifeq "$(PREFIX)" "/usr/local"
87 echo 'rm -f /etc/paths.d/graphviz' >>Scripts/postinstall
88 else
89 echo 'echo "$(PREFIX)/bin" >/etc/paths.d/graphviz' >>Scripts/postinstall
90 endif
91 chmod 755 $@
92
93 $(GV_DIR)/cmd/dot/.libs/$(DOT): $(GV_DIR)/Makefile
94 @echo
95 @echo MAKING GRAPHVIZ...
96 @echo
97 if [[ -e $@ ]]; then $(MAKE) -C $(GV_DIR) clean; fi
98 $(MAKE) -C $(GV_DIR)/tclpkg/tclstubs
99 $(MAKE) -C $(GV_DIR)
100
101 $(GV_DIR)/Makefile Distribution.xml: $(GV_DIR)/configure Distribution.xml.in
102 @echo
103 @echo CONFIGURING GRAPHVIZ...
104 @echo
105 cd $(GV_DIR) && ./configure --prefix=$(PREFIX) --enable-swig=no --disable-dependency-tracking --with-ipsepcola --with-quartz --with-smyrna=no --disable-perl CFLAGS="-O2 $(ARCH)" CXXFLAGS="-O2 $(ARCH)" OBJCFLAGS="-O2 $(ARCH)" LDFLAGS="$(ARCH) -Wl,-dead_strip"
106
107 .PHONY: clean
108 clean:
109 rm -rf Distribution.xml graphviz.build Scripts Release SharedPrecompiledHeaders XCBuildData .$(PREFIX) *.pkg
110 $(MAKE) -C $(GV_DIR) clean
111
112 .PHONY: distclean
113 distclean: clean
114 $(MAKE) -C $(GV_DIR) distclean