make每次都会编译一些程序,即使它们只是被编译也是如此 [英] make compiles some programs every time, even if they are just compiled

查看:129
本文介绍了make每次都会编译一些程序,即使它们只是被编译也是如此的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在下面有一个Makefile.每当我运行make clean然后运行make时,所有内容都会再次编译.但是在那之后,如果我再次运行make,则会重新编译一部分程序:convert_genomesalign_bsmethyl_extract,这很奇怪,因为它们已经编译.

我已经在不同的操作系统上对此进行了测试,结果是相同的.你有什么主意吗?

编辑

当我将convert-genomes更改为convert_genomes时(和其他两个程序类似),问题得以解决,但是我仍然不知道Makefile-_之间的区别是什么导致我的问题

CC=                     gcc
CXX=            g++
CFLAGS=         -Wall -Wno-unused-function -O2
CXXFLAGS=       -Wall -Wno-unused-function -O2
OBJS=           QSufSort.o bwt_gen.o utils.o bwt.o bwtaln.o bwa2.o bwtgap.o sam.o hash.o smith.o aligner.o fa2bin.o \
                        is.o bntseq.o bwtindex.o ksw.o stdaln.o simple_dp.o \
                        bwaseqio.o bwase.o bwape.o kstring.o cs2nt.o \
                        bwtsw2_core.o bwtsw2_main.o bwtsw2_aux.o bwt_lite.o \
                        bwtsw2_chain.o bamlite.o bwtsw2_pair.o bwt2.o bwa.o
PROG=           aryana
INCLUDES=
LIBS=           -lm -lz -lpthread
SUBDIRS=        .
debug:          CFLAGS += -DDEBUG -g3 -O0
debug:          CXXFLAGS += -DDEBUG -g3 -O0

.SUFFIXES:.c .o .cc

.c.o:
                $(CC) -c $(CFLAGS) $(INCLUDES) $< -o $@
.cc.o:
                $(CXX) -c $(CXXFLAGS) $(INCLUDES) $< -o $@

all:    $(PROG) aryana convert-genomes align-bs methyl-extract read_simul SamAnalyzer fastaseq bwtcheck SamToNormWig
debug:  all

aryana:$(OBJS) aryana_main.o
                $(CC) $(CFLAGS) $(OBJS) aryana_main.o -o aryana $(LIBS)

convert-genomes:
                $(CXX) $(CXXFLAGS) convert_genomes.cpp -o convert_genomes

align-bs:
                $(CXX) $(CXXFLAGS)  align_bs.cpp -o align_bs

methyl-extract:
                $(CXX) $(CXXFLAGS) methyl_extract.cpp -o methyl_extract

read_simul:
                $(CXX) $(CXXFLAGS) read_simul.cpp -o read_simul

SamAnalyzer:
                $(CXX) $(CXXFLAGS) SamAnalyzer.cpp -o SamAnalyzer

SamToNormWig:
                $(CXX) $(CXXFLAGS) SamToNormWig.cpp -o SamToNormWig
fastaseq:
                $(CXX) $(CXXFLAGS) fastaseq.cpp -o fastaseq

bwtcheck:
                $(CXX) $(CXXFLAGS) bwtcheck.cpp -o bwtcheck

QSufSort.o:QSufSort.h

bwt.o:bwt.h
bwt2.o:bwt.h
bwtaln.o:bwt.h bwtaln.h kseq.h bwa2.h
bwt1away.o:bwt.h bwtaln.h
bwt2fmv.o:bwt.h
bntseq.o:bntseq.h
bwtgap.o:bwtgap.h bwtaln.h bwt.h
aligner.o: aligner.h bwt.h hash.h smith.h
fa2bin.o: fa2bin.h
hash.o: hash.h
bwa2.o: bwa2.h sam.h aligner.h bwt.h
sam.o: sam.h bwt.h
smith.o: smith.h bwt.h
bwtsw2_core.o:bwtsw2.h bwt.h bwt_lite.h stdaln.h
bwtsw2_aux.o:bwtsw2.h bwt.h bwt_lite.h stdaln.h
bwtsw2_main.o:bwtsw2.h
bwa.o: bntseq.h bwa.h bwt.h ksw.h utils.h kstring.h malloc_wrap.h kvec.h
aryana_main.o: aryana_main.h aryana_args.h bwt.h bwtaln.h kseq.h bwa2.h

clean:
                rm -f gmon.out *.o a.out $(PROG) *~ *.a aryana align_bs methyl_extract convert_genomes read_simul SamAnalyzer bwtcheck fastaseq SamToNormWig

解决方案

如果目标是convert-genomes,但是程序是convert_genomes,则每次尝试制作convert-genomes时,文件convert-genomes都不会存在,所以它已经过时,并且再次运行构建它"的规则,重新创建convert_genomes而不是create-genomes.

make创建文件.如果您告诉make此规则将创建文件F",并且实际上该规则将创建其他文件G,则make将永远不会发现F是最新的-正如您仔细演示的那样,尽管是偶然的.

I have a Makefile below. Whenever I run make clean and then make everything is compiled again. But just after that if I run make again a subset of programs: convert_genomes, align_bs and methyl_extract are compiled again, which is strange since they have just compiled.

I have tested this in different operating systems, and the result is the same. Do you have any ideas?

EDIT

When I changed convert-genomes to convert_genomes (and similarly for the two other programs) the problem got solved, but I have still no idea what is the different between - and _ in Makefile that results in my problem

CC=                     gcc
CXX=            g++
CFLAGS=         -Wall -Wno-unused-function -O2
CXXFLAGS=       -Wall -Wno-unused-function -O2
OBJS=           QSufSort.o bwt_gen.o utils.o bwt.o bwtaln.o bwa2.o bwtgap.o sam.o hash.o smith.o aligner.o fa2bin.o \
                        is.o bntseq.o bwtindex.o ksw.o stdaln.o simple_dp.o \
                        bwaseqio.o bwase.o bwape.o kstring.o cs2nt.o \
                        bwtsw2_core.o bwtsw2_main.o bwtsw2_aux.o bwt_lite.o \
                        bwtsw2_chain.o bamlite.o bwtsw2_pair.o bwt2.o bwa.o
PROG=           aryana
INCLUDES=
LIBS=           -lm -lz -lpthread
SUBDIRS=        .
debug:          CFLAGS += -DDEBUG -g3 -O0
debug:          CXXFLAGS += -DDEBUG -g3 -O0

.SUFFIXES:.c .o .cc

.c.o:
                $(CC) -c $(CFLAGS) $(INCLUDES) $< -o $@
.cc.o:
                $(CXX) -c $(CXXFLAGS) $(INCLUDES) $< -o $@

all:    $(PROG) aryana convert-genomes align-bs methyl-extract read_simul SamAnalyzer fastaseq bwtcheck SamToNormWig
debug:  all

aryana:$(OBJS) aryana_main.o
                $(CC) $(CFLAGS) $(OBJS) aryana_main.o -o aryana $(LIBS)

convert-genomes:
                $(CXX) $(CXXFLAGS) convert_genomes.cpp -o convert_genomes

align-bs:
                $(CXX) $(CXXFLAGS)  align_bs.cpp -o align_bs

methyl-extract:
                $(CXX) $(CXXFLAGS) methyl_extract.cpp -o methyl_extract

read_simul:
                $(CXX) $(CXXFLAGS) read_simul.cpp -o read_simul

SamAnalyzer:
                $(CXX) $(CXXFLAGS) SamAnalyzer.cpp -o SamAnalyzer

SamToNormWig:
                $(CXX) $(CXXFLAGS) SamToNormWig.cpp -o SamToNormWig
fastaseq:
                $(CXX) $(CXXFLAGS) fastaseq.cpp -o fastaseq

bwtcheck:
                $(CXX) $(CXXFLAGS) bwtcheck.cpp -o bwtcheck

QSufSort.o:QSufSort.h

bwt.o:bwt.h
bwt2.o:bwt.h
bwtaln.o:bwt.h bwtaln.h kseq.h bwa2.h
bwt1away.o:bwt.h bwtaln.h
bwt2fmv.o:bwt.h
bntseq.o:bntseq.h
bwtgap.o:bwtgap.h bwtaln.h bwt.h
aligner.o: aligner.h bwt.h hash.h smith.h
fa2bin.o: fa2bin.h
hash.o: hash.h
bwa2.o: bwa2.h sam.h aligner.h bwt.h
sam.o: sam.h bwt.h
smith.o: smith.h bwt.h
bwtsw2_core.o:bwtsw2.h bwt.h bwt_lite.h stdaln.h
bwtsw2_aux.o:bwtsw2.h bwt.h bwt_lite.h stdaln.h
bwtsw2_main.o:bwtsw2.h
bwa.o: bntseq.h bwa.h bwt.h ksw.h utils.h kstring.h malloc_wrap.h kvec.h
aryana_main.o: aryana_main.h aryana_args.h bwt.h bwtaln.h kseq.h bwa2.h

clean:
                rm -f gmon.out *.o a.out $(PROG) *~ *.a aryana align_bs methyl_extract convert_genomes read_simul SamAnalyzer bwtcheck fastaseq SamToNormWig

解决方案

If your target is convert-genomes but the program is convert_genomes, then every time you try to make convert-genomes, the file convert-genomes does not exist, so it is out of date, and the rules to 'build it' are run once more, recreating convert_genomes instead of create-genomes.

make makes files. If you tell make 'this rule will make a file F' and actually the rule creates some other file G, then make will never find that F is up to date — as you carefully demonstrated, albeit by accident.

这篇关于make每次都会编译一些程序,即使它们只是被编译也是如此的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆