################################ # Set up your environment here # ################################ PREFIX := /cygdrive/d/CS8900/Quartus_Project/cpu_sdk/uClinux ifndef PREFIX @echo -e "PREFIX MUST be defined, such as /opt/uClinux\n" endif ifndef USERLAND_DIR USERLAND_DIR := $(PREFIX)/userland endif ifndef ROMFSDIR ROMFSDIR = $(PREFIX)/target endif ########################################################################## # niosgnu is defined by the Cygwin envronment. In the Linux environment, # # niosgnu is the same as PREFIX. Also, the Cygwin environment requires # # executable files to have the .exe suffix, which Linux does no require. # ########################################################################## ifndef niosgnu EXECSUFFIX := else EXECSUFFIX := .exe endif ############### # Tool Macros # ############### CROSS := nios-elf- CC := $(CROSS)gcc CXX := $(CROSS)g++ AR := $(CROSS)ar LD := $(CROSS)ld NM := $(CROSS)nm RANLIB := $(CROSS)ranlib STRIPTOOL := $(CROSS)strip ELF2FLT := $(PREFIX)/tools/flat/elf2flt FLATDUMP := $(PREFIX)/tools/flat/flat_dump ROMFSINST := $(PREFIX)/tools/scripts/romfs-inst.sh ############## # DIM - Vars # ############## CPP = yes THREADS = yes SHAREABLE = no IDIR = ./dim MAKE = make EXTRALIBS = FLAGS = LIBFLAGS = #################### # Lib Paths & Libs # #################### LIBGCCDIR := $(shell $(CC) -print-file-name=m32) LIBCDIR := $(PREFIX)/uClibc/lib LIBMDIR := $(shell $(CC) -m32 -print-file-name=libm.a |sed s/libm.a//g) ############### # Tools Flags # ############### DEBUG_FLAGS := -g #WARNING_FLAGS := -Wall -Wstrict-prototypes WARNING_FLAGS := -Wall CFLAGS := -mno-zero-extend -c -m32 -O2 -fno-strength-reduce -nostdinc -funaligned-struct-hack -Wall CFLAGS += $(FLAGS) -I$(LIBCDIR)/../include -I$(LIBGCCDIR)/../include -I$(IDIR) CFLAGS += -D__linux__ -D__VFORK_MACRO__ CFLAGS += -DMIPSEL -DPROTOCOL=1 CFLAGS += -Dunix -Dlinux # Auto-dependency flags: -MM : ignore system includes, -M : include system includes in the dependency DEPFLAGS = -E -MM LDRELOC := -T $(USERLAND_DIR)/linkReloc.ld -r -d LDLOC := -T $(USERLAND_DIR)/linkLoc.ld #CROSS_LDFLAGS := -L- -L$(LIBCDIR) -L$(LIBGCCDIR) -L$(LIBMDIR) CROSS_LDFLAGS := -L$(LIBCDIR) -L$(LIBGCCDIR) -L$(LIBMDIR) CROSS_LDLIBS := -lc -lgcc -lm ifneq ($(SHAREABLE),no) SHAREABLE = yes LIBFLAGS += -shared endif ifneq ($(THREADS),yes) CFLAGS += -DNOTHREADS endif ############################################################################################# # not in use due to makefile_dim, where the rules are defined ############################################################################################# ############################## # Implicit Rules Definitions # ############################## # # Make a relocatable flat file from an ELF file. # STACKSIZE is defined by individual makefiles. # #%.relocbflt : %.relocelf # $(ELF2FLT) -s $(STACKSIZE) -o $@ $< # $(FLATDUMP) -v $@ # # Make a bound-address ELF file required by GDB for debugging the application. # #%.abself : %.o # $(LD) $(LDLOC) -Ttext 0x1000000 -o $@ $^ $(CROSS_LDFLAGS) $(CROSS_LDLIBS) # # Make a relocatable ELF file. # #%.relocelf : %.o # $(LD) $(LDRELOC) -o $@ $^ $(CROSS_LDFLAGS) $(CROSS_LDLIBS) # $(LD) $(LDLOC) -Ttext 0x1000000 -o $(subst relocelf,abself, $@) $^ $(CROSS_LDFLAGS) $(CROSS_LDLIBS) # # Standard stuff: The object file is dependent on the C source and Makefile timestamps # #%.o : %.c Makefile # $(CC) $(CFLAGS) $(DEBUG_FLAGS) $(WARNING_FLAGS) -o $@ $< #%.o : %.cpp Makefile # $(CC) $(CFLAGS) $(DEBUG_FLAGS) $(WARNING_FLAGS) -o $@ $< # # Automatically generate dependencies for the .c source files. # Be sure to omitt debug-level flags as this can produce macro def'n output. # The sed "script" makes the .d (in addition to the .c) file a # target of the dependencies so that the .d file is rebuild if required. # e.g. "X.o: " gets transformed into "X.o X.d: " # #%.d: %.c # $(SHELL) -ec '$(CC) $(DEPFLAGS) $(CFLAGS) -c $< | sed '\''s/\($*\)\.o[ :]*/\1.o $@ : /g'\'' >$@; [ -s $@ ] || rm -f $@'