forked from flightno23/OS161
-
Notifications
You must be signed in to change notification settings - Fork 0
/
os161.prog.mk
83 lines (71 loc) · 2.5 KB
/
os161.prog.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 program
#
# Usage:
# TOP=../..
# .include "$(TOP)/mk/os161.config.mk"
# [defs go here]
# .include "$(TOP)/mk/os161.prog.mk"
# [any extra rules go here]
#
# Variables controlling this file:
#
# PROG Name of program to generate.
# SRCS .c and .S files to compile.
#
# CFLAGS Compile flags.
# LDFLAGS Link flags.
# LIBS Libraries to link with.
# LIBDEPS Full paths of LIBS for depending on.
#
# BINDIR Directory under $(OSTREE) to install into,
# e.g. /bin. Should have a leading slash.
#
# Note that individual program makefiles should only *append* to
# CFLAGS, LDFLAGS, LIBS, and LIBDEPS, not assign them. Otherwise stuff
# set by os161.config.mk will get lost and bad things will happen.
#
BINDIR?=/bin
# We may want these directories created. (Used by os161.baserules.mk.)
MKDIRS+=$(MYBUILDDIR)
MKDIRS+=$(INSTALLTOP)$(BINDIR)
MKDIRS+=$(OSTREE)$(BINDIR)
# Default rule: create the program.
# (In make the first rule found is the default.)
all: $(MYBUILDDIR) .WAIT $(MYBUILDDIR)/$(PROG)
# Now get rules to compile the SRCS.
.include "$(TOP)/mk/os161.compile.mk"
# Further rules for programs.
# Clean: delete extraneous files.
clean: cleanprog
cleanprog:
rm -f $(MYBUILDDIR)/$(PROG)
#
# Install: we can install into either $(INSTALLTOP) or $(OSTREE).
# When building the whole system, we always install into the staging
# area. However, if you're working on a particular program it is
# usually convenient to be able to install it directly to $(OSTREE)
# instead of doing a complete top-level install.
#
# Note that we make a hard link instead of a copy by default to reduce
# overhead.
#
install-staging: $(INSTALLTOP)$(BINDIR) .WAIT $(INSTALLTOP)$(BINDIR)/$(PROG)
$(INSTALLTOP)$(BINDIR)/$(PROG): $(MYBUILDDIR)/$(PROG)
rm -f $(.TARGET)
ln $(MYBUILDDIR)/$(PROG) $(.TARGET) || \
cp $(MYBUILDDIR)/$(PROG) $(.TARGET)
install: install-prog
install-prog: $(OSTREE)$(BINDIR) $(MYBUILDDIR)/$(PROG)
rm -f $(OSTREE)$(BINDIR)/$(PROG)
ln $(MYBUILDDIR)/$(PROG) $(OSTREE)$(BINDIR)/$(PROG) || \
cp $(MYBUILDDIR)/$(PROG) $(OSTREE)$(BINDIR)/$(PROG)
# Link the program.
$(MYBUILDDIR)/$(PROG): $(OBJS) $(LIBDEPS)
$(LDCC) $(LDFLAGS) $(OBJS) $(LIBS) $(MORELIBS) -o $(.TARGET)
# Mark targets that don't represent files PHONY, to prevent various
# lossage if files by those names appear.
.PHONY: all clean cleanprog install-staging install install-prog
# Finally, get the shared definitions for the most basic rules.
.include "$(TOP)/mk/os161.baserules.mk"
# End.