【发布时间】:2017-10-26 14:43:24
【问题描述】:
对于我的硕士论文,我正在开发一种工具来测试和评估多路径网络的公式。
我将使用 traceroute 工具通过传递 -s 标志、src IP 和 dst IP 来跟踪两个多宿主主机之间的网络。我有多个源和目标 IP。所以traceroute会被执行多次。
我不擅长编译。从https://sourceforge.net/projects/traceroute/files/traceroute/ 网站下载的 traceroute-2.1.0 代码有以下“make”相关文件。
- 生成文件
- make.defines
- make.rules
- default.rules
我已将更改应用到traceroute.c 中的代码,我可以通过“make”和“make install”正确编译它。但是这些更改是对系统的 traceroute 工具进行的(显然)。
我想要实现的是,使用新名称,例如“mytrace”而不是“traceroute”。所以它不会与 traceroute 工具发生冲突,我可以同时使用这两个工具。在 cmd 行中使用“traceroute”和其他使用“mytrace”调用。
问题是:为了实现它,我必须在重新编译之前进行哪些更改。
这是文件“makefile”的代码。
# Global Makefile.
# Global rules, targets etc.
#
# See Make.defines for specific configs.
#
srcdir = $(CURDIR)
override TARGET := .MAIN
dummy: all
include ./Make.rules
targets = $(EXEDIRS) $(LIBDIRS) $(MODDIRS)
# be happy, easy, perfomancy...
.PHONY: $(subdirs) dummy all force
.PHONY: depend indent clean distclean libclean release store libs mods
allprereq := $(EXEDIRS)
ifneq ($(LIBDIRS),)
libs: $(LIBDIRS)
ifneq ($(EXEDIRS),)
$(EXEDIRS): libs
else
allprereq += libs
endif
endif
ifneq ($(MODDIRS),)
mods: $(MODDIRS)
ifneq ($(MODUSERS),)
$(MODUSERS): mods
else
allprereq += mods
endif
ifneq ($(LIBDIRS),)
$(MODDIRS): libs
endif
endif
all: $(allprereq)
depend install: $(allprereq)
$(foreach goal,$(filter install-%,$(MAKECMDGOALS)),\
$(eval $(goal): $(patsubst install-%,%,$(goal))))
what = all
depend: what = depend
install install-%: what = install
ifneq ($(share),)
$(share): shared = yes
endif
ifneq ($(noshare),)
$(noshare): shared =
endif
$(targets): mkfile = $(if $(wildcard $@/Makefile),,-f
$(srcdir)/default.rules)
$(targets): force
@$(MAKE) $(mkfile) -C $@ $(what) TARGET=$@
force:
indent:
find . -type f -name "*.[ch]" -print -exec $(INDENT) {} \;
clean:
rm -f $(foreach exe, $(EXEDIRS), ./$(exe)/$(exe)) nohup.out
rm -f `find . \( -name "*.[oa]" -o -name "*.[ls]o" \
-o -name core -o -name "core.[0-9]*" -o -name a.out \) -print`
distclean: clean
rm -f `find $(foreach dir, $(subdirs), $(dir)/.) \
\( -name "*.[oa]" -o -name "*.[ls]o" \
-o -name core -o -name "core.[0-9]*" -o -name a.out \
-o -name .depend -o -name "_*" -o -name ".cross:*" \) \
-print`
libclean:
rm -f $(foreach lib, $(LIBDIRS), ./$(lib)/$(lib).a ./$(lib)/$(lib).so)
# Rules to make whole-distributive operations.
#
STORE_DIR = $(HOME)/pub
release release1 release2 release3:
@./chvers.sh $@
@$(MAKE) store
store: distclean
@./store.sh $(NAME) $(STORE_DIR)
【问题讨论】:
-
修改 Makefile 并更改输出二进制名称
-
@OleksandrKravchuk Makefile 对我来说有点太复杂了,不像我迄今为止遇到的较小的文件。正如我在帖子中提到的,make 规则跨越多个文件。我编辑了帖子以包含 Makefile 代码。
标签: linux gcc makefile compilation traceroute