All c code compiled makefile templates under Linux Engineering

Source: Internet
Author: User

How to develop the simple C program quickly, first need a makefile template.


Simple Makefile Characteristics

This template requires the following features:

= = "Quickly compile all C code

"=" To quickly package the source code

= = "Language is simple and easy to understand, easy to follow the modular operation


Here to provide a template for everyone to refer to the use, if there are improvement methods and suggestions, also please advise, in order to improve, thank you!


Simple Makefile Template

No nonsense, simple example (version.c/main.c/version.h) is done using the three files of the demo with the "Release automated scripts for Linux/C + + release".

Makefile the template file, compile the output Hello executable program.

#Makefile for program Hello#program: = hellosources: = $ (wildcard *.c) Headers: = $ (wildcard *.h) objects: = $ (SOURCES:.C=.O ) Deps    : = $ (SOURCES:.C=.D) CC      : = gccshared  : =-sharedfpic    : =-fpiccflags  : = ldflags: = RM      : = RM- Ftar     : = targzip    : = Gzipme: =      makefileall: $ (program    ) Hello: $  (objects) $ (CC)-o [email protected] $ (CFLAGS) $ (objects) $ (ldflags) $ (ldlibs) dist:pkg= ' pwd '; Tar CVF-$ (Me) $ (sources) $ (headers)                 | $ (GZIP)-C > ' basename $${pkg} '. tar.gzclean:$ (RM) $ (objects) $ (RM) $ (deps) $ (RM) $ (program). Suffixes:. d.c.d:$ (CC) $ (cppflags)-MM-MF [email protected] $<-include $ (deps)

Easy Makefile Template Download

Download package Information


Engineering Test Results

The test results are as follows:

# lsmain.c  Makefile  version.c  version.h# makegcc  -mm-mf version.d version.cgcc  -mm-mf main.d MAIN.CGCC    -c-o main.o main.cgcc    -c-o version.o version.cgcc-o Hello  main.o version.o# lshello  main.c< C9/>MAIN.D  main.o  Makefile  version.c  version.d  version.h  version.o#./helloget_ Version:debug_2016-05-10_18:41:24_v1_2_271get_ver_author:lidaget_ver_author_contact: [Email protected]get_ver_ flag:debugget_build_date:2016-05-10get_build_time:18:41:24get_ver_major:1get_ver_minor:2get_ver_rev:271# make distpkg= ' pwd '; Tar cvf-makefile main.c version.c version.h                 | gzip-c > ' basename ${pkg} '. Tar.gzMakefilemain.cversion.cversion. h# make clean$ lsmain.c  Makefile  version.c  version.h  version.tar.gz

Resources

Introduction to "1" Simple development process (C language)
Getting Started with the "2" Linux application HelloWorld
"3" Linux version of the C/C + + release automatic script
"4" Linux common Packaging, decompression method (tar, bz2, RAR) detailed

All c code compiled makefile templates under Linux Engineering

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.