Skip to content

Instantly share code, notes, and snippets.

@doitian
Created September 1, 2009 13:36
Show Gist options
  • Save doitian/179100 to your computer and use it in GitHub Desktop.
Save doitian/179100 to your computer and use it in GitHub Desktop.
# paths
PREFIX = /usr/local
INCS =
LIBS =
CXX_FLAGS = -O2 -g -Wall ${INCS}
LD_FLAGS = ${LIBS}
# compiler and linker
CC = g++
LD = ${CC}
APP_NAME = test
APP_SRC = $(wildcard *.cpp)
APP_OBJ = ${APP_SRC:.cpp=.o}
.SUFFIXES: .cpp .o .d
all: options ${APP_NAME}
options:
@echo build options:
@echo "CXX_FLAGS = ${CXX_FLAGS}"
@echo "LD_FLAGS = ${LD_FLAGS}"
@echo "CC = ${CC}"
@echo "LD = ${LD}"
%.o: %.cpp
${CC} -c ${CXX_FLAGS} $<
%.d: %.cpp
${CC} -MM ${CXX_FLAGS} $< > $@
${APP_NAME}: ${APP_OBJ}
${LD} -o $@ $+ ${LD_FLAGS}
clean:
@echo cleaning
@rm -f ${APP_NAME}
@rm -f *.d
@rm -f *.o
install: all
@echo installing executable file to ${DESTDIR}${PREFIX}/bin
@mkdir -p ${DESTDIR}${PREFIX}/bin
@cp -f ${APP_NAME} ${DESTDIR}${PREFIX}/bin
@chmod 755 ${DESTDIR}${PREFIX}/bin/${APP_NAME}
uninstall:
@echo removing executable file from ${DESTDIR}${PREFIX}/bin
@rm -f ${DESTDIR}${PREFIX}/bin/${APP_NAME}
.PHONY: all options clean install uninstall
ifneq ($(MAKECMDGOALS),clean)
-include $(APP_SRC:.cpp=.d)
endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment