Skip to content

Instantly share code, notes, and snippets.

@mcgrew
Created February 5, 2013 18:22
Show Gist options
  • Select an option

  • Save mcgrew/4716461 to your computer and use it in GitHub Desktop.

Select an option

Save mcgrew/4716461 to your computer and use it in GitHub Desktop.
Generic Makefile template
CC = gcc
CXX = g++
INCLUDES = -I.
CFLAGS = -g -O2
DEFINES =
EXTRA_CFLAGS= -Wall -Wextra -Wconversion
PROGRAM_NAME= program
LIBS = -L/usr/lib64/ -L/usr/lib/ -lm
CC_SWITCHES= $(EXTRA_CFLAGS) $(CFLAGS) $(DEFINES) $(INCLUDES)
GENERIC_OBJS=
OBJS = $(GENERIC_OBJS) $(PROGRAM_NAME).o
install: all
cp $(PROGRAM_NAME) /usr/bin/
all: $(OBJS)
$(CXX) $(CC_SWITCHES) -o $@ $(OBJS) $(LIBS) $(PROGRAM_NAME)
.cpp.o:
$(CXX) -c $(CC_SWITCHES) $<
.c.o:
$(CC) -c $(CC_SWITCHES) $<
clean:
rm -rf $(OBJS) $(PROGRAM_NAME).o $(PROGRAM_NAME)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment