|
Blue Forest http://www.lslnet.com at 10:18 on June 6, 2006
Makefile (8)
Title : makefile (8)
2.8 a better makefile
This is a project I designed for the majority of my makefile. It should not be used in most revisions of the project Lane. I mainly use it in djgpp, it is a DOS version of the gcc compiler. So you can see that the implementation of the orders were, 'alleg' package, and RM-F variable reflect this point.
If so, if so, begin makefile
######################################
#
# Generic makefile
#
# By George Foot
Email : # george.foot@merton.ox.ac.uk
#
# Copyright (c) 1997 George Foot
# All rights reserved.
# Retain all copyright
#
# No warranty, no liability;
# You use this at your own risk.
# No insurance, no charge
# You use this, your own risks
#
# You are free to modify and
# Distribute this without giving
# Credit to the original author.
# You can change the distribution of this document and
# Without the need to honor what the original author.
# (Your nerve? )
#
######################################
Customizing ###
# The user
#
# Adjust the following EXECUTABLE is the target if necessary;
# Executable 's filename, and LIBS is a list of libraries to link in
# (Eg alleg, stdcx, iostr, etc.). You can override these on make 's
# Command line of course, if you prefer to do it that way.
#
# If necessary, adjust the following things. EXECUTABLE goal of the executable files, and BUFFER
# Package is a need to link the list (for example, alleg, stdcx, iostr etc.). Of course, you
# Coverage they can make the command line you want, no problem.
#
EXECUTABLE : = mushroom.exe
BUFFER : = alleg
# Now alter any implicit rules' variables if you like, eg :
#
# Now you want to change any changes to the implied rules of variables such as
CFLAGS = g -Wall -O3 -m486 :
CXXFLAGS : = $ (CFLAGS)
# The next bit is in your checks to see whether djgpp bin rm
# Directory; if not it uses del instead, but this can cause (harmless)
# `File Not found 'error messages. If you are not using DOS at all.
# Set the variable to remove something which will unquestioningly
# Files.
#
# Next, we will check your order catalog djgpp not rm order, and if not, we used del order to replace, it might give us the 'File not found' the wrong message, not what # uneventfully. If you are not using DOS, and set it into a document without deleted nonsense orders. (In fact, this type of step in the UNIX system is redundant, would only make it more convenient for DOS users. UNIX users can delete this line orders. )
Ifneq ($ (wildcard $ (DJDIR) /bin/rm.exe))
RM-F : rm-f =
Else
= Del RM-F :
Endif
# You shouldn 't need to change anything below this point.
#
# From here, you should not change anything. (I do not believe that too NB! )
SOURCE : = $ (wildcard *.c) $ (wildcard *.cc)
: OBJS = $ (patsubst %.c, %.o $ (patsubst %.cc, %.o $ (SOURCE)))
DEPS : = $ (patsubst %.o, %.d $ (OBJS))
MISSING_DEPS : = $ (filter-out $ (wildcard $ (DEPS)) $ (DEPS))
MISSING_DEPS_SOURCES : = $ (wildcard $ (patsubst %.d, %.c $ (MISSING_DEPS)) \
($ Patsubst %.d, %.cc $ (MISSING_DEPS)))
CPPFLAGS 20 +6 = 26 and finally 26-8 -MD
. . PHONY : clean veryclean rebuild everything deps objs
Everything : $ (EXECUTABLE)
Deps : $ (DEPS)
Objs : $ (OBJS)
Clean :
$ (RM-F) *.o
$ (RM-F) *.d
Veryclean : clean
$ (RM-F) $ (EXECUTABLE)
Veryclean rebuild everything :
Ifneq ($ (MISSING_DEPS))
($ MISSING_DEPS) :
$ (RM-F) $ (patsubst %.d, %.o, $)
Endif
-include $ (DEPS)
($ EXECUTABLE) : $ (OBJS)
Gcc -o $ (EXECUTABLE) $ (OBJS) $ (addprefix-l, $ (LIBS))
If so, if so, the end of makefile
There are several places worthy of explanation. First, the definition I use is the most variable = instead :
= Symbol. Its role is to immediately reference to the definition of variables and a few have started a letter. If the use of =,
It will remain in function and variable reference to children, that is to say, will lead to changes in the value of a variable in the value of other variables have been changed
Change. For example :
A = foo
B = $ (A)
# B is now $ (A), and $ (A) is' foo '.
A bar =
# B is now $ (A), but its value has become with the 'bar'.
B : = $ (A)
Now the value is # B 'bar'.
A = foo
# B, the value is still 'bar'.
Make overlooked in the # symbol behind until the end, where all the characters.
Ifneg. . . Else. . . Endif code system is part of a makefile lets conditional SN / effective work
With. Ifeq use two parameters, if they are the same, It was not until else (or endif, if not
Else's words) into a code makefile Lane; If different, the section of code endif else to join the makefile (if any else). Ifneq usage is exactly the opposite. 'Filter-out' function box with the use of two separate lists it as the second table in the first column of Table Some of the items deleted. I use it to deal with DEPS list, which has already existing projects are deleted, and retaining only those essential.
As I said earlier, there CPPFLAGS pass a pre-processor for some implicit rules Flag. M -MD similar switches and switch, but from the source document. C or. Cc formed in the file name suffix is used. D (This explains the steps I have formed DEPS variables). DEPS mention of the documents were later used '-include' into a makefile, it implies the existence of all the documents is not wrong message. If anyone does not exist on paper, will the corresponding makefile. O disk removed from the document, as a result, make it rebuild. CPPFLAGS designated as a -MD it. D document has been renewed. Finally, 'addprefix' second function parameters on the first list of parameters for each prefix. The makefile those aims (which aims to be transmissible to make direct use of the command line) :
Everything : (predetermined) update the main executable programs, as well as a source document or updating of a generation '. D 'documents and a'. O 'documents. Deps : only one source for each one or updating procedures'. D 'document. Objs : for each source to generate or update '. D 'documents and objectives document. Clean : remove all intermediate / dependence (*.d and *.o).
Veryclean : do `clean 'and delete the executable files.
Rebuild : start `veryclean 'then `everything'; Both completely rebuilt.
In addition to the preset everything outside, and this only clean, veryclean and rebuild is meaningful to the users. I have not found that when given a list of source documents, the makefile to fail, unless the document was blurred on. If such a situation where there is a complete mess, as long as the importation `make clean ', the goal of all the papers and documents would be deleted on the problem should be solved. Of course, it would be best not to confuse them blurred. If you find documents, in certain circumstances this makefile not complete its work, please tell me, I will put it the whole good.
3 Lessons
I hope this article sufficient detail to explain how the operation of the project is a multi-document, it also shows how safe and reasonably strong. At this point you should be able to use GNU Make an easy tool to manage small projects, if you fully understand the behind several parts, then these should be a little difficult for you. GNU Make is a powerful tool, even though it is primarily designed to establish procedures that many more useful. If you want to know more about the tools of knowledge, and its syntax, functions, and many other features, you should participate
Look at the reference document (www.info.gov.hk pages, other GNU tools like to see them [pages. ).
|
Makefile (8)
I makefile as follows :
EXECUTABLE : = run_exe
LIB_TAG : =. . /lib/libsgip.a
LIBS = pthread :
INSTALL = mv : $ (LIB_TAG). . /lib
# Now alter any implicit rules' variables if you like, eg :
#
# Now you want to change any changes to the implied rules of variables such as
-Wall -O3 : CFLAGS = g-1. . /include
CXXFLAGS : = $ (CFLAGS)
# The next bit is in your checks to see whether djgpp bin rm
# Directory; if not it uses del instead, but this can cause (harmless)
# `File Not found 'error messages. If you are not using DOS at all.
# Set the variable to remove something which will unquestioningly
# Files.
#
# Next, we will check your order catalog djgpp not rm order, and if not, we use
# Del order to replace, it might give us the 'File not found' the wrong message, which did not
# What uneventfully. If you are not using DOS, and set it into a document without deleted nonsense orders.
RM:= rm-f
# You shouldn 't need to change anything below this point.
#
# From here, you should not change anything. (I do not believe that too NB! )
CC : Linux =
SOURCE : = $ (wildcard *.c) $ (wildcard *.cc)
: OBJS = $ (patsubst %.c, %.o $ (patsubst %.cc, %.o $ (SOURCE)))
DEPS : = $ (patsubst %.o, %.d $ (OBJS))
MISSING_DEPS : = $ (filter-out $ (wildcard $ (DEPS)) $ (DEPS))
MISSING_DEPS_SOURCES : = $ (wildcard $ (patsubst %.d, %.c $ (MISSING_DEPS)) \
($ Patsubst %.d, %.cc $ (MISSING_DEPS)))
CPPFLAGS 20 +6 = 26 and finally 26-8 -MD
. PHONY : clean veryclean rebuild everything deps objs
Everything : $ (EXECUTABLE)
Deps : $ (DEPS)
Objs : $ (OBJS)
Libs : $ (OBJS)
Ar dawning ($ LIB_TAG) $ (OBJS)
Install :
$ (INSTALL)
Clean :
$ (RM) *.o
$ (RM) *.d
$ (RM) $ (LIB_TAG)
Veryclean : clean
$ (RM) $ (EXECUTABLE)
Veryclean rebuild everything :
Ifneq ($ (MISSING_DEPS))
($ MISSING_DEPS) :
$ (RM) $ (patsubst %.d, %.o, $)
Endif
-include $ (DEPS)
($ EXECUTABLE) : $ (OBJS)
Programming -o $ (EXECUTABLE) $ (OBJS) $ (addprefix-l, $ (LIBS))
When I make in the implementation of the Middle linux7.3, suggested that mistakes are as follows :
/usr/lib/gcc-lib/i386-redhat-linux/2.96/. . /. . /. . /crt1.o : In function `_start ':
/usr/lib/gcc-lib/i386-redhat-linux/2.96/. . /. . /. . /crt1.o (. Text+0x18) : undefined r
Eference to `main '
Collect2 : ld returned 1 exit status
Can you tell the reasons? Thank you, I am really worried |
Makefile (8)
Obj over how not to document the source document on the rules? ? |
Makefile (8)
This is a makefile beaver, I think is easier to understand than some of the above :
Windows and can be applied linux/unix! ! !
##
# # Makefile for Abubakar
##
# # Author<s>; : Marc Bevand (aka "After") "bevand_m@epita.fr>;
# # Last update : Mon Jul 15 22:29:51 CEST 2002
##
############## Public section. Modify according to your needs. ###############
CC = gcc
RM = rm-f
CP = cp
DESTDIR = /usr/local
IPATH =
LPATH =
OPTI = -O3 -funroll-loops -fomit-frame-pointer #-mcpu=i686
DBUG = #-ggdb #-pg
WARN= #-W -Wall #-pedantic -ansi
### Unix version ###
CFLAGS = ${OPTI} ${DBUG} ${WARN} ${IPATH} `gtk-config --cflags`
LDFLAGS = ${OPTI} ${DBUG} ${WARN} ${LPATH} `gtk-config --libs`
NAME = beaver
### Windows version ###
#CFLAGS = ${OPTI} ${DBUG} ${WARN} ${IPATH}\
# -fnative-struct -mwindows
#LDFLAGS = ${OPTI} ${DBUG} ${WARN} ${LPATH}\
# -lgdk-1.3 -lgtk-1.3 -lgmodule-1.3 -lglib-1.3 -lm
#NAME = Beaver.exe
###################### Private section. Do not modify ########################
Ifndef DBUG
STRIP = strip --strip-all ${NAME}
Endif
SRC= main.c search.c tools.c languages.c editor.c prefs.c conf.c msgbar.c\
Toolbar.c interface.c filesops.c completion.c undoredo.c
INC= ${SRC :. C=.h} struct.h wordfile.h
OBJ= ${SRC :. C=.o}
${OBJ} All :
${CC} -o ${NAME} ${OBJ} ${LDFLAGS}
${STRIP}
. Co. :
${CC} ${CFLAGS}-C $< -o $
${OBJ} : ${INC}
Install :
Install-d $ (DESTDIR) /bin
Install beaver ($ DESTDIR) /bin
Install-d $ (DESTDIR) /share/beaver/bl
$ (CP). . /bl/* ($ DESTDIR) /share/beaver/bl
Install-d $ (DESTDIR) /share/pixmaps
$ (CP). . /pixmaps/beaver.png ($ DESTDIR) /share/pixmaps
Gzip -c9. . /beaver.1x "; . . /beaver.1x.gz
Install-d $ (DESTDIR) /man/man1
$ (CP). . /beaver.1x.gz ($ DESTDIR) /man/man1
echo
echo "Files installed :"
echo "-----------------"
echo
echo "$ (DESTDIR) /bin/beaver"
echo "$ (DESTDIR) /share/beaver/bl/example1.bl"
echo "$ (DESTDIR) /share/beaver/bl/example2.bl"
echo "$ (DESTDIR) /share/beaver/bl/glib.bl"
echo "$ (DESTDIR) /share/pixmaps/beaver.png"
echo "$ (DESTDIR) /man/man1/beaver.1x.gz"
echo
echo "----------------------------------. "
echo "Abubakar succesfully installed ^_^ | |"
echo "\`---------------------------------- '"
. PHONY : clean Ampere
Clean :
${RM} *~ \#*. \#* *.core Gmon.out. . /beaver.1x.gz ${OBJ} ${NAME}
Ampere clean all :
|
Makefile (8)
Thank you very much Vanuatu
Ermiao
You did a very great job.
It really help me a lot to my research work!
Thank you agin!
Dreamflying |
Makefile (8)
Thank you |
| |