Statistics
| Branch: | Revision:

grapes / src / utils.mak @ 26e69d1e

History | View | Annotate | Download (1.49 KB)

1
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) $(LDFLAGS) $(CFLAGS) $(1) -o /dev/null -xc - \
6
		> /dev/null 2>&1; then echo "$(1)"; fi ;)
7

    
8
-include $(CFGDIR)/config.mk
9
ifdef CROSS_COMPILE
10
CC = $(CROSS_COMPILE)cc
11
AR = $(CROSS_COMPILE)ar
12
LD = $(CROSS_COMPILE)ld
13
endif
14

    
15
ifndef STATIC_CFLAGS
16
CFLAGS += -g -Wall
17
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
else
30
CFLAGS += $(STATIC_CFLAGS)
31
endif
32

    
33
ifdef GPROF
34
CFLAGS += -pg
35
LDFLAGS += -pg
36
endif
37

    
38
CPPFLAGS = -I$(BASE)/include -I$(BASE)/src
39

    
40
LIBCOMMON = libgrapes.a
41
COMMON = common.o
42

    
43
%.a: $(OBJS)
44
	$(AR) rcs $@ $^
45

    
46
libcommon: $(OBJS)
47
	$(AR) rcs $(BASE)/src/$(LIBCOMMON) $^
48

    
49
objs.lst: $(OBJS)
50
	echo $(addprefix `pwd`/, $(OBJS)) > objs.lst
51

    
52
$(COMMON): objs.lst
53
	$(LD) -r -o $(COMMON) `cat objs.lst`
54
clean::
55
	rm -f *.a
56
	rm -f *.o
57
	rm -f *.lst
58
	rm -f *.d
59

    
60
### Automatic generation of headers dependencies ###
61
%.d: %.c
62
	$(CC) $(CPPFLAGS) -MM -MF $@ $<
63

    
64
%.o: %.d
65

    
66
-include $(OBJS:.o=.d)