1
2COLLECT = ar cru
3RANLIB = ranlib
4LNK = ln -s
5POST = $(fltkconfig) --post
6RPMARCH = `rpmbuild --showrc | awk '/^build arch/ {print $$4}'`
7MSGCAT = msgcat
8MSGFMT = msgfmt -c --statistics
9
10docdir          = $(datadir)/doc/$(TARGET)
11SRCDIR          = $(src_dir)
12BUILDDIR        = $(build_dir)/
13
14
15MAN1 =
16MAN3 =
17DOKU =  AUTHORS \
18        ChangeLog \
19        COPYING \
20        README
21MIME_TYPES = \
22	x-color-cgats.xml \
23	x-color-icc.xml
24
25ICONS = \
26	$(TARGET)_logo.png
27
28DEFAULT_PROFILES = base printing
29
30CONFIG_FILES = \
31	$(SRCDIR)/configure \
32	$(SRCDIR)/configure_tests.sh \
33	$(SRCDIR)/makefile.in \
34	$(SRCDIR)/$(TARGET).spec.in \
35	$(SRCDIR)/$(TARGET)_control.in
36
37ALL_FILES = \
38	$(DOKU) \
39	$(ICONS) \
40	$(MIME_TYPES) \
41	$(MAN1) $(MAN3)
42
43# build all what is needed to run the libraries, helpers
44all:
45	test -d default_profiles && \
46	( cd default_profiles; \
47	for prof in $(DEFAULT_PROFILES); do \
48	     test -d $${prof} && \
49	         echo "$${prof} profiles will be included" || \
50	         echo "$${prof} profile directory is not found - ignoring"; \
51	done; ) || echo "default_profiles directory is not found - ignoring"
52	echo ... $@ done
53
54
55# get time stamp
56MTIME   := $(shell date +%y%m%d.%H%M%S)
57
58# this is a test
59time:
60	echo $(MTIME)
61
62
63# install recursive
64install:	install-main install-icc
65	echo ... $@ done
66
67install-main:	install_mime
68
69install-icc:	install_profiles
70
71install_mime:
72	echo installing mime types into $(DESTDIR)$(datadir)/mime/packages ...
73	mkdir -p $(DESTDIR)$(syscolordir)/$(settingsdirname)
74	mkdir -p $(DESTDIR)$(syscolordir)/$(targetdirname)
75	mkdir -p $(DESTDIR)$(datadir)/mime/packages/
76	for mime in $(MIME_TYPES); do \
77	  $(INSTALL) -m 644 $(SRCDIR)/$${mime} \
78	    $(DESTDIR)$(datadir)/mime/packages/$${mime}; \
79	  if [ -z "$(DESTDIR)" ]; then \
80	    test `which xdg-mime | wc -l` != 0 \
81		  && xdg-mime install $(SRCDIR)/$${mime} \
82		  || echo "no xdg-mime found - skipping"; \
83	  fi; \
84	done
85	echo adding icons to $(DESTDIR)$(pixmapdir) ...
86	mkdir -p $(DESTDIR)$(pixmapdir)
87	mkdir -p $(DESTDIR)$(icondir)
88	echo adding icons to $(DESTDIR)$(icondir) ...
89	$(COPY) $(SRCDIR)/$(TARGET)_logo.png application-vnd.iccprofile.png
90	$(COPY) $(SRCDIR)/$(TARGET)_logo.png text-vnd.cgats.png
91	if [ -z "$(DESTDIR)" ] && [ `which xdg-icon-resource | wc -l` != 0 ]; then \
92	  xdg-icon-resource install --size 128 --novendor application-vnd.iccprofile.png; \
93	  xdg-icon-resource install --size 128 --novendor text-vnd.cgats.png; \
94	fi
95	$(INSTALL) -m 644 application-vnd.iccprofile.png $(DESTDIR)$(icondir)
96	$(LINK) application-vnd.iccprofile.png $(DESTDIR)$(icondir)/text-vnd.cgats.png
97	$(LINK) $(icondir)/application-vnd.iccprofile.png $(DESTDIR)$(pixmapdir)/$(TARGET)_logo.png
98	echo ... done installing mime types and icons
99
100
101
102
103install_profiles:
104	test -d default_profiles && \
105	( cd default_profiles; \
106	for prof in $(DEFAULT_PROFILES); do \
107	     test -d $${prof} && \
108	         (cd $${prof}; $(MAKE) DESTDIR="$(DESTDIR)" SYSCOLORDIR=$(syscolordir) ICCDIRNAME=$(iccdirname) install) || \
109	         echo "$${prof} profile directory is not found - ignoring"; \
110	done; ) || echo "default_profiles directory is not found - ignoring"
111
112
113# build a source distribution package
114dist: targz
115	test -d ../Archiv && mv -v ../Archiv/$(TARGET)-$(MTIME).tgz $(TARGET)-$(VERSION).tar.gz || mv -v $(TARGET)-$(MTIME).tgz $(TARGET)-$(VERSION).tar.gz
116	tar xzf $(TARGET)-$(VERSION).tar.gz
117	tar cjf $(TARGET)-$(VERSION).tar.bz2 $(TARGET)-$(VERSION)/
118	$(RM) -R $(TARGET)-$(VERSION)
119
120dist-gzip:	dist
121
122# build a binary rpm package
123rpm:	dist
124	$(SRCDIR)/configure --prefix=/usr --rpm-only # generate the spec file
125	mkdir -p rpmdir/BUILD \
126	rpmdir/SPECS \
127	rpmdir/SOURCES \
128	rpmdir/SRPMS
129	$(COPY) -f $(TARGET)-$(VERSION).tar.bz2 rpmdir/SOURCES
130	rpmbuild --clean -ba $(build_dir)/$(TARGET).spec --define "_topdir $$PWD/rpmdir"
131	@echo "============================================================"
132	@echo "Finished - the packages are in rpmdir/RPMS and rpmdir/SRPMS!"
133
134deb:	dist
135	$(SRCDIR)/configure --prefix=/usr --rpm-only
136	mkdir -p debian/deb/DEBIAN
137	tar xvzf $(TARGET)-$(VERSION).tar.gz
138	(cd $(TARGET)-$(VERSION); \
139	./configure --prefix=/usr; \
140	make DESTDIR=$(build_dir)/debian/deb/DEBIAN install;)
141	$(COPY) $(TARGET)-$(VERSION)/$(TARGET)_control $(build_dir)/debian/deb/DEBIAN/control
142	$(RM) -R $(TARGET)-$(VERSION)
143	dpkg -b $(build_dir)/debian/deb debian/$(TARGET)_$(VERSION)-$(RELEASE)_$(deb_arch).deb
144	$(RM) -R $(build_dir)/debian/deb
145	echo ... $@ done
146
147# remove everything previously installed
148uninstall:	uninstall-icc
149
150
151uninstall_profiles:
152	echo Uninstalling profiles ...
153	test -d default_profiles && \
154	(  cd default_profiles; \
155	   for prof in $(DEFAULT_PROFILES); do \
156	     test -d $${prof} && \
157	         (cd $${prof}; $(MAKE)  DESTDIR="$(DESTDIR)" SYSCOLORDIR=$(syscolordir) ICCDIRNAME=$(iccdirname) uninstall) || \
158	         echo "$${prof} profile directory is not found - ignoring"; \
159	   done; \
160        ) || echo "no profile directory found"
161	echo ... done uninstalling profiles
162
163uninstall-icc:	uninstall_mime uninstall_profiles
164
165uninstall_mime:
166	echo uninstalling mime types from $(DESTDIR)$(datadir)/mime/packages ...
167	for mime in $(MIME_TYPES); do \
168	  $(RM) $(DESTDIR)$(datadir)/mime/packages/$${mime}; \
169	done
170	echo removing icons from $(DESTDIR)$(pixmapdir) ...
171	$(RM) $(DESTDIR)$(pixmapdir)/$(TARGET)_logo.png
172	echo removing icons from $(DESTDIR)$(icondir) ...
173	$(RM) $(DESTDIR)$(icondir)/text-vnd.cgats.png
174	$(RM) $(DESTDIR)$(icondir)/application-vnd.iccprofile.png
175	echo ... done uninstalling mime types
176
177
178
179# remove in this directory
180distclean: clean
181	-$(RM) Makefile
182	-$(RM) default_profiles/base/Makefile
183	-$(RM) default_profiles/printing/Makefile
184	-$(RM) $(TARGET).spec $(TARGET)-icc.spec
185
186clean:
187	echo ... $@ done
188
189
190
191
192
193# smallest package covering the current directory
194tgz:
195	-test -d Entwickeln && $(RM) -r Entwickeln
196	$(MAKE) DESTDIR=Entwickeln copy_files
197	tar cf - Entwickeln/ \
198	| gzip > $(TARGET)_$(MTIME).tgz
199	-test -d ../Archiv && mv -v $(TARGET)_*.tgz ../Archiv
200	-test -d Entwickeln && \
201	test `pwd` != `(cd Entwickeln; pwd)` && \
202	rm -R Entwickeln
203
204# build the source package including the subdirectories
205targz:
206	test -d $(TARGET)-$(VERSION) && $(RM) -R $(TARGET)-$(VERSION) || echo -e "\c"
207	$(MAKE) DESTDIR=$(build_dir)/$(TARGET)-$(VERSION) copy_files
208	cd default_profiles; \
209	for prof in $(DEFAULT_PROFILES); do \
210	     test -d $${prof} && \
211	         mkdir -p ../$(TARGET)-$(VERSION)/default_profiles/$${prof}; \
212	         (cd $${prof}; echo bin in `pwd`; $(MAKE) DESTDIR=$(build_dir)/$(TARGET)-$(VERSION)/default_profiles/$${prof} copy_files; $(RM) $(build_dir)/$(TARGET)-$(VERSION)/default_profiles/$${prof}/Makefile) || \
213	         echo "$${prof} profile directory is not found - ignoring"; \
214	done;
215	tar cf - $(TARGET)-$(VERSION)/ \
216	| gzip > $(build_dir)/$(TARGET)-$(MTIME).tgz
217	test -d $(build_dir)/$(TARGET)-$(VERSION) && \
218	test `pwd` != `(cd $(build_dir)/$(TARGET)-$(VERSION); pwd)` && \
219	$(RM) -R $(build_dir)/$(TARGET)-$(VERSION)
220	test -d ../Archiv && mv -v $(TARGET)-*.tgz ../Archiv || echo "no copy"
221
222# basic file set
223copy_files:
224	mkdir $(DESTDIR)
225	cd $(SRCDIR) && \
226	  $(COPY) -R $(ALL_FILES) $(DESTDIR)
227	$(COPY) $(CONFIG_FILES) $(DESTDIR)
228	echo ... $@ done
229
230help:
231	echo "... all :        build the binaries"
232	echo "... "
233	echo "... install :    install the binaries, include files and data"
234	echo "... install-icc: install only profiles and targets"
235	echo "... uninstall"
236	echo "... clean :      remove binaries, object files and most processed data"
237	echo "... distclean :  remove all files processed from configure scripts"
238	echo "... rpm :        build RPM's"
239	echo "... dist :       build a distribution tarball and place local"
240	echo "... targz :      build a distribution tar ball"
241	echo "... tgz :        build a development tar ball"
242	echo "... copy_files : copy distribution files to a DESTDIR=xxx path"
243	echo "  VARIABLES:"
244	echo "... DESTDIR=\"/user/a/My Install Dir/\" install"
245	echo "... BUILDDIR=../build_local"
246
247
248