在linux下如果有多个文件和头文件如何来编写make,只要执行make就可以编译了,谢谢了
展开全部
#----------------------------------------------------------------------------
# Macros
#----------------------------------------------------------------------------
CC = gcc
CXX = g++
LD = $(CXX) $(CCFLAGS) $(CPPFLAGS)
AR = ar
PICFLAGS = -fPIC
CPPFLAGS = $(PICFLAGS) $(GENFLAGS) -D_REENTRANT
OBJEXT = .o
OUTPUT_OPTION = -o "../build/x86/$@"
OUTPUTBIN_OPTION = -o "../bin/$@"
COMPILE.c = $(CC) $(CFLAGS) $(CCFLAGS) $(CPPFLAGS) -c
COMPILE.cc = $(CXX) $(CCFLAGS) $(CPPFLAGS) -c
LDFLAGS = -L"../lib" -L"../lib/realse"
CCC = $(CXX)
MAKEFILE = Makefile.x86_EmbedTask
DEPENDENCIES = .depend.$(MAKEFILE)
BTARGETDIR = ./
BIN = $(BTARGETDIR)x86EmbedTask$(EXESUFFIX)$(EXEEXT)
CAT = cat
MV = mv -f
RM = rm -rf
CP = cp -p
NUL = /dev/null
MKDIR = mkdir -p
TESTDIRSTART = test -d
TESTDIREND = ||
TOUCH = touch
EXEEXT =
LIBPREFIX = lib
LIBSUFFIX =
GENFLAGS = -O
OPH = ../build/x86/
OBJS = $(OPH)Mtask$(OBJEXT) $(OPH)ServerConnectPool$(OBJEXT)
OBJS1 = Mtask$(OBJEXT) ServerConnectPool$(OBJEXT)
SRC = Mtask.cpp ServerConnectPool.cpp
LINK.cc = $(LD) $(LDFLAGS)
STATICFLAGS = -DACE_AS_STATIC_LIBS
EXPORTFLAGS =
#----------------------------------------------------------------------------
# Local targets
#----------------------------------------------------------------------------
all: $(BIN)
$(BIN): $(OBJS1)
@$(TESTDIRSTART) "$(BTARGETDIR)" $(TESTDIREND) $(MKDIR) "$(BTARGETDIR)"
$(LINK.cc) $(OBJS) $(LDLIBS) $(OUTPUTBIN_OPTION)
SPACE = $(should_be_unset) $(should_be_unset)
GENERATED_DIRTY =
.PRECIOUS: $(GENERATED_DIRTY)
$(OBJS): $(GENERATED_DIRTY)
generated: $(GENERATED_DIRTY)
@-:
Mtask$(OBJEXT): Mtask.cpp
$(COMPILE.cc) $(EXPORTFLAGS) $(OUTPUT_OPTION) Mtask.cpp
ServerConnectPool$(OBJEXT): ServerConnectPool.cpp
$(COMPILE.cc) $(EXPORTFLAGS) $(OUTPUT_OPTION) ServerConnectPool.cpp
clean:
-$(RM) $(OBJS)
realclean: clean
-$(RM) $(BIN)
-$(RM) $(GENERATED_DIRTY)
#----------------------------------------------------------------------------
# Dependencies
#----------------------------------------------------------------------------
#
#$(DEPENDENCIES):
# @$(TOUCH) $(DEPENDENCIES)
#
#depend:
# -$(MPC_ROOT)/depgen.pl $(CFLAGS) $(CCFLAGS) $(CPPFLAGS) -f $(DEPENDENCIES) $(SRC) 2> $(NUL)
#
#include $(DEPENDENCIES)
按照这个makefile进行相应的修改,即可实现只要执行make就可以编译了.
# Macros
#----------------------------------------------------------------------------
CC = gcc
CXX = g++
LD = $(CXX) $(CCFLAGS) $(CPPFLAGS)
AR = ar
PICFLAGS = -fPIC
CPPFLAGS = $(PICFLAGS) $(GENFLAGS) -D_REENTRANT
OBJEXT = .o
OUTPUT_OPTION = -o "../build/x86/$@"
OUTPUTBIN_OPTION = -o "../bin/$@"
COMPILE.c = $(CC) $(CFLAGS) $(CCFLAGS) $(CPPFLAGS) -c
COMPILE.cc = $(CXX) $(CCFLAGS) $(CPPFLAGS) -c
LDFLAGS = -L"../lib" -L"../lib/realse"
CCC = $(CXX)
MAKEFILE = Makefile.x86_EmbedTask
DEPENDENCIES = .depend.$(MAKEFILE)
BTARGETDIR = ./
BIN = $(BTARGETDIR)x86EmbedTask$(EXESUFFIX)$(EXEEXT)
CAT = cat
MV = mv -f
RM = rm -rf
CP = cp -p
NUL = /dev/null
MKDIR = mkdir -p
TESTDIRSTART = test -d
TESTDIREND = ||
TOUCH = touch
EXEEXT =
LIBPREFIX = lib
LIBSUFFIX =
GENFLAGS = -O
OPH = ../build/x86/
OBJS = $(OPH)Mtask$(OBJEXT) $(OPH)ServerConnectPool$(OBJEXT)
OBJS1 = Mtask$(OBJEXT) ServerConnectPool$(OBJEXT)
SRC = Mtask.cpp ServerConnectPool.cpp
LINK.cc = $(LD) $(LDFLAGS)
STATICFLAGS = -DACE_AS_STATIC_LIBS
EXPORTFLAGS =
#----------------------------------------------------------------------------
# Local targets
#----------------------------------------------------------------------------
all: $(BIN)
$(BIN): $(OBJS1)
@$(TESTDIRSTART) "$(BTARGETDIR)" $(TESTDIREND) $(MKDIR) "$(BTARGETDIR)"
$(LINK.cc) $(OBJS) $(LDLIBS) $(OUTPUTBIN_OPTION)
SPACE = $(should_be_unset) $(should_be_unset)
GENERATED_DIRTY =
.PRECIOUS: $(GENERATED_DIRTY)
$(OBJS): $(GENERATED_DIRTY)
generated: $(GENERATED_DIRTY)
@-:
Mtask$(OBJEXT): Mtask.cpp
$(COMPILE.cc) $(EXPORTFLAGS) $(OUTPUT_OPTION) Mtask.cpp
ServerConnectPool$(OBJEXT): ServerConnectPool.cpp
$(COMPILE.cc) $(EXPORTFLAGS) $(OUTPUT_OPTION) ServerConnectPool.cpp
clean:
-$(RM) $(OBJS)
realclean: clean
-$(RM) $(BIN)
-$(RM) $(GENERATED_DIRTY)
#----------------------------------------------------------------------------
# Dependencies
#----------------------------------------------------------------------------
#
#$(DEPENDENCIES):
# @$(TOUCH) $(DEPENDENCIES)
#
#depend:
# -$(MPC_ROOT)/depgen.pl $(CFLAGS) $(CCFLAGS) $(CPPFLAGS) -f $(DEPENDENCIES) $(SRC) 2> $(NUL)
#
#include $(DEPENDENCIES)
按照这个makefile进行相应的修改,即可实现只要执行make就可以编译了.
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
CC=gcc
SRC=$(wildcard *.c)
OBJS=$(patsubst %.c,%,$(SRC))
CFLAGS += -Wall -g
LDFLAGS:= -lm -lcurl -lssl -lpthread -lreadline -lGeoIP -lglut#-ltermcap
all:$(OBJS)
clean:
rm -rf *~
rm -rf $(OBJS)
SRC=$(wildcard *.c)
OBJS=$(patsubst %.c,%,$(SRC))
CFLAGS += -Wall -g
LDFLAGS:= -lm -lcurl -lssl -lpthread -lreadline -lGeoIP -lglut#-ltermcap
all:$(OBJS)
clean:
rm -rf *~
rm -rf $(OBJS)
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
建议你在网上搜一下《跟我一起写Makefile》这篇文章吧
阅读后 估计你就知道了
阅读后 估计你就知道了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |