1 | # ------------------ # |
---|
2 | # -- NRC Makefile -- # |
---|
3 | # ------------------ # |
---|
4 | |
---|
5 | # Copyright (c) 2000-2007 Lionel Lacassagne |
---|
6 | # with a little help of Stephane Piskorski and Joel Falcou |
---|
7 | |
---|
8 | # -- File list ---------- |
---|
9 | FILE = nralloc1.c, nralloc2.c, nralloc2x.c, nrarith0.c, nrarith1.c, nrarith2.c, nrarith2x.c, nrbool1.c, nrbool2.c, nrio0.c, nrio1.c, nrio1x.c, nrio2.c, nrlinalg.c, nrlut.c, nrmem1.c, nrmem1x.c, nrmem2.c, nrmem2x.c, nrset1.c, nrset2.c, nrset2x.c, nrset3.c nrsort1.c, nrsort2.c, nrwrap1.c, nrwrap2.c |
---|
10 | #FILE := $(FILE), nrio1f.c, nrio1xf.c, nrio2f.c nrio2x.c nrio2xf.c nrio3.c # comment if giet |
---|
11 | |
---|
12 | |
---|
13 | TARGET ?= linux |
---|
14 | |
---|
15 | # -- Paths ---------- |
---|
16 | SRC_PATH = src |
---|
17 | OBJ_PATH = obj |
---|
18 | INC_PATH = include |
---|
19 | PRODUCT = libnrc2x.a |
---|
20 | |
---|
21 | all: checktarget $(PRODUCT) |
---|
22 | |
---|
23 | ifeq ($(TARGET),giet-vm) |
---|
24 | |
---|
25 | CC = mipsel-unknown-elf-gcc |
---|
26 | AR = mipsel-unknown-elf-ar |
---|
27 | RANLIB = mipsel-unknown-elf-ranlib |
---|
28 | AS = mipsel-unknown-elf-as |
---|
29 | OD = mipsel-unknown-elf-objdump |
---|
30 | OCPY = mipsel-unknown-elf-objcopy |
---|
31 | LD = mipsel-unknown-elf-ld |
---|
32 | NM = mipsel-unknown-elf-nm |
---|
33 | |
---|
34 | |
---|
35 | C_DEBUG_FLAGS = -O0 |
---|
36 | C_OPTIMISATION_FLAGS = -std=c99 -O2 -fstrict-aliasing |
---|
37 | C_OS_FLAGS = -DGTODay -DTARGET_OS=GIETVM |
---|
38 | C_CONFIG_FLAGS = -DCLI |
---|
39 | C_INC_FLAGS = -I$(INC_PATH) -I../../.. -I../../../giet_libs |
---|
40 | CFLAGSCPU := -mips32 -EL -G0 -mhard-float -fomit-frame-pointer -fno-builtin -ffreestanding |
---|
41 | |
---|
42 | checktarget: |
---|
43 | @if [ -f $(PRODUCT) ] && objdump -f $(PRODUCT) | grep "little" > /dev/null ; then \ |
---|
44 | echo -ne "" ; \ |
---|
45 | else \ |
---|
46 | rm -f $(OBJS) $(PRODUCT) ;\ |
---|
47 | fi |
---|
48 | endif |
---|
49 | |
---|
50 | ifeq ($(TARGET),linux) |
---|
51 | |
---|
52 | CC = gcc |
---|
53 | LD = gcc |
---|
54 | AR = ar |
---|
55 | RANLIB = ranlib |
---|
56 | |
---|
57 | C_DEBUG_FLAGS = -O0 |
---|
58 | C_OPTIMISATION_FLAGS = -std=c99 -O2 -fstrict-aliasing |
---|
59 | C_OS_FLAGS = -DTARGET_OS=LINUX |
---|
60 | C_CONFIG_FLAGS = -DCLI |
---|
61 | C_INC_FLAGS = -I$(INC_PATH) |
---|
62 | |
---|
63 | checktarget: |
---|
64 | @if [ -f $(PRODUCT) ] && objdump -f $(PRODUCT) | grep "86" > /dev/null ; then \ |
---|
65 | echo -ne "" ; \ |
---|
66 | else \ |
---|
67 | rm -f $(OBJS) $(PRODUCT) ;\ |
---|
68 | fi |
---|
69 | |
---|
70 | endif |
---|
71 | |
---|
72 | |
---|
73 | # -- Flags ---------- |
---|
74 | CFLAGS = $(C_OPTIMISATION_FLAGS) $(C_OS_FLAGS) $(C_INC_FLAGS) |
---|
75 | |
---|
76 | |
---|
77 | #------------------------------------------------------------------------------ |
---|
78 | # CC tools and parameters |
---|
79 | #------------------------------------------------------------------------------ |
---|
80 | |
---|
81 | CFLAGSW := -Wredundant-decls -Wdisabled-optimization -Winline -Wpointer-arith -Wsign-compare -Wendif-labels |
---|
82 | CFLAGS := $(CFLAGS) -g -Wall $(CFLAGSW) $(CFLAGSCPU) |
---|
83 | |
---|
84 | |
---|
85 | |
---|
86 | OBJS = $(addprefix $(OBJ_PATH)/, $(addsuffix .o,$(basename $(FILE)))) |
---|
87 | |
---|
88 | |
---|
89 | $(OBJ_PATH)/%.o: $(SRC_PATH)/%.c $(INC_PATH)/*.h |
---|
90 | $(CC) -c $(CFLAGS) -o $@ $< |
---|
91 | |
---|
92 | |
---|
93 | $(PRODUCT): $(OBJS) |
---|
94 | $(AR) -cr $@ $^ |
---|
95 | $(RANLIB) $@ |
---|
96 | |
---|
97 | clean: |
---|
98 | rm -f $(OBJS) |
---|
99 | rm -f $(PRODUCT) |
---|
100 | |
---|