Как е възможно да напиша този makefile?

Имам тези 3 команди, които компилират програмата ми:

  1. g++ -I/usr/include/cryptopp -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"AESBest.d" -MT"AESBest.d" -o "AESBest.o" "AESBest .cpp"
  2. g++ -I/usr/include/cryptopp -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"main.d" -MT"main.d" -o "main.o" "main .cpp"
  3. g++ -L/usr/include/cryptopp -o "Crypto" AESBest.o main.o -lcryptopp -lpthread

Как е възможно да се създаде makefile, като се вземат предвид тези 3 команди?

В Eclipse получавам изход от програмата в обвивката, но в моя bash, когато компилирам bin файла, наречен "Crypto", и го стартирам, нямам изход в моя bash обвивка. Защо?


person Community    schedule 03.11.2011    source източник
comment
Помислете дали да не преместите последните си два реда в отделен въпрос с повече коментари и обяснения.   -  person Andrejs Cainikovs    schedule 03.11.2011


Отговори (1)


Това ще работи:

all:
  g++ -I/usr/include/cryptopp -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"AESBest.d" -MT"AESBest.d" -o "AESBest.o" "AESBest.cpp"
  g++ -I/usr/include/cryptopp -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"main.d" -MT"main.d" -o "main.o" "main.cpp"
  g++ -L/usr/include/cryptopp -o "Crypto" AESBest.o main.o -lcryptopp -lpthread

И можете да го разбиете малко по следния начин:

AESBest.o:
  g++ -I/usr/include/cryptopp -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"AESBest.d" -MT"AESBest.d" -o "AESBest.o" "AESBest.cpp"

main.o:
  g++ -I/usr/include/cryptopp -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"main.d" -MT"main.d" -o "main.o" "main.cpp"

Crypto:
  g++ -L/usr/include/cryptopp -o "Crypto" AESBest.o main.o -lcryptopp -lpthread

И след това опростете така:

AESBest.o main.o: %.o : %.cpp
  g++ -I/usr/include/cryptopp -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF$*.d -MT$*.d -o $@ $<

Crypto: AESBest.o main.o
  g++ -L/usr/include/cryptopp -o $@ $^ -lcryptopp -lpthread
person Beta    schedule 03.11.2011