-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.common
94 lines (73 loc) · 1.6 KB
/
Makefile.common
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
## common Makefile
##
## omc - (c) 2006 Alexis Saettler
##
CONFIGMAK := $(SRCDIR)/config.mak
ifeq (,$(wildcard $(CONFIGMAK)))
$(error "$(CONFIGMAK) is not present, run configure !")
endif
include $(CONFIGMAK)
OBJS := $(SRCS:.c=.o)
CFLAGS += $(OPTFLAGS)
CFLAGS += -I.
CFLAGS += -I$(SRCDIR)
##
## default target
##
all:: $(SUBDIRS)
$(SUBDIRS)::
$(MAKE) -C $@
.PHONY: all $(SUBDIRS)
##
## CLEAN targets
##
clean-subdirs := $(addprefix _clean_,$(SUBDIRS))
$(clean-subdirs):
$(MAKE) -C $(patsubst _clean_%,%,$@) clean
clean:: $(clean-subdirs)
ifneq (,$(OBJS))
clean::
$(RM) $(OBJS)
endif
distclean-subdirs := $(addprefix _distclean_,$(SUBDIRS))
$(distclean-subdirs):
$(MAKE) -C $(patsubst _distclean_%,%,$@) distclean
distclean:: $(distclean-subdirs)
# Add clean target to distclean
distclean:: clean
.PHONY: clean $(clean-subdirs) distclean $(distclean-subdirs)
##
## INSTALL targets
##
install-subdirs := $(addprefix _install_,$(SUBDIRS))
$(install-subdirs):
$(MAKE) -C $(patsubst _install_%,%,$@) install
install:: $(install-subdirs)
uninstall-subdirs := $(addprefix _uninstall_,$(SUBDIRS))
$(uninstall-subdirs):
$(MAKE) -C $(patsubst _uninstall_%,%,$@) uninstall
uninstall:: $(uninstall-subdirs)
.PHONY: install $(install-subdirs) uninstall $(uninstall-subdirs)
##
## Common targets
##
%.o:: %.c
$(CC) -c $(CFLAGS) -o $@ $<
$(LIBNAME)::%.a: $(OBJS)
$(AR) r $@ $(OBJS)
$(RANLIB) $@
##
## DEPEND target
##
depend:: .depend
.depend: $(SRCS)
$(CC) -MM $(CFLAGS) $(SRCS) 1>$@
#
# include dependency files if they exist
#
ifneq (,$(wildcard .depend))
include .depend
clean::
$(RM) .depend
endif
.PHONY: depend