Skip to content

Instantly share code, notes, and snippets.

@abranhe
Last active June 1, 2020 01:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abranhe/69aa2f4f985626cb9a02ea5ad892a81c to your computer and use it in GitHub Desktop.
Save abranhe/69aa2f4f985626cb9a02ea5ad892a81c to your computer and use it in GitHub Desktop.
Example of Makfile for assignment 1

Instructions

  • Create Makefile
  • Create lab1.c
  • Add the contents for the file

How to run it

To compile you can do

make all

or

make gpa

or just

make

then type ls -alt and you will see that there are new files generated called gpa, to run it:

./gpa

Cleanup

You'll never want to keep those files auto-generated so you can run:

make clean

and those files will be removed, you can check by typing ls -alt once again.


For those who don't even want to create the Makefile by their own you can download it like:

wget --output-document Makefile  https://git.io/Jf6y7
#include <stdio.h>
int main(void)
{
printf("Hello world");
return 0;
}
# You can add comments like this
all: gpa
gpa: lab1.o
gcc lab1.o -o gpa
lab1.o: lab1.c
gcc -c lab1.c -o lab1.o
clean:
rm -f gpa lab1.o core*~
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment