Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add C to make #4

Open
MichaelCurrin opened this issue Oct 27, 2020 · 1 comment
Open

Add C to make #4

MichaelCurrin opened this issue Oct 27, 2020 · 1 comment

Comments

@MichaelCurrin
Copy link
Owner

https://docs.oracle.com/cd/E19504-01/802-5880/6i9k05dhg/index.html

# Simple makefile for compiling a program from
# two C source files.  

.KEEP_STATE

functions: main.o data.o 
         cc -O -o functions main.o data.o 
main.o: main.c 
        	cc -O -c main.c 
data.o: data.c 
         cc -O -c data.c 
clean: 
        	rm functions main.o data.o
$ make 
cc -o functions main.o data.o 
cc -O -c main.c 
cc -O -c data.c 

With flags

# Makefile for compiling two C sources 
CFLAGS= -O 
.KEEP_STATE:

functions: main.o data.o 
          $(LINK.c) -o functions main.o data.o 
main.o: main.c 
          $(COMPILE.c) main.c 
data.o: data.c 
          $(COMPILE.c) data.c 
clean: 
         	rm functions main.o data.o
@MichaelCurrin
Copy link
Owner Author

Cheatsheet reference?

Implicit rules and dynamic macros

 make maintains a set of macros dynamically, on a target-by-target basis. These macros are used quite extensively, especially in the definitions of implicit rules. It is important to understand what they mean.
Note -

Because they are not explicitly defined in a makefile, the convention is to document dynamic macros with the $-sign prefix attached (in other words, by showing the macro reference). 

$@

    The name of the current target.

$?

    The list of dependencies newer than the target.

$<

    The name of the dependency file, as if selected by make for use with an implicit rule.

$*

    The base name of the current target (the target name stripped of its suffix).

$%

    For libraries, the name of the member being processed. See "Building Object Libraries " for more information.

@MichaelCurrin MichaelCurrin changed the title C make Add C to make Oct 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant