-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathMakefile
More file actions
96 lines (75 loc) · 2.06 KB
/
Makefile
File metadata and controls
96 lines (75 loc) · 2.06 KB
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
#
# Makefile
#
PROG = shellcode
# you can use command "export CROSS_COMPILE=powerpc-eabi-" instead of
CROSS_COMPILE = powerpc-eabi-
#
AS = $(CROSS_COMPILE)as
LD = $(CROSS_COMPILE)ld
CC = $(CROSS_COMPILE)gcc
CPP = $(CROSS_COMPILE)g++
AR = $(CROSS_COMPILE)ar
NM = $(CROSS_COMPILE)nm
STRIP = $(CROSS_COMPILE)strip
OBJCOPY = $(CROSS_COMPILE)objcopy
OBJDUMP = $(CROSS_COMPILE)objdump
OBJCOPY = $(CROSS_COMPILE)objcopy
STRIP = $(CROSS_COMPILE)strip
LDSTATIC = -static
ELF2ECOFF = ${OBJCOPY} -O ecoff-bigmips
ELF2BIN = ${OBJCOPY} -O binary
TEXTADDR = 0
# strip debug
LINKFLAGS = -Map ${PROG}.map \
--omagic \
--discard-all \
--strip-all \
${LDBUG} \
-Ttext ${TEXTADDR} \
--entry=_start \
${GP} \
-T raw.ld \
-nostdlib -nodefaultlibs
# HAS_STDARG, DUSE_PROTOTYPE, USE_TCL_STUBS are Tcl's macro
DEFS = -D__ASSEMBLY__ -DHAS_STDARG -DUSE_PROTOTYPE -DUSE_TCL_STUBS -DTCL_CISCO
SUBDIRS =
OBJS = crt0.o ${PROG}.o
INCLUDES = -I include/ -I include/libc
LIBS = lib/libc.a
CFLAGS = -Os -mcpu=powerpc -Wa,-mregnames \
-mrelocatable \
-fpic \
-std=c99 \
-fno-keep-inline-functions \
-fomit-frame-pointer \
-nostdinc \
-ffreestanding \
-Wall \
$(INCLUDES)
CPPFLAGS = -O3 -mcpu=powerpc -Wa,-mregnames\
-fpic \
-fno-keep-inline-functions \
-nostdinc \
-Wall \
$(INCLUDES)
ASFLAGS = -x c -traditional-cpp -mregnames
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(CFLAGS) $(ASFLAGS)
CPPCOMPILE = $(CPP) $(INCLUDES) $(CPPFLAGS)
%.o: %.c
$(COMPILE) -c $<
%.o: %.cpp
$(CPPCOMPILE) -c $<
%.o: %.S
$(AS) -mregnames -mrelocatable $< -o $@
${PROG}: crt0.o ${PROG}.o
${LD} ${LINKFLAGS} -o ${PROG}.elf ${OBJS} $(LIBS)
${ELF2BIN} ${PROG}.elf ${PROG}.bin
sub:
@list='$(SUBDIRS)'; \
for subdir in $$list; do \
echo "Making all in $$subdir"; \
(cd $$subdir && $(MAKE)) \
done;
clean:
rm -f *.o *.core ${PROG}.map ${PROG}.elf ${PROG}.bin