ifeq ($(LANG),) # Customize for Windows # The MIPS gcc compiler must use the cygwin1.dll that came with the compiler. CC_X86 = cl /O1 /nologo CP = copy RM = del DWIN32 = -DWIN32 BIN_MIPS = ..\gccmips_elf VHDL_DIR = ..\vhdl LINUX_PWD = GCC_MIPS = $(BIN_MIPS)\gcc $(CFLAGS) AS_MIPS = $(BIN_MIPS)\as LD_MIPS = $(BIN_MIPS)\ld DUMP_MIPS = $(BIN_MIPS)\objdump CONVERT_BIN = $(LINUX_PWD)convert_bin.exe else # Customized for Linux # See http://www.opencores.com/projects.cgi/web/mips/linux_tools.htm CC_X86 = gcc -Wall -O -g CP = cp RM = rm -rf DWIN32 = BIN_MIPS = VHDL_DIR = ../vhdl LINUX_PWD = ./ #GCC_MIPS = $(BIN_MIPS)mips-elf-gcc $(CFLAGS) #AS_MIPS = $(BIN_MIPS)mips-elf-as #LD_MIPS = $(BIN_MIPS)mips-elf-ld #DUMP_MIPS = $(BIN_MIPS)mips-elf-objdump GCC_MIPS = mips-uclibc-gcc $(CFLAGS) AS_MIPS = mips-uclibc-as LD_MIPS = mips-uclibc-ld DUMP_MIPS = mips-uclibc-objdump CONVERT_BIN = $(LINUX_PWD)convert_bin.exe #CONVERT_BIN = $(BIN_MIPS)mips-elf-objcopy -I elf32-big -O binary test.axf test.bin endif
一般情况下,linux是有 LANG这个环境变量 而window没有的,所有通过 ifeq ($(LANG),) 是否为空即可判断操作系统。
windows情况下,一般情况是要用cl.exe 编译的,所以要用if 之下 else之上的块。
但是,不一般的情况,比如装个matlab,系统会增加环境变量Lang ,于是, gmake all出错了。
判断方法 echo %LANG% 解决方案: set LANG= (只在当前cmd窗口有效)