Created
November 28, 2014 23:48
-
-
Save loadletter/626215517424fcf54939 to your computer and use it in GitHub Desktop.
Generic makefile for small c programs
This file contains hidden or 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
# ?= declare if not already defined | |
CC ?= gcc | |
CFLAGS ?= -Wall -O2 -march=native | |
#LDLIBS = -lcrypt -lssl | |
# output executable name and file extensions | |
EXEC = run | |
SOURCES = $(wildcard *.c) | |
OBJECTS = $(SOURCES:.c=.o) | |
all: $(EXEC) | |
debug: CFLAGS = -Wall -g | |
debug: clean | |
debug: $(EXEC) | |
# Main target | |
$(EXEC): $(OBJECTS) | |
$(CC) $(LDLIBS) $(OBJECTS) -o $(EXEC) | |
# Object files | |
%.o: %.cpp | |
$(CC) -c $(CFLAGS) $< -o $@ | |
clean: | |
rm -f $(EXEC) $(OBJECTS) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment