Makefile.rules
247c2b65
 #
 # $Id$
 #
 #
 # common Makefile rules, included by main Makefile & the  modules
 #
 
 #
ad1e3e5c
 # Uses: NAME, ALLDEP, CC, CFLAGS, DEFS, INCLUDES, LIBS, MKDEP, auto_gen, auto_gen_others,
9de818a2
 # depends, objs, extra_objs, static_modules, static_modules_path
247c2b65
 # (all this must  be defined previously!,  see Makefile.defs & Makefile)
 #
 
 
 
 #implicit rules
04bb7a49
 %.o:%.c  $(ALLDEP)
ad1e3e5c
 	$(CC) $(CFLAGS) $(INCLUDES) $(DEFS) -c $< -o $@
247c2b65
 
 %.d: %.c $(ALLDEP)
ad1e3e5c
 	@set -e; $(MKDEP) $(INCLUDES) $(DEFS) $< \
debad23c
 	|  sed 's#\(\($*D)\)\?$(*F)\)\.o[ :]*#$*.o $@ : #g' > $@; \
247c2b65
 	[ -s $@ ] || rm -f $@
 
 
 # normal rules
dcb5f364
 $(NAME): $(objs) $(ALLDEP)
404073d3
 	$(LD) $(LDFLAGS) $(objs) $(extra_objs) $(LIBS) -o $(NAME) 
247c2b65
 
 
 .PHONY: all
 all: $(NAME) modules
 
 .PHONY: dep
 dep: $(depends)
 
404073d3
 .PHONY: static
 static: $(objs)
 
247c2b65
 .PHONY: clean
054cb6cf
 clean: 
e22bbdb8
 	-@rm -f $(objs) $(NAME) $(objs:.o=.il) 2>/dev/null
e7a9bd30
 	-@for r in $(modules) $(static_modules_path) "" ; do \
a65ed385
 		if [ -d "$$r" ]; then \
e7a9bd30
 			echo "module $$r" ; \
 			$(MAKE) -C $$r clean ; \
 		fi ; \
eddda8ce
 	done 
 	@if [ -n "$(modules)" ]; then \
 		for r in $(utils_compile) "" ; do \
 			if [ -d "$$r" ]; then \
 				 $(MAKE) -C $$r clean ; \
 			fi ; \
 		done \
a65ed385
 	fi
247c2b65
 
 .PHONY: proper
 .PHONY: distclean
 .PHONY: realclean
 proper realclean distclean: clean 
9de818a2
 	-@rm -f $(depends) $(auto_gen) $(auto_gen_others) 2>/dev/null
e7a9bd30
 	-@for r in $(modules) "" ; do \
a65ed385
 		if [ -d "$$r" ]; then \
e7a9bd30
 			 $(MAKE) -C $$r proper ; \
 		fi ; \
 	done 
eddda8ce
 	@if [ -n "$(modules)" ]; then \
 		for r in $(utils_compile) "" ; do \
 			if [ -d "$$r" ]; then \
 				 $(MAKE) -C $$r proper ; \
 			fi ; \
 		done \
 	fi
247c2b65
 
 .PHONY: mantainer-cleaan
 mantainer-clean: distclean
74121cdb
 	-rm -f TAGS tags *.dbg .*.swp
e7a9bd30
 	-@for r in $(modules) "" ; do \
a65ed385
 		if [ -d "$$r" ]; then \
e7a9bd30
 			$(MAKE) -C $$r mantainer-clean; \
 		fi ; \
 	 done 
 
247c2b65
 
 .PHONY: TAGS
 TAGS:
 	$(MKTAGS) 
 	
04bb7a49
 ifeq (,$(MAKECMDGOALS))
a2dd69c1
 -include $(depends)
04bb7a49
 endif
247c2b65
 ifneq (,$(filter-out clean proper distclean realclean mantainer-clean TAGS \
d4f2d8b0
 		tar modules, $(MAKECMDGOALS)))
a2dd69c1
 -include $(depends)
247c2b65
 endif