File: Makefile.common

package info (click to toggle)
gnucash 1.3.4-3
  • links: PTS
  • area: main
  • in suites: potato
  • size: 9,232 kB
  • ctags: 6,947
  • sloc: ansic: 60,740; lisp: 10,772; sh: 7,437; perl: 3,812; cpp: 2,992; sql: 1,255; makefile: 673
file content (105 lines) | stat: -rw-r--r-- 3,328 bytes parent folder | download
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
103
104
105
### -*-makefile-*- #################################################
##  Makefile.common
##
##  standard targets and rules 
####################################################################

# Autoconf notes...
# Need to handle -MD there.

# COMMON_SRCS: have to be compiled separately for all flavors
#  MOTIF_SRCS: are motif only sources
#  GNOME_SRCS: are gnome only sources
#  INDEP_SRCS: are for flavor independent sources (like engine)

# OBJS is for flavor independent files
# GNOME/MOTIF_OBJS  is for flavor dependent files

OBJS       := $(addprefix obj/,${INDEP_SRCS:.c=.o})
GNOME_OBJS := $(addprefix obj/gnome/,${COMMON_SRCS:.c=.o})
GNOME_OBJS += $(addprefix obj/gnome/,${GNOME_SRCS:.c=.o})
MOTIF_OBJS := $(addprefix obj/motif/,${COMMON_SRCS:.c=.o})
MOTIF_OBJS += $(addprefix obj/motif/,${MOTIF_SRCS:.c=.o})
QT_OBJS    := $(addprefix obj/qt/,${COMMON_SRCS:.c=.o})
QT_OBJS    += $(addprefix obj/qt/,${QT_SRCS:.cpp=.o})

CFLAGS += -pg ${DEFS}

ifdef GNOME_CONFIG_BIN
  GNOME_CFLAGS += $(shell ${GNOME_CONFIG_BIN} --cflags gnomeui)
endif

QT_FLAGS   := 


%.c : %.h

# Basically take the output foo.d file and put it in the right
# subdirectory, adding a prefix indicating where the file actually
# lives (i.e. obj-pic/Foo.cc rather than Foo.cc.  This would all be
# unnecessary if gcc actually paid attention to the argument to "-o".

# Note that this cannot handle subdirs in the Makefile dir, so if the
# relevant Makefile was src/foo/Makefile, this rule can't handle
# src/foo/bar/x.c src/foo/x.c and src/foo/bax/x.c.  You'd need another
# Makefile in src/foo/bar and src/foo/bax for now.

define cleanupdeps
	sed -e "1 s|$(basename $<)\.o|$@|1" $(basename $@).d.tmp > $(basename $@).d
	rm $(basename $@).d.tmp
endef

# Default rule used for non-flavor dependent files (i.e. all of register)
obj/%.o: %.c
	@if [ ! -e $(dir $@) ]; then mkdir -p $(dir $@); fi
	$(CC) -Wp,-MD,$(basename $@).d.tmp -c $(CFLAGS) -o $@ $< 
	${cleanupdeps}

obj/%.o: %.cpp
	@if [ ! -e $(dir $@) ]; then mkdir -p $(dir $@); fi
	g++ -Wp,-MD,$(basename $@).d.tmp -c $(CFLAGS) -o $@ $< 
	${cleanupdeps}


obj/motif/%.o: %.c
	@if [ ! -e $(dir $@) ]; then mkdir -p $(dir $@); fi
	$(CC) -Wp,-MD,$(basename $@).d.tmp -c $(CFLAGS) ${MOTIF_CFLAGS} -DMOTIF -o $@ $< 
	${cleanupdeps}

obj/gnome/%.o: %.c
	@if [ ! -e $(dir $@) ]; then mkdir -p $(dir $@); fi
	$(CC) -Wp,-MD,$(basename $@).d.tmp -c $(CFLAGS) ${GNOME_CFLAGS} -DGNOME -o $@ $< 
	${cleanupdeps}

obj/qt/%.o: %.cpp
	@if [ ! -e $(dir $@) ]; then mkdir -p $(dir $@); fi
	g++ -Wp,-MD,$(basename $@).d.tmp -c $(CFLAGS) ${QT_CFLAGS} -DKDE -o $@ $< 
	${cleanupdeps}

obj/qt/%.o: %.c
	@if [ ! -e $(dir $@) ]; then mkdir -p $(dir $@); fi
	$(CC) -Wp,-MD,$(basename $@).d.tmp -c $(CFLAGS) ${QT_CFLAGS} -DKDE -o $@ $< 
	${cleanupdeps}

clean-files:
	rm -f *~ *.bak \#*
	rm -rf obj
	-rm -rf ${TRASH}

clean: clean-files
	$(foreach dir,${CLEAN_SUBDIRS},(cd ${dir} && $(MAKE) clean);)

distclean: clean-files
	$(foreach dir,${CLEAN_SUBDIRS},(cd ${dir} && $(MAKE) distclean);)
	rm -f Makefile.bak
	rm -f $(foreach f,$(wildcard *.in),$(filter-out configure,$(f:.in=)))
	-rm -rf ${DIST_TRASH}

dist:
	$(foreach dir,${CLEAN_SUBDIRS},(cd ${dir} && $(MAKE) dist);)

.PHONY: clean clean-files dist distclean

# Get dependencies (if existent).

-include $(shell if [ -e obj ]; then find obj -name "*.d"; fi) ""