aboutsummaryrefslogtreecommitdiff
path: root/examples/childexec/makefile
blob: 9cf72188e1df7c1e56877965d40baf58cc79ea49 (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
include ../sdk-common.mk

INCLUDE	 	+= 
LIBDIRS		+= 

LIBS		= -lpsxetc -lpsxgpu -lpsxgte -lpsxspu -lc -lpsxapi

CFLAGS		= -g -O2 -fno-builtin -fdata-sections -ffunction-sections
CPPFLAGS	= $(CFLAGS) -fno-exceptions
AFLAGS		= -g -msoft-float
LDFLAGS		= -g -gc-sections -T $(GCC_BASE)/mipsel-unknown-elf/lib/ldscripts/elf32elmip.x

LDFLAGS_P	= $(LDFLAGS) -Ttext=0x80010000
LDFLAGS_C	= $(LDFLAGS) -Ttext=0x80030000

CC			= $(PREFIX)gcc
LD			= $(PREFIX)ld

all: child parent

child: build/child.o
	$(LD) $(LDFLAGS_C) $(LIBDIRS) build/child.o $(LIBS) -o child.elf
	elf2x child.elf

parent: build/parent.o build/child_exe.o
	$(LD) $(LDFLAGS_P) $(LIBDIRS) build/parent.o build/child_exe.o $(LIBS) -o parent.elf
	elf2x parent.elf
	
build/%.o: %.c
	@mkdir -p $(dir $@)
	$(CC) $(CFLAGS) $(INCLUDE) -c $< -o $@
	
build/%.o: %.s
	@mkdir -p $(dir $@)
	$(CC) $(AFLAGS) $(INCLUDE) -c $< -o $@
	
clean:
	rm -rf build parent.elf parent.exe child.elf child.exe