summaryrefslogtreecommitdiff
path: root/libpsx/Makefile
blob: 740465c4d6a0687efc7fb7c5ca3ba05bb9d17eae (plain) (blame)
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
# Makefile for PSX SDK library

include ../Makefile.cfg

CFLAGS += -Os

# Never remove the line below!
CFLAGS += -D__IN_LIBPSX -ffunction-sections -fdata-sections

OBJS =	$(patsubst src/%.c, out/%.o, $(wildcard src/*.c)) \
		$(patsubst src/libc/%.c, out/libc/%.o, $(wildcard src/libc/*.c)) \
		$(patsubst src/runexe/%.c, out/runexe/%.o, $(wildcard src/runexe/*.c)) \
		$(patsubst src/%.s, out/%.o, $(wildcard src/*.s)) \
		$(patsubst src/runexe/%.s, out/runexe/%.o, $(wildcard src/runexe/*.s))

all: libpsx.a start.o

libpsx.a: $(OBJS)
	$(AR) r libpsx.a $(OBJS)

out/%.o: src/%.c
	@mkdir out -p
	$(CC) $(CFLAGS) -c -o $@ $<

out/libc/%.o: src/libc/%.c
	@mkdir out -p
	@mkdir out/libc -p
	$(CC) $(CFLAGS) -c -o $@ $<

out/runexe/%.o: src/runexe/%.c
	@mkdir out -p
	@mkdir out/runexe -p
	$(CC) $(CFLAGS) -c -o $@ $<

out/%.o: src/%.s
	@mkdir out -p
	$(CC) $(CFLAGS) -c -o $@ $<

out/runexe/%.o: src/runexe/%.s
	@mkdir out -p
	@mkdir out/runexe -p
	$(CC) $(CFLAGS) -c -o $@ $<

start.o: src/start/start.s
	$(CC) $(CFLAGS) -c -o $@ $<

install: libpsx.a start.o
	cp libpsx.a $(TOOLCHAIN_PREFIX)/lib
	cp start.o $(TOOLCHAIN_PREFIX)/lib
	cp -r include/*	$(TOOLCHAIN_PREFIX)/include

clean:
	rm -f $(OBJS)
	rm -f libpsx.a
	rm -f start.o

distclean: clean