summaryrefslogtreecommitdiff
path: root/libstd/Makefile
blob: d1e75e2e401e807f6346779736e51e7f40f3814f (plain)
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
SYSLIB=sys
SYSSRC= \
	sys.myr \
	syserrno.myr \
	systypes.myr \
	ifreq.myr \

SYSASMSRC= \
	syscall.s \
	util.s


STDLIB=std
STDSRC= \
	alloc.myr \
	bigint.myr \
	bitset.myr \
	blat.myr \
	bytebuf.myr \
	chartype.myr \
	cmp.myr \
	clear.myr \
	dial.myr \
	die.myr \
	dir.myr \
	dirname.myr \
	endian.myr \
	env.myr \
	errno.myr \
	execvp.myr \
	extremum.myr \
	fltbits.myr \
	fmt.myr \
	fltfmt.myr \
	hashfuncs.myr \
	hasprefix.myr \
	hassuffix.myr \
	htab.myr \
	getint.myr \
	intparse.myr \
	ipparse.myr \
	mk.myr \
	mkpath.myr \
	now.myr \
	option.myr \
	optparse.myr \
	pathjoin.myr \
	putint.myr \
	rand.myr \
	resolve.myr \
	result.myr \
	search.myr \
	slcp.myr \
	sldup.myr \
	sleq.myr \
	slfill.myr \
	sljoin.myr \
	slpush.myr \
	slput.myr \
	slurp.myr \
	sort.myr \
	spork.myr \
	cstrconv.myr \
	strfind.myr \
	strjoin.myr \
	strsplit.myr \
	strstrip.myr \
	syswrap.myr \
	syswrap-ss.myr \
	swap.myr \
	try.myr \
	types.myr \
	units.myr \
	utf.myr \
	varargs.myr \
	wait.myr \

include ../config.mk

all: lib$(STDLIB).a $(MYRBIN)

# HACK HACK HACK.
# Ideally we would have patterns for the
# foo+arch-suffix.myr instead of a loop,
# but that leads to a combinatorial explosion
# of patterns that Make will try, leading to
# millions of files getting statted. This
# works around that.
COPYTARG = for suff in $(SYSCLASS)-$(SYS)-$(ARCH) \
		$(SYSCLASS)-$(SYS) \
		$(SYSCLASS)-$(ARCH) \
		$(SYSCLASS) \
		$(SYS)-$(ARCH) \
		$(SYS) \
		$(ARCH); do \
	    if [ -f $*+$$targ.$$ext ] ; then  \
		echo $$targ; \
		echo cp $*+$$targ.$$ext $@; \
		cp $*+$$targ.$$ext $@; \
		exit 0; \
	    fi; \
	done; \

%.myr: %+*.myr
	@export ext=myr; \
	$(COPYTARG)

%.s: %+*.s
	@export ext=s; \
	$(COPYTARG)

lib$(STDLIB).a: $(STDSRC) $(ASMSRC) lib$(SYSLIB).a ../6/6m
	export MYR_MC=../6/6m && \
	export MYR_MUSE=../muse/muse && \
	./build.sh -l $(STDLIB) $(STDSRC) $(STDASMSRC)

lib$(SYSLIB).a: $(SYSSRC) $(SYSASMSRC) ../6/6m
	export MYR_MC=../6/6m && \
	export MYR_MUSE=../muse/muse && \
	./build.sh -l $(SYSLIB) $(SYSSRC) $(SYSASMSRC)

OBJ=$(STDSRC:.myr=.o) $(SYSSRC:.myr=.o) $(STDASMSRC:.s=.o) $(SYSASMSRC:.s=.o)
USE=$(STDSRC:.myr=.use) $(SYSSRC:.myr=.use) $(STDLIB)
.PHONY: clean check test
clean:
	rm -f $(OBJ)
	rm -f $(USE)
	rm -f lib$(STDLIB).a lib$(SYSLIB).a

install: all
	mkdir -p  $(abspath $(DESTDIR)/$(INST_ROOT)/lib/myr)
	install libstd.a $(abspath $(DESTDIR)/$(INST_ROOT)/lib/myr)
	install libsys.a $(abspath $(DESTDIR)/$(INST_ROOT)/lib/myr)
	install std $(abspath $(DESTDIR)/$(INST_ROOT)/lib/myr)
	install sys $(abspath $(DESTDIR)/$(INST_ROOT)/lib/myr)

uninstall:
	rm -f $(abspath $(DESTDIR)/$(INST_ROOT)/lib/myr/libstd.a)
	rm -f $(abspath $(DESTDIR)/$(INST_ROOT)/lib/myr/std)

check: test

test:
	mbld test

../6/6m:
	cd ..; $(MAKE)