forked from cvjena/nice-core
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile.inc
More file actions
97 lines (81 loc) · 3.71 KB
/
Copy pathMakefile.inc
File metadata and controls
97 lines (81 loc) · 3.71 KB
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
# LIBRARY-DIRECTORY-MAKEFILE
# conventions:
# - all subdirectories containing a "Makefile.inc" are considered sublibraries
# exception: "progs/" and "tests/" subdirectories!
# - all ".C", ".cpp" and ".c" files in the current directory are linked to a
# library
# - the library depends on all sublibraries
# - the library name is created with $(LIBNAME), i.e. it will be somehow
# related to the directory name and with the extension .a
# (e.g. lib1/sublib -> lib1_sublib.a)
# - the library will be added to the default build list ALL_LIBRARIES
# --------------------------------
# - remember the last subdirectory
#
# set the variable $(SUBDIR) correctly to the current subdirectory. this
# variable can be used throughout the current makefile.inc. The many
# SUBDIR_before, _add, and everything are only required so that we can recover
# the previous content of SUBDIR before exitting the makefile.inc
SUBDIR_add:=$(dir $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)))
SUBDIR_before:=$(SUBDIR)
SUBDIR:=$(strip $(SUBDIR_add))
SUBDIR_before_$(SUBDIR):=$(SUBDIR_before)
ifeq "$(SUBDIR)" "./"
SUBDIR:=
endif
# ------------------------
# - include subdirectories
#
# note the variables $(SUBDIRS_OF_$(SUBDIR)) are required later on to recover
# the dependencies automatically. if you handle dependencies on your own, you
# can also dump the $(SUBDIRS_OF_$(SUBDIR)) variable, and include the
# makefile.inc of the subdirectories on your own...
SUBDIRS_OF_$(SUBDIR):=$(patsubst %/Makefile.inc,%,$(wildcard $(SUBDIR)*/Makefile.inc))
include $(SUBDIRS_OF_$(SUBDIR):%=%/Makefile.inc)
# ----------------------------
# - include local dependencies
#
# you can specify libraries needed by the individual objects or by the whole
# directory. the object specific additional libraries are only considered
# when compiling the specific object files
# TODO: update documentation...
-include $(SUBDIR)libdepend.inc
$(foreach d,$(filter-out %progs %tests,$(SUBDIRS_OF_$(SUBDIR))),$(eval $(call PKG_DEPEND_INT,$(d))))
# ---------------------------
# - objects in this directory
#
# the use of the variable $(OBJS) is not mandatory. it is mandatory however
# to update $(ALL_OBJS) in a way that it contains the path and name of
# all objects. otherwise we can not include the appropriate .d files.
OBJS:=$(patsubst %.cpp,$(OBJDIR)%.o,$(notdir $(wildcard $(SUBDIR)*.cpp))) \
$(patsubst %.C,$(OBJDIR)%.o,$(notdir $(wildcard $(SUBDIR)*.C))) \
$(patsubst %.c,$(OBJDIR)%.o,$(notdir $(wildcard $(SUBDIR)*.c)))
ALL_OBJS += $(OBJS)
# ----------------------------
# - binaries in this directory
#
# output of binaries in this directory. none of the variables has to be used.
# but everything you add to $(ALL_LIBRARIES) and $(ALL_BINARIES) will be
# compiled with `make all`. be sure again to add the files with full path.
LIBRARY_BASENAME:=$(call LIBNAME,$(SUBDIR))
ifneq "$(SUBDIR)" ""
ALL_LIBRARIES+=$(LIBDIR)$(LIBRARY_BASENAME).$(LINK_FILE_EXTENSION)
endif
# ---------------------
# - binary dependencies
#
# there is no way of determining the binary dependencies automatically, so we
# follow conventions. the current library depends on all sublibraries.
# all other dependencies have to be added manually by specifying, that the
# current .pc file depends on some other .pc file. binaries depending on
# libraries should exclusivelly use the .pc files as well.
$(LIBDIR)$(LIBRARY_BASENAME).a:$(OBJS) \
$(call PRINT_INTLIB_DEPS,$(PKGDIR)$(LIBRARY_BASENAME).a,.$(LINK_FILE_EXTENSION))
$(PKGDIR)$(LIBRARY_BASENAME).pc: \
$(call PRINT_INTLIB_DEPS,$(PKGDIR)$(LIBRARY_BASENAME).pc,.pc)
# -------------------
# - subdir management
#
# as the last step, always add this line to correctly recover the subdirectory
# of the makefile including this one!
SUBDIR:=$(SUBDIR_before_$(SUBDIR))