comparison Makefile @ 11:4df0dc4dcc3d

Fix automatic dependency generation and improve portability
author Guido Berhoerster <guido+xinhibit-applet@berhoerster.name>
date Fri, 07 Feb 2014 17:54:41 +0100
parents d83540fd999c
children 7379cd513e6d
comparison
equal deleted inserted replaced
10:d3e7ff315d98 11:4df0dc4dcc3d
24 PACKAGE = xinhibit-applet 24 PACKAGE = xinhibit-applet
25 APP_NAME = org.guido-berhoerster.xinhibit-applet 25 APP_NAME = org.guido-berhoerster.xinhibit-applet
26 VERSION = 2 26 VERSION = 2
27 DISTNAME := $(PACKAGE)-$(VERSION) 27 DISTNAME := $(PACKAGE)-$(VERSION)
28 28
29 # gcc, clang, icc
30 MAKEDEPEND.c = $(CC) -MM $(CFLAGS) $(CPPFLAGS)
31 # Sun/Solaris Studio
32 #MAKEDEPEND.c = $(CC) -xM1 $(CFLAGS) $(CPPFLAGS)
33 # X makedepend
34 #MAKEDEPEND.c = makedepend -f- -Y -- $(CFLAGS) $(CPPFLAGS) --
29 INSTALL := install 35 INSTALL := install
30 INSTALL.exec := $(INSTALL) -D -m 0755 36 INSTALL.exec := $(INSTALL) -D -m 0755
31 INSTALL.data := $(INSTALL) -D -m 0644 37 INSTALL.data := $(INSTALL) -D -m 0644
32 PAX := pax 38 PAX := pax
33 GZIP := gzip 39 GZIP := gzip
107 $(INTLTOOL_UPDATE) --dist --gettext-package="$(PACKAGE)" \ 113 $(INTLTOOL_UPDATE) --dist --gettext-package="$(PACKAGE)" \
108 $${lang}; \ 114 $${lang}; \
109 done 115 done
110 116
111 %.o: %.c 117 %.o: %.c
112 $(COMPILE.c) -MD -o $@ $< 118 $(MAKEDEPEND.c) $< | $(SED) -f deps.sed >$*.d
113 @cp $*.d $*.P; \ 119 $(COMPILE.c) -o $@ $<
114 $(SED) -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' -e '/^$$/ d' \
115 -e 's/$$/ :/' < $*.d >> $*.P; \
116 rm -f $*.d
117 120
118 $(foreach section,1 2 3 4 5 6 7 8 9,$(eval $(call generate-manpage-rule,$(section)))) 121 $(foreach section,1 2 3 4 5 6 7 8 9,$(eval $(call generate-manpage-rule,$(section))))
119 122
120 %.desktop: %.desktop.in $(MOFILES) 123 %.desktop: %.desktop.in $(MOFILES)
121 $(INTLTOOL_MERGE) --desktop-style --utf8 po $< $@ 124 $(INTLTOOL_MERGE) --desktop-style --utf8 po $< $@
140 143
141 clean: 144 clean:
142 rm -f $(PACKAGE) $(OBJS) $(POTFILE) $(MOFILES) $(MANPAGES) $(AUTOSTART_FILE) 145 rm -f $(PACKAGE) $(OBJS) $(POTFILE) $(MOFILES) $(MANPAGES) $(AUTOSTART_FILE)
143 146
144 clobber: clean 147 clobber: clean
145 rm -f *.P 148 rm -f $(patsubst %.o,%.d,$(OBJS))
146 149
147 dist: clobber 150 dist: clobber
148 $(PAX) -w -x ustar -s ',.*/\..*,,' -s ',./[^/]*\.tar\.gz,,' \ 151 $(PAX) -w -x ustar -s ',.*/\..*,,' -s ',./[^/]*\.tar\.gz,,' \
149 -s ',\./,$(DISTNAME)/,' . | $(GZIP) > $(DISTNAME).tar.gz 152 -s ',\./,$(DISTNAME)/,' . | $(GZIP) > $(DISTNAME).tar.gz
150 153
151 -include $(patsubst %.o,%.P,$(OBJS)) 154 -include $(patsubst %.o,%.d,$(OBJS))