Skip to content

Instantly share code, notes, and snippets.

@BourneID
Created November 22, 2011 02:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BourneID/1384722 to your computer and use it in GitHub Desktop.
Save BourneID/1384722 to your computer and use it in GitHub Desktop.
Project Makefile Template
#
# Project Makefile Template
#
INC = .
SRC = .
OUT = .
OBJ = obj
JSON_CPP_INC = ../jsoncpp/include
JSON_CPP_LIB = ../jsoncpp/libs
#
# g++ relative flags
#
GCC = g++
COMPILE = -c -g -D_GNE_SOURCE -fPIC -Wall
# static for link .a lib, not the default .so one
LINK = -Wall -fPIC -g -pthread -lpthread -lrt -L"$(JSON_CPP_LIB)" -static -ljson
ADD_INCS = -I"$(INC)" \
-I"$(JSON_CPP_INC)" \
#
# target(s)
#
TARGET = $(OUT)/json_demo
OBJECTS = $(OBJ)/json_hw.o \
ALL = MK_DIR $(TARGET)
#
# make all
#
all : $(ALL)
$(TARGET) : $(OBJECTS) $(JSON_CPP_LIB)/libjson.a
$(GCC) $(LINK) $^ -o $@
$(OBJ)/json_hw.o : $(SRC)/json_hw.cpp
$(GCC) $(COMPILE) $(ADD_INCS) $^ -o $@
#
# other commands
#
.PHONY: clean MK_DIR
clean:
rm -rf $(OBJ) $(TARGET)
MK_DIR:
mkdir -p $(OBJ)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment