Skip to content

a demo shows how to build a project with dependency among sub-directory | 一个用於演示如何構建存在編譯依賴關係的項目的示例Makefile

License

Notifications You must be signed in to change notification settings

WeilunFong/DepSubdirMakefile

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DepSubdirMakefile

A solution shows how to compile a project with dependency.

Brief

DepSubdirMakefile is a tiny project shows how to compile a project which has multi-sub-directory with dependency. In the other words, one or more sub-directory need to be compile firstly bacause other sub-directory required. It's a common suitation in project and DepSubdirMakefile provides a easy and efficient solution. Notice that this DepSubdirMakefile only works on Linux or Unix-like environment.

Requirement

  • GNU Make
  • GNU C compiler (it can be configured as other compiler via environment varibale "CC")

Directory Structure

  • build:  makefile entrace for building project.
  • code:  project code, inlude all sub-directory. And directory dep needed to be compiled firstly.
  • obj:  ouput directory during build.
  • AUTHORS
  • ChangLog
  • LICENSE:  DepSubdirMakefile is licensed under the WTFPL2.
  • readme.html / readme-zh.html / README.md
  • test.sh:  one-key test script with Linux Shell format.
  • VERSION:  version code of DepSubdirMakefile

How it works & How to make?

Directory dep is a dependency item and needed to be compiled to a dynamic library file(libdep.so) under obj firstly. There is only a add opertaion function in this dynamic library file. Each of other sub-directory will generate a excutable file(bacause of only one .c files under these directory) and try creating a dynamic link to libdep.so. Besides, every executable files have the same name with corresponding .c file add opertaion function will be called in these excutable files. There are two ways to build this project:

  • Execute makefile under directory build. You can get what paramter the makefile supports via make help . Besides, you can choose which sub-directory which take part in build via command make + [name of sub-directory].It's noticed that this way only do build works. If you want to observe running results of target file, you need execute manually.
  • Run test.sh. You can get what paramter the script supports via paramter -h or --help . This script can complete build works and run target executable files in one time.

Contribution

You can pull request it or send e-mail to us if you have any words about this project.

About

a demo shows how to build a project with dependency among sub-directory | 一个用於演示如何構建存在編譯依賴關係的項目的示例Makefile

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published