Last active
August 29, 2015 14:05
-
-
Save kiyui/b043ed46da8db8a86b73 to your computer and use it in GitHub Desktop.
Simple makefile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#CC = gcc or g++ | |
CC = gcc | |
#CFLAGS are compile flags such as -lm to include <math.h> | |
#or -std=c++0x for C++11 | |
CFLAGS = -Wall -std=c99 | |
#TARGET is the name of your main file | |
TARGET = myMain | |
#OBJECTS = $(TARGET).o library1.o library.o, all the header files here | |
OBJECTS = $(TARGET).o myLib.o | |
#EXTRA Command line arguments | |
#Syntax: make EXTRA="arg1 arg2" | |
EXTRA? = "" | |
#Do not modify | |
$(TARGET) : $(OBJECTS) | |
$(CC) $(CFLAGS) $(EXTRA) $(OBJECTS) -o $(TARGET).bin | |
#%.c or %.cpp | |
%.o : %.c | |
$(CC) $(CFLAGS) $(EXTRA) -c $< | |
clean: | |
rm -rvf $(OBJECTS) $(TARGET).bin *~ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment