forked from flightno23/OS161
-
Notifications
You must be signed in to change notification settings - Fork 0
/
os161.lib.mk
83 lines (71 loc) · 2.49 KB
/
os161.lib.mk
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
#
# OS/161 build environment: build a library
#
# Usage:
# TOP=../..
# .include "$(TOP)/mk/os161.config.mk"
# [defs go here]
# .include "$(TOP)/mk/os161.lib.mk"
# [any extra rules go here]
#
# Variables controlling this file:
#
# LIB Name of library. We create lib$(LIB).a.
# SRCS .c and .S files to compile.
#
# CFLAGS Compile flags.
#
# LIBDIR Directory under $(OSTREE) to install into,
# e.g. /lib. Should have a leading slash.
#
# Note that individual program makefiles should only *append* to
# CFLAGS, not assign it. Otherwise stuff set by os161.config.mk will
# get lost and bad things will happen.
#
# Because we only build static libs, we can't use and don't need
# LDFLAGS, LIBS, or LIBDEPS. (Shared libs would want these.)
#
LIBDIR?=/lib
_LIB_=lib$(LIB).a
# We may want these directories created. (Used by os161.baserules.mk.)
MKDIRS+=$(MYBUILDDIR)
MKDIRS+=$(INSTALLTOP)$(LIBDIR)
MKDIRS+=$(OSTREE)$(LIBDIR)
# Default rule: create the program.
# (In make the first rule found is the default.)
all: $(MYBUILDDIR) .WAIT $(MYBUILDDIR)/$(_LIB_)
# Now get rules to compile the SRCS.
.include "$(TOP)/mk/os161.compile.mk"
# Further rules for libraries.
#
# Install: we can install into either $(INSTALLTOP) or $(OSTREE).
# When building the whole system, we always install into the staging
# area. We provide the same direct install that os161.prog.mk
# provides; however, because it this doesn't relink anything using the
# library it generally isn't a very useful thing to do. Hence the
# warning.
#
# Note that we make a hard link instead of a copy by default to reduce
# overhead.
#
install-staging: $(INSTALLTOP)$(LIBDIR) .WAIT $(INSTALLTOP)$(LIBDIR)/$(_LIB_)
$(INSTALLTOP)$(LIBDIR)/$(_LIB_): $(MYBUILDDIR)/$(_LIB_)
rm -f $(.TARGET)
ln $(MYBUILDDIR)/$(_LIB_) $(.TARGET) || \
cp $(MYBUILDDIR)/$(_LIB_) $(.TARGET)
install: $(OSTREE)$(LIBDIR) $(MYBUILDDIR)/$(_LIB_)
@echo "Warning: manually installing library without relinking anything"
rm -f $(OSTREE)$(LIBDIR)/$(_LIB_)
ln $(MYBUILDDIR)/$(_LIB_) $(OSTREE)$(LIBDIR)/$(_LIB_) || \
cp $(MYBUILDDIR)/$(_LIB_) $(OSTREE)$(LIBDIR)/$(_LIB_)
# Build the library.
$(MYBUILDDIR)/$(_LIB_): $(OBJS)
rm -f $(.TARGET)
$(AR) -cq $(.TARGET) $(OBJS)
$(RANLIB) $(.TARGET)
# Mark targets that don't represent files PHONY, to prevent various
# lossage if files by those names appear.
.PHONY: all install-staging install
# Finally, get the shared definitions for the most basic rules.
.include "$(TOP)/mk/os161.baserules.mk"
# End.