File: Compile.mk

package info (click to toggle)
fbi 2.07-6
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 1,240 kB
  • ctags: 2,357
  • sloc: ansic: 17,896; sh: 59; makefile: 33; perl: 12
file content (102 lines) | stat: -rw-r--r-- 2,197 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#
# some rules to compile stuff ...
#
# (c) 2002-2006 Gerd Hoffmann <kraxel@suse.de>
#
# main features:
#  * autodependencies via "cpp -MD"
#  * fancy, non-verbose output
#
# This file is public domain.  No warranty.  If it breaks you keep
# both pieces.
#
########################################################################

# verbose yes/no
verbose		?= no

# dependency files
tmpdep		= mk/$(subst /,_,$*).tmp
depfile		= mk/$(subst /,_,$*).dep
depfiles	= mk/*.dep

compile_c	= $(CC) $(CFLAGS) -Wp,-MD,$(tmpdep) -c -o $@ $<
compile_c_pic	= $(CC) $(CFLAGS) -fPIC -Wp,-MD,$(tmpdep) -c -o $@ $<
compile_cc	= $(CXX) $(CXXFLAGS) -Wp,-MD,$(tmpdep) -c -o $@ $<
fixup_deps	= sed -e "s|.*\.o:|$@:|" < $(tmpdep) > $(depfile) && rm -f $(tmpdep)
cc_makedirs	= mkdir -p $(dir $@) $(dir $(depfile))

link_app	= $(CC) $(LDFLAGS) -o $@  $^ $(LDLIBS)
link_so		= $(CC) $(LDFLAGS) -shared -Wl,-soname,$(@F) -o $@ $^ $(LDLIBS)
ar_lib		= rm -f $@ && ar -r $@ $^ && ranlib $@

moc_h		= $(MOC) $< -o $@
msgfmt_po	= msgfmt -o $@ $<

# non-verbose output
ifeq ($(verbose),no)
  echo_compile_c	= echo "  CC	 " $@
  echo_compile_c_pic	= echo "  CC	 " $@
  echo_compile_cc	= echo "  CXX	 " $@
  echo_link_app		= echo "  LD	 " $@
  echo_link_so		= echo "  LD	 " $@
  echo_ar_lib		= echo "  AR	 " $@
  echo_moc_h		= echo "  MOC    " $@
  echo_msgfmt_po        = echo "  MSGFMT " $@
else
  echo_compile_c	= echo $(compile_c)
  echo_compile_c	= echo $(compile_c_pic)
  echo_compile_cc	= echo $(compile_cc)
  echo_link_app		= echo $(link_app)
  echo_link_so		= echo $(link_so)
  echo_ar_lib		= echo $(ar_lib)
  echo_moc_h		= echo $(moc_h)
  echo_msgfmt_po	= echo $(msgfmt_po)
endif

%.o: %.c
	@$(cc_makedirs)
	@$(echo_compile_c)
	@$(compile_c)
	@$(fixup_deps)

%.opic: %.c
	@$(cc_makedirs)
	@$(echo_compile_c_pic)
	@$(compile_c_pic)
	@$(fixup_deps)

%.o: %.cc
	@$(cc_makedirs)
	@$(echo_compile_cc)
	@$(compile_cc)
	@$(fixup_deps)

%.o: %.cpp
	@$(cc_makedirs)
	@$(echo_compile_cc)
	@$(compile_cc)
	@$(fixup_deps)


%: %.o
	@$(echo_link_app)
	@$(link_app)

%.so: %.o
	@$(echo_link_so)
	@$(link_so)

%.a: %.o
	@$(echo_ar_lib)
	@$(ar_lib)


%.moc : %.h
	@$(echo_moc_h)
	@$(moc_h)

%.mo : %.po
	@$(echo_msgfmt_po)
	@$(msgfmt_po)