9508541ec14722091c1efe98436657b008649250
[libfirm] / MakeRules.in
1 # Hey Emacs, this is a -*- makefile -*-
2 #
3 # libFIRM Project
4 #
5 # $Id$
6 #
7
8 VPATH = $(srcdir)
9
10 SHELL = @CONFIG_SHELL@
11
12 CC = @CC@
13 CFLAGS := @CFLAGS@
14 CPPFLAGS := -I. -I$(topdir) -I$(srcdir) -I$(top_srcdir) @CPPFLAGS@
15
16 INSTALL = @INSTALL@
17 INCLUDEDIR = @includedir@
18 LIBDIR = @libdir@
19
20 DEFS = @DEFS@
21
22 LD := @LD@
23 LDFLAGS := @LDFLAGS@
24 LD_R := @libfirm_cv_prog_ld_r@
25
26 # profiling enabled?
27 ifeq (@enable_profile_libfirm@,yes)
28 LDFLAGS += -g -pg
29 endif
30
31 AR := @AR@
32 ARFLAGS := rc
33
34 RANLIB := @RANLIB@
35
36 DISTFILES = $(SOURCES)
37 CFILES = $(filter %.c,$(SOURCES) $(GENFILES))
38 HFILES = $(filter %.h,$(SOURCES) $(GENFILES))
39 OFILES = $(CFILES:.c=.o)
40
41 TAGFILES = $(CFILES) $(HFILES)
42
43 LDLIBS=$(LIBS) -lm -lc
44
45 COMPILE.c = $(CC) -c $(DEFS) $(CPPFLAGS) $(CDEBUG) $(CFLAGS) $(XCFLAGS)
46 COMPILE.s = $(CC) -S $(DEFS) $(CPPFLAGS) $(CDEBUG) $(CFLAGS) $(XCFLAGS)
47
48 %.o: %.c
49         $(COMPILE.c) -o $@ $<
50
51 %.s: %.c
52         $(COMPILE.s) -o $@ $<
53
54 %.i: %.c
55         $(CPP) $(DEFS) $(CPPFLAGS) -o $@ $<
56
57 %.c: %.dot
58         $(DT) $(DTFLAGS) <$^ >$@ || $(fail)
59
60
61 define fail
62 { $(RM) $@; false; }
63 endef
64
65 # make target given by $@ recursively in $^ ...
66 ifeq (,$(findstring k,$(MAKEFLAGS)))
67 # ... and immediately stop on errors
68 define recurse
69 +@for i in $^ ""; do if test $$i; then $(MAKE) -C $$i $(subst subdir_,,$@) || exit $$?; fi; done
70 endef
71 else
72 # ... and keep going after errors
73 define recurse
74 +@fail=; \
75 for i in $^ ""; do if test $$i; then $(MAKE) -C $$i $(subst subdir_,,$@) || fail=y; fi; done; \
76 test -z "$$fail"
77 endef
78 endif
79
80 targets = all clean depend echodist echogen echosrc realclean tags install