[581] | 1 | |
---|
| 2 | #------------------------------------------------------------------------------ |
---|
| 3 | # Default plateform architecture and default CPU |
---|
| 4 | #------------------------------------------------------------------------------ |
---|
| 5 | CPU = mipsel |
---|
| 6 | CCTOOLS = /opt/mipsel-toolchain |
---|
| 7 | GIET_DISTRIB= $(PWD)/../.. |
---|
| 8 | |
---|
| 9 | #------------------------------------------------------------------------------ |
---|
| 10 | # CC tools and parameters |
---|
| 11 | #------------------------------------------------------------------------------ |
---|
| 12 | DIR_INC = $(GIET_DISTRIB)/giet_libs |
---|
| 13 | DIR_LIB = $(GIET_DISTRIB)/build/libs |
---|
| 14 | GCC_LIB = $(CCTOOLS)/lib |
---|
| 15 | CC = $(CCTOOLS)/bin/$(CPU)-unknown-elf-gcc |
---|
| 16 | AR = $(CCTOOLS)/bin/$(CPU)-unknown-elf-ar |
---|
| 17 | AS = $(CCTOOLS)/bin/$(CPU)-unknown-elf-as |
---|
| 18 | OD = $(CCTOOLS)/bin/$(CPU)-unknown-elf-objdump |
---|
| 19 | OCPY = $(CCTOOLS)/bin/$(CPU)-unknown-elf-objcopy |
---|
| 20 | LD = $(CCTOOLS)/bin/$(CPU)-unknown-elfld |
---|
| 21 | NM = $(CCTOOLS)/bin/$(CPU)-unknown-elf-nm |
---|
| 22 | |
---|
| 23 | OBJ=$(DIR_LIB)/malloc.o $(DIR_LIB)/stdio.o $(DIR_LIB)/user_barrier.o $(DIR_LIB)/user_lock.o $(DIR_LIB)/stdlib.o $(DIR_LIB)/user_sqt_lock.o |
---|
| 24 | |
---|
| 25 | |
---|
| 26 | BASEDIR := $(PWD) |
---|
| 27 | MACROS := $(BASEDIR)/null_macros/c.m4.null.GIET |
---|
| 28 | M4 := m4 -s -Ulen -Uindex |
---|
| 29 | |
---|
| 30 | CFLAGSW := -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wdisabled-optimization -Winline -Wpointer-arith -Wsign-compare -Wendif-labels |
---|
| 31 | CFLAGSCPU = -mips32 -EL -G0 -mhard-float |
---|
| 32 | CFLAGS := $(CFLAGS) -O2 -g -Wall -fomit-frame-pointer $(CFLAGSW) $(CFLAGSCPU) -I$(DIR_INC) -I$(GIET_DISTRIB) |
---|
| 33 | |
---|
| 34 | |
---|
| 35 | ifneq ($(ADD-LDSCRIPT),) |
---|
| 36 | LDSCRIPT=$(ADD-LDSCRIPT) |
---|
| 37 | else |
---|
| 38 | LDSCRIPT=ocean.ld |
---|
| 39 | endif |
---|
| 40 | |
---|
| 41 | #LDFLAGS := $(LDFLAGS) -L$(DIR_LIB) -L$(GCC_LIB) $(CPU-LFLAGS) -T$(LDSCRIPT) $(OBJ) $(ADD-LIBS) \ |
---|
| 42 | # -lpthread -lgomp -lc $(ADD-LIBS) -lgomp -lpthread -lm -lc -lgcc --hash-style=sysv |
---|
| 43 | LDFLAGS := $(LDFLAGS) -L$(DIR_LIB) -L$(GCC_LIB) $(CPU-LFLAGS) -T$(LDSCRIPT) -lmath $(OBJ) $(ADD-LIBS) |
---|
| 44 | |
---|
| 45 | |
---|
| 46 | |
---|
| 47 | |
---|
| 48 | ifeq ($(TARGET),) |
---|
| 49 | $(error *** Error: Variable TARGET must be defined before calling Makefile.config) |
---|
| 50 | endif |
---|
| 51 | |
---|
| 52 | ifeq ($(OBJS),) |
---|
| 53 | $(error *** Error: Variable OBJS must be defined before calling Makefile.config) |
---|
| 54 | endif |
---|
| 55 | |
---|
| 56 | ifneq ($(CPU),mipsel) |
---|
| 57 | $(error *** Error: Variable CPU must be equal to \'mipsel\' when calling this Makefile) |
---|
| 58 | endif |
---|
| 59 | |
---|
| 60 | |
---|
| 61 | |
---|
| 62 | #------------------------------------------------------------------------------ |
---|
| 63 | # Building rules |
---|
| 64 | #------------------------------------------------------------------------------ |
---|
| 65 | |
---|
| 66 | .PHONY: clean |
---|
| 67 | |
---|
| 68 | |
---|
| 69 | all: $(TARGET) |
---|
| 70 | |
---|
| 71 | $(TARGET): $(OBJS) |
---|
| 72 | $(LD) -o $@ $^ $(LDFLAGS) |
---|
| 73 | |
---|
| 74 | %.h: %.H |
---|
| 75 | $(M4) $(MACROS) $< > $@ |
---|
| 76 | |
---|
| 77 | %.c: %.C $(MACROS) |
---|
| 78 | $(M4) $(MACROS) $< > $@ |
---|
| 79 | |
---|
| 80 | %.o: %.c $(MACROS) |
---|
| 81 | $(CC) -c $(CFLAGS) -o $@ $< |
---|
| 82 | |
---|
| 83 | |
---|
| 84 | clean: |
---|
| 85 | $(RM) -f *.c *.h *.o *.pyc $(TARGET) |
---|
| 86 | |
---|
| 87 | |
---|
| 88 | |
---|