0
我是Mac OS新手,想要執行以下makefile程序。這被在Mac OS執行mac OS上的Makefile命令顯示不正確的輸出
GCCBASE = $(GCMDIR)/where/cplusplus/gcc
SRCS:=$(wildcard *.cpp) program.cpp
OBJS:=$(SRCS:.cpp=$(OBJDIR).o)
INCLUDES:=-I. -I$(ADD_INCLUDES)/Auto*.h -I$(ADD_INCLUDES)/program.h
OUTBASE =$(OUTBASE_EX)
OUT_ARTIFACT=Program
ifeq ($(OSNAME),Linux)
ifeq ($(GFLIB_MODEL),64bit)
CXXEXTRA_FLAGS = -m64
GCCDIR = $(GCCBASE)/linux64/4.5.3
GCCLIBDIR_W = $(GCCBASE)/linux64/4.5.3/lib64
GCCLIBDIR = $(GCCLIBDIR_W)
CFLAGS_common += -I$(GCCBASE)/linux64/4.5.3/include
OUTDIR = $(OUTBASE)/64
CFLAGS_link_libs = -L$(GCCLIBDIR) -lmyLib
else
CXXEXTRA_FLAGS = -m32
GCCDIR = $(GCCBASE)/linux/4.5.3
GCCLIBDIR_W = $(GCCBASE)/linux/4.5.3/lib
GCCLIBDIR = $(GCCLIBDIR_W)
CFLAGS_common += -I$(GCCBASE)/linux/4.5.3/include
OUTDIR = $(OUTBASE)/32
CFLAGS_link_libs = -L$(GCCLIBDIR) -lmyLib
endif
endif
ifeq ($(OSNAME),Darwin)
echo "Mac OS"
ifeq ($(GFLIB_MODEL),64bit)
CXXEXTRA_FLAGS = -m64
GCCDIR = $(GCCBASE)/macosx/4.8.1
GCCLIBDIR_W = $(GCCBASE)/macosx/4.8.1/lib
GCCLIBDIR = $(GCCLIBDIR_W)
CFLAGS_common += -I$(GCCBASE)/macosx/4.8.1/include
OUTDIR = $(OUTBASE)/64
CFLAGS_link_libs = -L$(GCCLIBDIR) -lmyLib
else
CXXEXTRA_FLAGS = -m32
GCCDIR = $(GCCBASE)/macosx/4.8.1
GCCLIBDIR_W = $(GCCBASE)/macosx/4.8.1/lib/i386
GCCLIBDIR = $(GCCLIBDIR_W)
CFLAGS_common += -I$(GCCBASE)/macosx/4.8.1/include
OUTDIR = $(OUTBASE)/32
CFLAGS_link_libs = -L$(GCCLIBDIR) -lmyLib
endif
endif
all: $(SRCS)
echo "Building Program application..."
$(CXX) $(CXXEXTRA_FLAGS) $(CFLAGS_common) $(INCLUDES) $^ -o $(OUTDIR)/$(OUT_ARTIFACT) $(CFLAGS_link_libs)
rm -f *.[o] *.log core
命令看起來是這個鏈接錯誤,因爲MYLIB未發現:
[exec] c++ -I. -IAuto*.h -IProgram.h Program.cpp -o /Program
雖然我期待我的命令是這樣的:
[exec] c++ -m32 -I. -IAuto*.h -IProgram.h Program.cpp -o /Program -LmyPath -lmyLib
爲什麼我的命令不包括-m32和鏈接庫路徑?
我也試過打印CXXEXTRA_FLAGS和CFLAGS_link_libs,但它們都是空的。
感謝MadScintist:如果我傳遞OSNAME是「Mac OS X」代替「Darwin」,我如何在makefile中比較它。 ifeq($(OSNAME),Darwin)應該換成什麼? – user3082802
顯而易見的'ifeq($(OSNAME),Mac OS X)'不起作用嗎? – MadScientist
不,它不適合我,任何改變空間分隔的詞,可能是? – user3082802