Best practice for building a make file

后端 未结 2 845
失恋的感觉
失恋的感觉 2020-12-03 12:55

Background:

I am relatively new to Make and I started building a makefile for my Othello game I recently built. My current makefile is relatively simple. Yet I am lo

2条回答
  •  -上瘾入骨i
    2020-12-03 13:24

    For a single folder project I built this Makefile *Note the executable generated has been changed to Game

    all: build archive
    
    build: Game
    
    Game: main.o Myothello.o space.o game.o
        clang++ main.o Myothello.o space.o game.o -o Othello
    
    main.o: main.cc
        clang++ -c main.cc
    
    game.o: game.cc
        clang++ -c game.cc
    
    Myothello.o: Myothello.cc
        clang++ -c Myothello.cc
    
    space.o: space.cc
        clang++ -c space.cc
    
    clean:
        rm -f *.o core *.core
    
    archive: main.cc game.cc Myothello.cc space.cc char.h  colors.h game.h 
    space.h Myothello.h makefile
        tar -cf archive.tar main.cc game.cc Myothello.cc space.cc char.h  
        colors.h game.h space.h Myothello.h makefile
    

    This works assuming all of your files are in the same directory This is where I found my information

    http://www.tutorialspoint.com/makefile/makefile_example.htm

    https://www.tecmint.com/18-tar-command-examples-in-linux/

    https://www.gnu.org/software/make/manual/html_node/Simple-Makefile.html

    ftp://ftp.gnu.org/old-gnu/Manuals/make-3.79.1/html_chapter/make_toc.html

提交回复
热议问题