Statistics
| Branch: | Revision:

grapes / src / utils.mak @ ef8002fd

History | View | Annotate | Download (1.48 KB)

1 a0384990 Luca Abeni
cc-option = $(shell if $(CC) $(1) -S -o /dev/null -xc /dev/null \
2
              > /dev/null 2>&1; then echo "$(1)"; fi ;)
3
4
ld-option = $(shell if echo "int main(){return 0;}" | \
5
		$(CC) $(CFLAGS) $(1) -o /dev/null -xc - \
6
		> /dev/null 2>&1; then echo "$(1)"; fi ;)
7 3d3def6e Luca Abeni
8 d97b1942 Luca Abeni
-include $(CFGDIR)/config.mk
9 23310237 Luca Abeni
ifdef CROSS_COMPILE
10
CC = $(CROSS_COMPILE)cc
11
AR = $(CROSS_COMPILE)ar
12
LD = $(CROSS_COMPILE)ld
13
endif
14 3d3def6e Luca Abeni
15 b34f7ed8 Luca Abeni
ifndef STATIC_CFLAGS
16 0eefcdd8 Csaba Kiraly
CFLAGS += -g -Wall
17 3d3def6e Luca Abeni
CFLAGS += $(call cc-option, -Wdeclaration-after-statement)
18
CFLAGS += $(call cc-option, -Wno-switch)
19
CFLAGS += $(call cc-option, -Wdisabled-optimization)
20
CFLAGS += $(call cc-option, -Wpointer-arith)
21
CFLAGS += $(call cc-option, -Wredundant-decls)
22
CFLAGS += $(call cc-option, -Wno-pointer-sign)
23
CFLAGS += $(call cc-option, -Wcast-qual)
24
CFLAGS += $(call cc-option, -Wwrite-strings)
25
CFLAGS += $(call cc-option, -Wtype-limits)
26
CFLAGS += $(call cc-option, -Wundef)
27
28
CFLAGS += $(call cc-option, -funit-at-a-time)
29 b34f7ed8 Luca Abeni
else
30
CFLAGS += $(STATIC_CFLAGS)
31
endif
32 3d3def6e Luca Abeni
33 d265f32a Csaba Kiraly
ifdef GPROF
34
CFLAGS += -pg
35
LDFLAGS += -pg
36
endif
37
38 3d137997 Csaba Kiraly
CPPFLAGS = -I$(BASE)/include -I$(BASE)/src
39 3d3def6e Luca Abeni
40 f9d6272b Luca Abeni
LIBCOMMON = libgrapes.a
41 7238266e Csaba Kiraly
COMMON = common.o
42 77a39b7c Luca Abeni
43 3d3def6e Luca Abeni
%.a: $(OBJS)
44 9d684cae Luca Abeni
	$(AR) rcs $@ $^
45 3d3def6e Luca Abeni
46 77a39b7c Luca Abeni
libcommon: $(OBJS)
47 9d684cae Luca Abeni
	$(AR) rcs $(BASE)/src/$(LIBCOMMON) $^
48 7238266e Csaba Kiraly
49
objs.lst: $(OBJS)
50
	echo $(addprefix `pwd`/, $(OBJS)) > objs.lst
51
52
$(COMMON): objs.lst
53 9d684cae Luca Abeni
	$(LD) -r -o $(COMMON) `cat objs.lst`
54 5618ba78 Luca Abeni
clean::
55 3d3def6e Luca Abeni
	rm -f *.a
56
	rm -f *.o
57 7238266e Csaba Kiraly
	rm -f *.lst
58 4876398c Luca Abeni
	rm -f *.d
59 99a59a3d Luca Abeni
60
### Automatic generation of headers dependencies ###
61
%.d: %.c
62
	$(CC) $(CPPFLAGS) -MM -MF $@ $<
63
64
%.o: %.d
65
66
-include $(OBJS:.o=.d)