Skip to content

Instantly share code, notes, and snippets.

@romsalva
Last active December 27, 2015 06:49
Show Gist options
  • Save romsalva/7284830 to your computer and use it in GitHub Desktop.
Save romsalva/7284830 to your computer and use it in GitHub Desktop.
Generic makefile
TARGET=a
SOURCES=main.cpp
OBJECTS=$(SOURCES:.cpp=.o)
#CC=gcc
CC=g++
CFLAGS=-c -g
LDFLAGS=
all: build
build: $(TARGET)
clean:
rm -f *.o
rm -f $(TARGET)
rebuild: clean build
info:
@echo Sources:
@echo $(SOURCES)
@echo Objects
@echo $(OBJECTS)
$(TARGET): $(OBJECTS)
$(CC) $(LDFLAGS) $^ -o $@
%.o: %.cpp
$(CC) $(CFLAGS) $< -o $@
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment