makefiles(4L)
π NAME π
makefiles(4L) is the users guide for compiling projects on different platforms β GMD FOKUS FILE FORMATS, bestie, welcome to the group chat π
β¨ SYNOPSIS β¨
make [target]
gmake [target]
smake [target]
target may be one of these iconic little words:
.helpβ get a list of possible targets and a short description.allβ make the default targets.installβ make and install the default targets (seeINS_BASEandINS_KBASEto learn how to modify the installation path).ibinsβ make and install a target inSRCROOT/bins.dependβ re-make dependency rules for all default targets. Note: all dependency files will automatically be remade on the next run ofmakebefore they are included.cleanβ remove core files and all intermediate object files.clobberβ remove the targets fromclean, all dependency files and all final targets.distcleanβ remove the targets fromcleanandclobberand all made files for all architectures.tagsβ makevi(1)compatible tags.TAGSβ makeemacs(1)compatible tags.configβ reserved for future use.rmtargetβ remove the default target.relinkβ remove the default target and remake it immediately. This can be used to change, for example,LD_RUN_PATHin the executable.
πΈ DESCRIPTION πΈ
Makefiles is a set of rules that allows compiling of structured projects with small and uniformly structured makefiles. All rules are located in a central directory. Compiling the projects on different platforms can be done simultaneously without the need to modify any of the makefiles that are located in the projects directories.
Makefiles is a set of high level portability tools superior to autoconf and easier to use.
Three make programs are supported: Sunpro make, GNU make and smake.
BSDmake could be supported if it supports pattern matching rules correctly.
The main design goal was to have a set of small and easy to read makefiles, each located in the project's leaf directory and therefore called leaf-makefile.
Each of these leaf-makefiles, in fact, contains no rule at all. It simply defines some macros for the make-program and includes two files from a central make rule depository. The included files and the files that are recursively included define the rules that are needed to compile the project.
Each leaf-makefile is formed in a really simple way:
- It first defines two macros that define the relative location of the project's root directory and the name of the directory that contains the complete set of rules, and then includes the rule file
rules.topfrom the directory that forms the central rule depository. You only have to edit the macroSRCROOTto reflect the relative location of the project's root directory. - The next part of a leaf-makefile defines macros that describe the target and the source. You can only have one target per leaf-makefile. Of course, there may be many source files that are needed to create that target. If you want to make more than one target in a specific directory, you have to put more than one makefile into that directory. This is the part of a makefile that describes a unique target. Edit this part to contain all source files, all local include files and all non global compile time flags that are needed for your target. For a typical target this is as simple as filling in a form.
- Each leaf-makefile finally includes a file from the rules directory that contains rules for the appropriate type of target that is to be made from this leaf-makefile.
The makefile in each directory has to be called Makefile. If you want to have more than one makefile in a specific directory, you have to choose different names for the other makefiles.
There are rules for the following type of targets:
commandsβ the make rules for user level commands likecat,lsetc. are located in the filerules.cmd.driversβ the make rules for device drivers are located in the filerules.drv.librariesβ the make rules for non shared libraries are located in the filerules.lib.shared librariesβ the make rules for shared libraries are located in the filerules.shl.localized filesβ the make rules for localized files are located in the filerules.loc.nonlocalized filesβ the make rules for non localized files are located in the filerules.aux.shell scriptsβ the make rules for shell scripts (a variant of localized files) are located in the filerules.scr.manual pagesβ the make rules for manual pages (a variant of localized files) are located in the filerules.man.diverted makefilesβ the make rules for projects that need to have more than one makefile in a specific directory are located in the filerules.mks. It contains a rule that diverts to the listed sub makefiles. Each sub makefile may be of any type.directoriesβ the make rules for sub directories are located in the filerules.dir.
π Macros/Variables Used In Rules π
The following is a description of the most important macros used within the make rules. NOTE: not all of them might be changed in a specific makefile. Carefully read the description and change only those macros that are intended to be used to change the behavior of the compilation.
ARCHDIRβ contains the location where object files and make targets will be placed. A typical name would be:OBJ/sparc-sunos5-cc. Do not change this macro.ASFLAGSβ the flags that are used with the assembler. Do not change this macro.ASMFILESβ a list of assembler source files, to be specified in a leaf makefile.ASOPTSβ the internal macro that contains the flags for the assembler. Change this macro if you want to change the behavior. Use:ASOPTS= valueif you want to override the default value. If you want to override the default assembler flags from the command line call:make 'ASOPTS=value'. Use:ASOPTS += valueif you want to add flags to the default value from within a makefile.ASOPTXβ may be used if you want to add flags to the assembler flags from the command line. Use:make 'ASOPTX=value'.C_ARCHβ this macro contains the c-compiler architecture name. Do not change this macro.CCOMβ this macro may be used from the command line to use a different c-compiler than the default. Use:make 'CCOM=gcc'to use gcc for the next run. Note: the value ofCCOMmust not necessarily be identical to the real name of the c-compiler. It refers to a filename which contains the definition for that c-compiler. This hint applies as well to all other macros that deal with the name of the c-compiler. The only macro that contains the real invocation name of the c-compiler isCC.CCis set inside the machine dependent configuration file in the central rules depository and must not be changed elsewhere.CFILESβ a list of C source files, to be specified in a leaf makefile.CFLAGSβ the flags that are used with the c-compiler. Do not use flags that belong to the c-preprocessor in theCOPTOPT,COPTSandCOPTXmacros. Do not change this macro.CLEAN_FILESβ a list of files (besides the object files) that will be removed withmake clean. Do not change this macro.CLEAN_FILEXβ this macro may be used to define additional files that should be removed withmake clean.CLOBBER_FILEXβ this macro may be used to define additional files that should be removed withmake clobber.COPTOPTβ the c-compiler optimization flag. This flag is intended to be overridden either from a makefile or from command line.COPTSβ the internal macro that contains the flags for the c-compiler. Change this macro if you want to change the behavior. Use:COPTS= valueif you want to override the default value. If you want to override the default c-compiler flags from the command line call:make 'COPTS=value'. Use:COPTS += valueif you want to add flags to the default value from within a makefile.COPTXβ may be used if you want to add flags to the c-compiler flags from the command line. Use:make 'COPTX=value'.CPPFLAGSβ the flags that are used with the c-preprocessor. This macro as well asCPPOPTSandCPPOPTXare also used when compiling c-programs. They should contain only the following flags:-Dname=value,-Uname,-Idirectoryand-Ydirectory. Do not change this macro.CPPOPTSβ the internal macro that contains the flags for the c-preprocessor. Change this macro if you want to change the behavior. Use:CPPOPTS= valueif you want to override the default value. If you want to override the default c-preprocessor flags from the command line call:make 'CPPOPTS=value'. Use:CPPOPTS += valueif you want to add flags to the default value from within a makefile.CPPOPTXβ may be used if you want to add flags to the c-preprocessor flags from the command line. Use:make 'CPPOPTX=value'.CURDIRβ this macro contains the name of the sub directory that is currently processed. Do not change this macro.CWARNOPTSβ this macro may be set in$(DEFLTSROOT)/$(DEFLTSDIR)/Defaultsor$(DEFLTSROOT)/$(DEFLTSDIR)/Defaults.$(O_ARCH)to overwrite the default c-compiler warn options.CWOPTSβ this macro is set inside the machine dependent configuration file in the central rules depository and must not be changed elsewhere. It contains the flags that set the default warning level for the c-compiler.DEFINSGRPβ this macro may be set in the projects defaults file to set up the default group id for installation.
okay so we're deep in the macro alphabet now, bestie β buckle up, the D's through the M's are a whole journey β¨
DEFINSMODEβ this macro can be set in the project's defaults file to set up the default file permission for installation πDEFINSUSRβ same deal, but it sets up the default user id for installation in the defaults file π«ΆDEFUMASKβ also set in the project's defaults file, and it sets up the default umask value used when creating sub directories β¨DEFAULTSDIRβ this one can be set from the command line or from the shell environment if you want a completely different set of Defaults files that isn't hanging out in the directoryDEFAULTSin the source root. Iconic use case: holding two or more sets of defaults that differ in stuff like the installation path or the C-compiler πDEFAULTSROOTβ may be set in a leaf makefile if that makefile wants a Defaults file that is not located in$(DEFAULTSDIR)in the source root. Perfect for when a sub tree in a big project needs its own different setup πΈDEFLTSDIRβ internally used macro, set from$(DEFAULTSDIR)or from the internal defaults. Do not change this macro. π«DEFLTSROOTβ internally used macro, set from$(DEFAULTSROOT)or from the internal defaults. Do not change this macro. π«DEFCCOMβ the default name of the c-compiler. Usually set in the file$(DEFLTSROOT)/$(DEFLTSDIR)/Defaultsor$(DEFLTSROOT)/$(DEFLTSDIR)/Defaults.$(O_ARCH)π οΈDEFINCDIRSβ a list of directories that get searched by default in addition to the system include directories. If this macro isn't set,$(SRCROOT)/includeis used πDIRNAMEβ this macro needs to be set in the makefile located in the$(SRCROOT)directory. The value should be either the name of the directory where the makefile lives, orSRCROOT. Its value updates automatically to follow the directory hierarchy. Do not change this macro in a make file other than the make file in the source root. πDIRSβ needs to be set in a makefile located in a directory that contains diversion directories. It has to contain a list of directory names where the diversions go to, likeDIRS= libfoo libbar libgarbageπHFILESβ for normal operation, makefiles automatically find which include files are needed for compilation. But β if you want to create a tag file that includes tags for definitions that occur within include files, you should setHFILESto a list of include files containing such definitions π₯INCDIRSβ normally this is just a copy ofDEFINCDIRS, but you can specify a different value in a leaf makefile or from the command line. That overwrites the defaults value πINS_BASEβ has to be specified in the file$(DEFLTSROOT)/$(DEFLTSDIR)/Defaultsor$(DEFLTSROOT)/$(DEFLTSDIR)/Defaults.$(O_ARCH). It must contain the path name of the root for installing general targets of the project. SeeINSDIRπINS_KBASEβ same deal, has to be specified in$(DEFLTSROOT)/$(DEFLTSDIR)/Defaultsor$(DEFLTSROOT)/$(DEFLTSDIR)/Defaults.$(O_ARCH), and it must contain the path name of the root for installing kernel modules from the project. SeeINSDIRπINSDIRβ this one has to be specified in the leaf makefile. It must contain the path name of a directory relative toINS_BASEorINS_KBASE. The target gets installed into$(INS_BASE)/$(INSDIR)π¦INSGRPβ may be set in a leaf makefile to set up the group id for installation π«ΆINSMODEβ may be set in a leaf makefile to set up the file permission for installation πINSUSRβ may be set in a leaf makefile to set up the user id for installation β¨K_ARCHβ contains the kernel/machine architecture for the target machine (e.g.sun3sun4csun4msun4u9000-725aviion). It's set to the output ofuname -mconverted to lower case. Do not change this macro. π«KARCHβ also contains the kernel/machine architecture for the target machine (e.g.sun3sun4csun4msun4u9000-725aviion), and yes it's set to the output ofuname -mconverted to lower case. Do not change this macro unless you want to do a cross compilation. πLDFLAGSβ the flags that are used with the linker. Do not change this macro. π«LDLIBSβ the internal macro that holds the libraries used while linking the target. Do not change this macro. π«LDOPTSβ the internal macro that contains the flags for the linker. This one you change if you want to change the behavior:- use
LDOPTS= valueif you want to override the default value - if you want to override the default linker flags from the command line, call
make 'LDOPTS=value' - use
LDOPTS += valueif you want to add flags to the default value from within a makefile π
- use
LDOPTXβ may be used if you want to add flags to the linker flags from the command line. Use:make 'LDOPTX=value'π₯LDPATHβ the default library search path for the linker. Usually set in the file$(DEFLTSROOT)/$(DEFLTSDIR)/Defaultsor$(DEFLTSROOT)/$(DEFLTSDIR)/Defaults.$(O_ARCH)πΈLIB_KVMβ a predefined macro containing the operating-system-dependent name of a library that programs need when they read/write kernel virtual memory. Add$(LIB_KVM)to your list of libraries (e.g.LIBS= -lintl $(LIB_KVM)) if your target uses kvm π§LIB_MATHβ a predefined macro containing the operating-system-dependent name of the library needed by programs that use routines of the math library. Add$(LIB_MATH)to your list of libraries (e.g.LIBS= -lintl $(LIB_MATH)) if your target uses math subroutines β¨LIB_SOCKETβ a predefined macro containing the operating-system-dependent name of the library needed by programs that use socket calls. Add$(LIB_SOCKET)to your list of libraries (e.g.LIBS= -lintl $(LIB_SOCKET)) if your target uses sockets. > Note: for portability reasons you should do this even on systems that don't require a socket library because they have the socket interface inside libc. no cap, do it anyway πLIBS_PATHβ contains the path to a directory where the libraries live that have been built during a make run inside the current project. Do not change this macro. π«M_ARCHβ contains the machine architecture for the target machine (e.g.sun3sun4ip22i86pci5869000-725aviion). It's set to the output ofarchconverted to lower case. On systems whereM_ARCHisn't available, it's set to the content ofK_ARCH. Do not change this macro. π«MK_FILESβ makefiles that divert into sub makes within the same directory must setMK_FILESto a list of makefile names for the sub makes. Those names should be built by adding.mkto the base name of the target that's defined inside the specific makefile πMAKEPROGβ set this macro to the name of your make program if it doesn't support the macroMAKE_NAME. The make programsmakeis able to identify itself. If you want to use a make program that is not able to identify itself and its name isn'tmake, setMAKEPROGto the name of the make program. Currently onlygmakeis supported as an alternate value forMAKEPROG. If you want to use an unsupported make program you have to check if it supports the needed features for makefiles β and you must write your own rule files for that make program. If you want to usegmake, you should dosetenv MAKEPROG gmakebefore you startgmake, or use a shell script that does this job for you π οΈMAKEβ set up by the make program itself. It contains a path name that's sufficient to recursively call the same make program again (either the last path component or the full path name of the make program). Do not change this macro. π«MAKEFLAGSβ set up by the make program. It contains the command line flags make is called with. Do not change this macro. π«MAKE_ARCHβ currently set up bysmakeonly. Contains the processor architecture of the target machine (e.g.mc68020,sparc,pentium). Do not change this macro. π«MAKE_BRANDβ currently set up bysmakeonly. Contains the brand of the target machine (e.g.Sun_Microsystems(e.g. )) β yes bestie the page literally has a stray "e.g." in there, I'm not making this up π Do not change this macro. π«MAKE_HOSTβ currently set up bysmakeonly. Contains the host name of the target machine (e.g.duffy,sherwood,ghost). Do not change this macro. π«MAKE_MACHβ currently set up bysmakeonly. Contains the kernel architecture of the target machine (e.g.sun3,sun4c,sun4m,sun4u). Do not change this macro. π«MAKE_MODELβ currently set up bysmakeonly. Contains the model name of the target machine (e.g.SUNW,SPARCstation-20). Do not change this macro. π«MAKE_M_ARCHβ currently set up bysmakeonly. Contains the machine architecture of the target machine (e.g.sun3,sun4). Do not change this macro. π«MAKE_NAMEβ currently set up bysmakeonly. Contains the official name of the make program (e.g.make,smake,gmake). Do not change this macro. π«
okay that's the macro wall done, bestie, but don't go anywhere β more is coming π
MAKE_OSβ bestie,smakeis literally the only one that sets this up. It's holding the operating system name of the target machine (likesunos,linux,dgux). Do not change this macro. hands off, i'm serious π ββοΈMAKE_OSDEFSβ alsosmake-only, also not yours to touch. It's carrying the operating system specific defines for the compiler (e.g.-D__SVR4). Do not change this macro.MAKE_OSRELβ yup,smakesets this one too. It's got the operating system release name of the target machine (e.g.5.5,4.1.1). Do not change this macro.MAKE_OSVERSIONβ again,smake-only territory. Contains the operating system version of the target machine (e.g.generic). Do not change this macro. π«ΆMAKE_SERIALβ last of thesmake-only squad, and it's holding the serial number of the target machine (e.g.1920098175). Do not change this macro. like why would you even πMANDIRβ okay so every single makefile for manual pages must set this macro to the path name relative toINS_BASEwhere the manual page root dir for the project should live. Valid values for english manual pages aremanorshare/man; valid values for german manual pages areman/deorshare/man/de. slay, choices β¨MANFILEβ makefiles for manual pages set this macro to the name of the troff source file for the manual page. that's it, that's the whole vibe πMANSECTβ makefiles for manual pages set this macro to the macro name that contains the real section name for this manual page. Why? because bsd based systems have different naming conventions than system V based systems, and we're not about to let that ruin our day. See below for a valid list of manual section macros πMANSECT_ADMINβ this macro contains the name of the sub directory for administrative commands and maintenance procedures. Do not change this macro.MANSECT_CMDβ this macro contains the name of the sub directory for general user commands. Do not change this macro.MANSECT_DEMOSβ this macro contains the name of the sub directory for demo commands. Do not change this macro.MANSECT_DEVICEβ this macro contains the name of the sub directory for user level device interfaces. Do not change this macro.MANSECT_DRIVERβ this macro contains the name of the sub directory for kernel level device driver interfaces. Do not change this macro.MANSECT_FILEFORMβ this macro contains the name of the sub directory for file formats. Do not change this macro.MANSECT_GAMESβ this macro contains the name of the sub directory for games. Do not change this macro. (yes, games. iconic.)MANSECT_HDRβ this macro contains the name of the sub directory for header files. Do not change this macro.MANSECT_LIBβ this macro contains the name of the sub directory for library function interfaces. Do not change this macro.MANSECT_MACROSβ this macro contains the name of the sub directory for troff macros. Do not change this macro.MANSECT_NETWORKβ this macro contains the name of the sub directory for user level network interfaces. Do not change this macro.MANSECT_SYSCALLβ this macro contains the name of the sub directory for system call interfaces. Do not change this macro.MANSECT_TABLESβ this macro contains the name of the sub directory for tables. Do not change this macro.MANSTYLEβ this macro contains the name that's used to find the right ordering conventions for manual pages. Do not change this macro. no cap, just leave it π¦MANSUFFIXβ makefiles for manual pages set this macro to the macro name that contains the real suffix for this manual page. Necessary because bsd based systems have different naming conventions than system V based systems (same whole situation asMANSECT). See below for a valid list of manual suffix macros βMANSUFF_ADMINβ this macro contains the name of the file suffix for administrative commands and maintenance procedures. Do not change this macro.MANSUFF_CMDβ this macro contains the name of the file suffix for general user commands. Do not change this macro.MANSUFF_DEMOSβ this macro contains the name of the file suffix for demo commands. Do not change this macro.MANSUFF_DEVICEβ this macro contains the name of the file suffix for user level device interfaces. Do not change this macro.MANSUFF_DRIVERβ this macro contains the name of the file suffix for kernel level device driver interfaces. Do not change this macro.MANSUFF_FILEFORMβ this macro contains the name of the file suffix for file formats. Do not change this macro.MANSUFF_GAMESβ this macro contains the name of the file suffix for games. Do not change this macro.MANSUFF_HDRβ this macro contains the name of the file suffix for header files. Do not change this macro.MANSUFF_LIBβ this macro contains the name of the file suffix for library function interfaces. Do not change this macro.MANSUFF_MACROSβ this macro contains the name of the file suffix for troff macros. Do not change this macro.MANSUFF_NETWORKβ this macro contains the name of the file suffix for user level network interfaces. Do not change this macro.MANSUFF_SYSCALLβ this macro contains the name of the file suffix for system call interfaces. Do not change this macro.MANSUFF_TABLESβ this macro contains the name of the file suffix for tables. Do not change this macro.
MARCHβ this macro contains the machine architecture for the target machine (e.g.sun3sun4ip22i86pci5869000-725aviion). It's set to the output ofarchconverted to lower case. On systems whereM_ARCHis not available, it's set to the content ofK_ARCH. Do not change this macro unless you want to do a cross compilation. like for real, that's the only exception πO_ARCHβ this macro contains the name of the operating system converted to lower case. It's usually the output ofuname -s. It may contain a modified name if the compilation rules for different versions of the operating system differ (e.g. on SunOS and Solaris, the official operating system name in both cases isSunOS). Do not change this macro.OARCHβ this macro contains the object architecture that's used for architecture dependent sub directories. It's set to$(PARCH)-$(O_ARCH)-$(C_ARCH). Do not change this macro.OARCHDIRβ this macro contains the concatenation ofOBJ/and$(OARCH). Do not change this macro.OFILESβ this macro contains the list of objects that are the dependency list for the target. It's constructed from the list of assembler source files, c source files, lex source files and yacc source files. Do not change this macro. built different, literally π§OINCSDIRβ this macro contains the concatenation of$(SRCROOT)/incs/and$(OARCH). It's the location where include files that are made within a make run and subject to global use will be placed. Do not change this macro.OLIBSDIRβ this macro contains the concatenation of$(SRCROOT)/libs/and$(OARCH). It's the location where libraries that are made within a make run will be placed. Do not change this macro.OSDEFSβ this macro contains operating system specific c-preprocessor definitions. Do not change this macro.OSNAMEβ the unmodified name of the operating system converted to lower case. SeeO_ARCH. Do not change this macro.OSRELβ the release of the operating system. Do not change this macro.P_ARCHβ this macro contains the processor architecture for the target machine (e.g.mc68020mc88200sparcpentium). It's set to the output ofuname -pconverted to lower case. On systems whereP_ARCHis not available, it's set to the content ofK_ARCH. Do not change this macro.PARCHβ same deal asP_ARCH: processor architecture for the target machine (e.g.mc68020mc88200sparcpentium), set to the output ofuname -pconverted to lower case, and on systems whereP_ARCHis not available it's set to the content ofK_ARCH. Do not change this macro unless you want to do a cross compilation. twin behavior, twin rules πRULESDIRβ the value of this macro must be set before the rules file$(SRCROOT)/$(RULESDIR/rules.topis included (yes, that's exactly how it's written, don't come for me π). If you want to test the behavior of a modified version of the makefiles inRULESDIR, put a copy into an alternate directory, modify one or more files in it, and then usemakewith a different value ofRULESDIRthat points to the alternate directory. lowkey a genius move fr frRUNPATHβ evaluated on systems whereLD_RUN_PATHis supported. It contains the default library search path for dynamic linked targets at runtime. This search path will be stored inside the target. It's usually set in the file$(DEFLTSROOT)/$(DEFLTSDIR)/Defaultsor$(DEFLTSROOT)/$(DEFLTSDIR)/Defaults.$(O_ARCH). Note that older systems will useLD_LIBRARY_PATHfor this purpose too. ok history lesson, we love context β¨SCRFILEβ this macro must be set in a leaf makefile for shell scripts to define the source for that script file. set it or it's not happening, bestie πSRCFILEβ bestie, this one must be set in a leaf makefile whenever you've got localized files, because it defines the source for that file. πSRCROOTβ holds the relative position to the project's source root directory. Timing is everything here: the value of this macro must be set before the rules file$(SRCROOT)/$(RULESDIR/rules.topgets included. So if the leaf makefile in question is located two directory levels below the source root, setSRCROOTto../... πSUBARCHDIRβ may be set to drop the object files and the target into a different directory than usual.SUBARCHDIRwill modify the value ofARCHDIR. Wanna build a target that's compiled for dbx? You may use:
make COPTX=-g SUBARCHDIR=-dbx
TARGETβ every makefile that isn't referring to library targets or sub makes / sub dir makes must defineTARGETto be the output file name of the final link operation. no cap, all of them. π₯TARGETLIBβ every makefile that's used to make libraries must defineTARGETLIBto be the central part of the target library. So if you wanna make e.g.libfoo, defineTARGETLIB= foo. Why tho? Because it lets operating systems have different naming conventions for libraries, obvs. And if you're making a non shared library, the example above would result in a filename oflibfoo.afor the real target. β¨TARGETMANβ this macro must be set in a leaf makefile for manual pages, and it defines the base name for that manual page (the suffix is not included, okay?). π¦XMK_FILEβ makefiles that want to install manual pages should setXMK_FILEtoMakefile.man, which saves you from having to install a diversion make file. The make file found inXMK_FILEwill be processed only if make is called with the targetinstall. iykyk π«Ά
πΈ GETTING STARTED πΈ
Setting up a new project? Here's the little ritual, bestie:
- First, copy the
RULESandTEMPLATESdirectories β and all their content β into the project's root directory. - Then copy a top level makefile, a
Defaultsfile and aTargetdirs.archnamefile into the project's root directory. - Then create the following directories:
cmd,lib,include. - Now start creating target directories, e.g. below
cmdandlib. And do not forget to create a makefile and an appropriateTargetdirs.archnamefile on each node directory. π
π¦ EXAMPLES π¦
Okay so if you want to set up a private copy of parts of a project, here's the move: pick a directory inside your own directory tree that's gonna become the shadow project's source root directory. Then create symbolic links named RULES and TEMPLATES pointing at the real source root. π
If you don't wanna modify the global include files, create a symbolic link to the include directory too β otherwise, copy the include directory and its content. Then copy the top level makefile, the Defaults file and the Targetdirs.archname file.
Finally, copy the desired sub tree together with all makefiles and the Targetdirs.archname files that are located in the directories above your part of the project β the part you want to have separately. π
π FILES π
.../RULES/*
.../DEFAULTS/*
.../TARGETS/*
.../TEMPLATES/*
β¨ SEE ALSO β¨
makerules(4), make(1), gmake(1), smake(1).
If you wanna know how to add new rules, or how to add support for new operating systems or compilers, look into makerules(4). that's the lore drop right there π
π©Ί DIAGNOSTICS π©Ί
Diagnostic messages depend on the make program you're running, so have a look at the appropriate man page. it's giving "read the docs, bestie" π
π NOTES π
The scope of this manual is only the usage of leaf makefiles. If you want to make changes to the make rules, have a look at makerules(4) instead. π
makefiles can be used with Sunpro make, Gnu make and smake. Although Gnu make runs on many platforms, it has no useful debug output. π
Use Sunpro make or smake if you have problems with a makefile. Sunpro make and smake both have a -D flag that allows you to watch the makefiles after the first expansion. Use this option if you're in doubt whether your makefile gets expanded the right way, and whether the right rules are included. There's also a -d option that gives debugging output while make is running. Want even more output? Use -dd, -ddd and so on. π₯
Smake has an option -xM that shows you the include dependency for make rules. slay.
The following is a list of all macros that are used in makefiles. Do not use them unless their meaning has been explained before. π¨
-O_ARCH, .OBJDIR, .SEARCHLIST, ALLTARGETS, AR, ARCH, ARCHDIR, ARCHDIRX,
ARCH_DONE, ARFLAGS, AS, ASFLAGS, ASMFILES, ASOPTS, ASOPTX, CC, CCOM,
CCOM_DEF, CFILES, CFLAGS, CHGRP, CHMOD, CHOWN, CLEAN_FILES, CLEAN_FILEX,
CLOBBER_FILEX, COPTDYN, COPTGPROF, COPTOPT, COPTS, COPTX, CPP, CPPFLAGS,
CPPOPTS, CPPOPTX, CTAGS, CURDIR, CWARNOPTS, CWOPTS, C_ARCH, DEFAULTSDIR,
DEFAULTSROOT, DEFCCOM, DEFCCOM_DEF, DEFINCDIRS, DEFINCDIRS_DEF,
DEFINSGRP, DEFINSMODE, DEFINSUSR, DEFUMASK, DEF_ROOT, DEP_DEP, DEP_FILE,
DEP_SUFFIX, DIRNAME, DIRS, DYNLD, ETAGS, FLOAT_OPTIONS, HFILES,
HOSTNAME, INCDIRS, INSDIR, INSGRP, INSGRP_DEF, INSMODE, INSMODE_DEF,
INSTALL, INSUSR, INSUSR_DEF, INS_BASE, INS_KBASE, KARCH, KARCH_DEF,
KDEFINES, K_ARCH, LD, LDCC, LDFLAGS, LDLIBS, LDOPTDYN, LDOPTS, LDOPTX,
LDPATH, LIBS, LIBS_PATH, LIBX, LIB_KVM, LIB_MATH, LIB_PREFIX,
LIB_SOCKET, LIB_SUFFIX, LN, LNDYNLIB, LOCALIZE, LORDER, MAKE, MK_FILES,
MAKEPROG, MAKE_ARCH, MAKE_HOST, MAKE_MACH, MAKE_M_ARCH, MAKE_NAME,
MAKE_OS, MAKE_OSDEFS, MAKE_OSREL, MANDIR, MANFILE, MANSECT,
MANSECT_ADMIN, MANSECT_CMD, MANSECT_DEMOS, MANSECT_DEVICE,
MANSECT_DRIVER, MANSECT_FILEFORM, MANSECT_GAMES, MANSECT_HDR,
MANSECT_LIB, MANSECT_MACROS, MANSECT_NETWORK, MANSECT_SYSCALL,
MANSECT_TABLES, MANSTYLE, MANSUFFIX, MANSUFF_ADMIN, MANSUFF_CMD,
MANSUFF_DEMOS, MANSUFF_DEVICE, MANSUFF_DRIVER, MANSUFF_FILEFORM,
MANSUFF_GAMES, MANSUFF_HDR, MANSUFF_LIB, MANSUFF_MACROS,
MANSUFF_NETWORK, MANSUFF_SYSCALL, MANSUFF_TABLES, MARCH, MARCH_DEF,
MKDEP, MKDEP_OUT, MKDIR, MV, M_ARCH, OARCH, OARCHDIR, OFILES, OINCSDIR,
OLIBSDIR, OSDEFS, OSNAME, OSREL, O_ARCH, PALLDEP_FILE, PARCH, PARCH_DEF,
PASMFILES, PDEP_FILE, PLOFILES, POFILES, PTARGET, PTARGET_BASE,
PYOFILES, P_ARCH, RANLIB, RM, RMDEP, RMTARGET, RM_FORCE, RM_RECURS,
RM_RF, RULESDIR, RUNPATH, SCRFILE, SHELL, SHL_SUFFIX, SRCFILE, SRCLIBS,
SRCROOT, SUBARCH, SUBARCHDIR, SYMLINK, TAGS, TARGET, TARGETLIB,
TARGETMAN, TARGET_BASE, TARGET_PATH, TSORT, UMASK, UMASK_DEF, UMASK_VAL,
XARCH, XK_ARCH, XMK_FILE, XMAKEPROG, XM_ARCH, XP_ARCH, _CCOM,
_DEFAULTSDIR, _DEFCCOM, _DEFINSGRP, _DEFINSMODE, _DEFINSUSR, _DEFUMASK,
_DIRNAME, _INCDIRS, _MAKEPROG, _MARCH, _M_ARCH, _O_ARCH, _PARCH,
_P_ARCH, _UNIQ, __CCOM, __DEFAULTSDIR, __DEFCCOM, __DEFINSGRP,
__DEFINSMODE, __DEFINSUSR, __DEFUMASK, __DIRNAME, __INCDIRS, __MAKEPROG,
__MARCH, __M_ARCH, __PARCH, __P_ARCH,
π BUGS π
Nothing listed here yet β literally an empty section, and we're not gonna invent bugs for it, bestie. π«Ά (if there's more coming, it's coming π )
π³ SOURCE TREE HIERARCHY π³
Okay bestie, here's the quick tour through a typical source hierarchy β it's giving "family tree but make it build system" π:
.../β root directory of the source tree, the main character πMakefileβ the topMakefileTargetdirsβ a file with a list of directories that are needed for that project. If the system needs different target lists depending on the target system architecture, use target specific files in.../TARGETS/...β more root-level stuff, iykyk
.../RULES/β the location of makefiles (included rules) πrules.topβ the mandatory include rules (needed to setup basic rules)rules.auxβ rules needed to install a non localized auxiliary filerules.cmdβ rules needed to make an ordinary command (like/bin/sh)rules.drvβ rules needed to make a device driverrules.libβ rules needed to make a standard (nonshared) libraryrules.locβ rules needed to install a localized auxiliary filerules.manβ rules needed to install a localized manual pagerules.scrβ rules needed to install a localized shell scriptrules.shlβ rules needed to make a shared libraryrules.mksβ rules needed to make more than one target in a specific directoryrules.dirβ rules needed to make targets that are located in sub directories to the current directory...β more rules, because of course π
.../DEFAULTS/β default definitions for various target architectures are located in this directory. Templates for some architectures can be found in the.../TEMPLATES/directory.Defaultsβ default definitions for that source tree. System dependent definitions are in.../DEFAULTS/Defaults.*
.../TARGETS/β target list definitions for various target architectures are located in this directory..../TEMPLATES/β templates that should be used inside the project (rename toMakefile, if it is the only makefile in that directory, rename totarget.mk, if there is more than one target in that directory) β¨DefaultsβDefaultsfile for the source root directoryDefaults.linuxβDefaultsfile for linux. This should be installed in the.../DEFAULTS/directory.Makefile.rootβMakefilefor the source root directoryMakefile.auxβMakefilefor a non localized auxiliary fileMakefile.cmdβMakefilefor an ordinary command (like/bin/sh)Makefile.libβMakefilefor a standard (nonshared) libraryMakefile.locβMakefilefor a localized auxiliary fileMakefile.manβMakefilefor a localized manual pageMakefile_de.manβMakefilefor a localized manual page in the german localeMakefile.scrβMakefilefor a localized shell scriptMakefile.shlβMakefilefor a shared libraryMakefile.drvβMakefilefor a device driverMakefile.mksβMakefilefor more than one target in a specific directoryMakefile.dirβMakefilefor targets that are located in sub directories to the current directory...β the template stash continues
.../cmd/β source tree for normal commandsMakefileβ the makefile for thecmdsub directoryTargetdirs.sun4mβ a file containing a list of directories likemyprog(see below) that are needed for that specific architecture.myprog/β directory where the sources for a specific command are locatedMakefileβ makefile formyprogMakefile.manβ makefile for the manual page ofmyprogmprog.cβ source formyprogmprog.trβ troff source for the manual page ofmyprogOBJ/β directory where system specific sub directories are locatedsparc-sunos5-cc/β directory for binaries that belong to a specific system...β more system-specific sub directories
...β moremyprogbits
...β more commands, obviously
.../lib/β directory where the sources for libraries are locatedMakefileβ the makefile for thelibsub directoryTargetdirs.sun4mβ a file containing a list of directories likelibfoo(see below) that are needed for that specific architecture.libfoo/β directory where all source files forlibfooare located...β more library goodness
.../kernelβ directory for kernel modulesMakefileβ the makefile for thekernelsub directoryTargetdirs.sun4mβ a file containing a list of directories likedrv(see below) that are needed for that specific architecture.drv/β directory where drivers are locatedMakefileβ the makefile for thedrvsub directoryTargetdirs.sun4mβ a file containing a list of directories likemydrv(see below) that are needed for that specific architecture.mydrv/β source for a specific driver...β more driver files
...β more kernel modules
.../includeβ directory for global include files that are used in that project.../binsβ directory for binary programs that are created/needed while compiling the projectsparc-sunos5-cc/β directory for binaries that belong to a specific system...β more architecture dirs
.../libsβ directory for libraries that are created/needed while compiling the projectsparc-sunos5-cc/β directory for libraries that belong to a specific system...β more architecture dirs
.../incsβ directory for include files that are created/needed while compiling the projectsparc-sunos5-cc/β directory for include files that belong to a specific system...β more architecture dirs
...β and the tree goes on, because she contains multitudes π¦
π AUTHOR π
This absolute icon wrote the page:
Joerg Schilling
Seestr. 110
D-13353 Berlin
Germany
Mail bugs and suggestions to:
joerg@schily.isdn.cs.tu-berlin.de or js@cs.tu-berlin.de or jes@fokus.gmd.de
And that's a wrap on makefiles(4L), dated 14. February 1997 β go forth and build something iconic, bestie π
β¨
π¦ where this page comes from
- arch rolling: cdrtools 3.02a09-6 Β· GPL-2.0-or-later AND LGPL-2.1-or-later AND CDDL-1.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms