# # $Id: Makefile.Software 138 2010-05-12 17:34:01Z rosiere $ # # [ Description ] # # Makefile # ifeq ($(origin MORPHEO_TOPLEVEL), undefined) $(error "variable MORPHEO_TOPLEVEL is undefined") else include $(MORPHEO_TOPLEVEL)/Makefile.tools endif include $(MORPHEO_TOPLEVEL)/Softwares/Makefile.defs #-----[ Directory ]--------------------------------------------------------------- DIR_OBJ = obj DIR_BIN = bin EXE = soft_$(OS)_$(TARGET) DIR_COMMON = $(MORPHEO_TOPLEVEL)/Softwares/Common DIR_COMMON_C = $(DIR_COMMON)/src/c DIR_COMMON_ASM = $(DIR_COMMON)/src/asm DIR_COMMON_SYS = $(DIR_COMMON)/src/sys DIR_COMMON_INC = $(DIR_COMMON)/include #PREFIX_OBJ = $(OS)_$(TARGET)_ # #SOURCES_COMMON = $(wildcard $(DIR_COMMON_SYS)/*.s)\ # $(wildcard $(DIR_COMMON_ASM)/*.s)\ # $(wildcard $(DIR_COMMON_C)/*.c) # #TEST = $(addprefix $(DIR_OBJ)/$(PREFIX_OBJ), $(addsuffix .o, $(basename $(notdir $(SOURCES_COMMON))))) OBJECTS_COMMON = $(patsubst $(DIR_COMMON_SYS)/%.s,$(DIR_OBJ)/%.o,$(wildcard $(DIR_COMMON_SYS)/*.s))\ $(patsubst $(DIR_COMMON_ASM)/%.s,$(DIR_OBJ)/%.o,$(wildcard $(DIR_COMMON_ASM)/*.s))\ $(patsubst $(DIR_COMMON_C)/%.c,$(DIR_OBJ)/%.o,$(wildcard $(DIR_COMMON_C)/*.c)) #-----[ To the compilation ]------------------------------------------------------ #~~~~~[ OS : Newlib ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ NEWLIB_DIR_LDSCRIPT = $(NEWLIB)/lib/ #NEWLIB_INCDIR #NEWLIB_LIBDIR #NEWLIB_LIBNAME NEWLIB_OBJECTS = $(NEWLIB)/lib/*.o #~~~~~[ OS : UNIX ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ UNIX_DIR_LDSCRIPT = UNIX_INCDIR = UNIX_LIBDIR = UNIX_LIBNAME = -lm UNIX_OBJECTS = #~~~~~[ TARGET : COMMON ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ COMMON_OPTIMIZE = -O3 -std=c99 -Wall -Wlong-long COMMON_CC_OPT = $(INCDIR) -D$(OS) -D$(TARGET) $($(TARGET)_OPTIMIZE) $(FLAGS) COMMON_AS_OPT = COMMON_LD_OPT = $(LIBDIR) $(LIBNAME) -static COMMON_OBJDUMP_OPT = -D COMMON_NM_OPT = -n #~~~~~[ TARGET : MORPHEO ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MORPHEO_OPTIMIZE = $(COMMON_OPTIMIZE) -fomit-frame-pointer -fdelayed-branch -mror -mcmov -msext -mhard-mul -msoft-div -msoft-float #Option : # -fomit-frame-pointer : n'utilise pas le pointeur de frame # -fdelayed-branch : utilise les delayed slot # ON OFF # -mror -mno-ror : utilisation de l'instruction l.ror # -mcmov -mno-cmov : utilisation de l'instruction l.cmov # -msext -mno-sext : utilisation des instructions l.extXX # -mhard-mul -msoft-mul : utilisation du multiplieur materiel # -mhard-div -msoft-div : utilisation du diviseur materiel # -mhard-float -msoft-float : utilisation du flottant materiel # -msibcall -mno-sibcall : Enable sibcall optimization # -mlogue -mno-logue : Schedule pro/epi-logue. # -maj -mno-aj : Use aligned jumps. # Tools PREFIX_MORPHEO = or32-elf- MORPHEO_CC = $(OR1K_BIN)/$(PREFIX_MORPHEO)gcc MORPHEO_AS = $(OR1K_BIN)/$(PREFIX_MORPHEO)as MORPHEO_LD = $(OR1K_BIN)/$(PREFIX_MORPHEO)ld MORPHEO_OBJDUMP = $(OR1K_BIN)/$(PREFIX_MORPHEO)objdump MORPHEO_NM = $(OR1K_BIN)/$(PREFIX_MORPHEO)nm # Tools's option MORPHEO_CC_OPT = $(COMMON_CC_OPT) MORPHEO_AS_OPT = $(COMMON_AS_OPT) MORPHEO_LD_OPT = $(COMMON_LD_OPT) -T$(DIR_LDSCRIPT)/or32.ld $(OR1K_LIBDIR) $(OR1K_LIBNAME) MORPHEO_OBJDUMP_OPT = $(COMMON_OBJDUMP_OPT) MORPHEO_NM_OPT = $(COMMON_NM_OPT) #~~~~~[ TARGET : x86 ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ x86_OPTIMIZE = $(COMMON_OPTIMIZE) x86_CC = gcc x86_AS = as x86_LD = gcc x86_OBJDUMP = objdump x86_NM = nm x86_CC_OPT = $(COMMON_CC_OPT) x86_AS_OPT = $(COMMON_AS_OPT) x86_LD_OPT = $(COMMON_LD_OPT) x86_OBJDUMP_OPT = $(COMMON_OBJDUMP_OPT) x86_NM_OPT = $(COMMON_NM_OPT) #~~~~~[ TARGET : EV67 ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ EV67_OPTIMIZE = $(COMMON_OPTIMIZE) -mtune="ev4" PREFIX_EV67 = alphaev67-unknown-linux-gnu- #PREFIX_EV67 = alpha-unknown-linux-gnu- EV67_CC = $(EV67_BIN)/$(PREFIX_EV67)gcc EV67_AS = $(EV67_BIN)/$(PREFIX_EV67)as EV67_LD = $(EV67_BIN)/$(PREFIX_EV67)gcc EV67_OBJDUMP = $(EV67_BIN)/$(PREFIX_EV67)objdump EV67_NM = $(EV67_BIN)/$(PREFIX_EV67)nm EV67_CC_OPT = $(COMMON_CC_OPT) EV67_AS_OPT = $(COMMON_AS_OPT) EV67_LD_OPT = $(COMMON_LD_OPT) EV67_OBJDUMP_OPT = $(COMMON_OBJDUMP_OPT) EV67_NM_OPT = $(COMMON_NM_OPT) #-----[ Rules ]------------------------------------------------------------------- .PRECIOUS : $(DIR_BIN)/%.x.txt $(DIR_BIN)/%.x $(DIR_OBJ)/%.o vpath %.h $(DIR_INC):$(DIR_COMMON_INC) vpath %.c $(DIR_C):$(DIR_COMMON_C) vpath %.s $(DIR_ASM):$(DIR_SYS):$(DIR_COMMON_ASM):$(DIR_COMMON_SYS) vpath %.o $(DIR_OBJ) vpath %.x $(DIR_BIN) all : $(DIR_BIN)/$(EXE).x $(DIR_BIN)/%.x : $(DIR_BIN) $(DIR_OBJ) @\ $(MAKE) $(OBJECTS); \ $(ECHO) "Linkage : $*.x"; \ $($(TARGET)_LD) -o $@ $(OBJECTS) $($(TARGET)_LD_OPT); \ $(ECHO) "List symbols : $*.x.nm"; \ $($(TARGET)_NM) $($(TARGET)_NM_OPT) $@ > $@.nm; \ $(ECHO) "Display info : $*.x.txt"; \ $($(TARGET)_OBJDUMP) $($(TARGET)_OBJDUMP_OPT) $@ > $@.txt;\ echo $($(GREP) "l.jal 0" $@.txt); $(DIR_OBJ)/%.o : %.s @\ $(ECHO) "Compilation : $*.s"; \ $($(TARGET)_CC) $($(TARGET)_CC_OPT) -o $@ -c $^ ; # $($(TARGET)_CC) $($(TARGET)_CC_OPT) -S -o $@.s -c $^ ; $(DIR_OBJ)/%.o : %.c @\ $(ECHO) "Compilation : $*.c"; \ $($(TARGET)_CC) $($(TARGET)_CC_OPT) -o $@ -c $^ ; # $($(TARGET)_CC) $($(TARGET)_CC_OPT) -S -o $@.s -c $^ ; $(DIR_BIN) $(DIR_OBJ) : @\ $(MKDIR) $@; #-----[ Maintenance ]------------------------------------------------------------- clean : @\ $(ECHO) "Delete temporary files"; \ $(RM) $(DIR_OBJ) \ *~ \ $(DIR_SRC)/*~ \ $(DIR_C)/*~ \ $(DIR_ASM)/*~ \ $(DIR_SYS)/*~ \ $(DIR_INC)/*~ \ $(DIR_LDSCRIPT)/*~ \ clean_all : clean $(RM) $(DIR_BIN) #-----[ Help ]-------------------------------------------------------------------- help : @\ $(ECHO) "";\ $(ECHO) "List of directive : ";\ $(ECHO) " * all : Compile the software";\ $(ECHO) " * clean : Erase all files generates";\ $(ECHO) " * clean_all : Erase all files generates";\ $(ECHO) "";