TMP = $(HOME)/nightwatch/tmp TGT = $(HOME)/nightwatch CXX = g++ CC = gcc AR = ar CP = cp INCLUDE = -Isource -I$(TMP)/include LIB = -L$(TMP) DEBUG = CFLAGS = $(DEBUG) $(INCLUDE) -pipe -Wall `pkg-config --cflags sigc++-2.0` `sdl-config --cflags` CXXFLAGS = $(CFLAGS) LIBRARY = framework LIBFILE = libmspframework SRC = source LIBOBJS = $(addprefix $(TMP)/, $(addsuffix .o, $(notdir $(basename $(wildcard $(SRC)/*.cpp))))) pkgincludedir = include/msp/$(LIBRARY) libdir = lib .PHONY: all all: $(TMP) $(TMP)/$(LIBFILE).so $(TMP)/$(LIBFILE).a tmpheaders # Create temp directory $(TMP): mkdir -p $@ # Dynamic library $(TMP)/$(LIBFILE).so: $(LIBOBJS) echo "Compiling $(notdir $@)" $(CXX) $^ -shared -o $@ $(LIB) $(LIBRARYLIBS) # Static library $(TMP)/$(LIBFILE).a: $(LIBOBJS) echo "Compiling $(notdir $@)" $(AR) rcs $@ $^ # Copy headers to temp .PHONY: tmpheaders tmpheaders: $(TMP)/$(pkgincludedir) $(CP) $(SRC)/*.h $< $(TMP)/$(pkgincludedir): mkdir -p $@ # Library object file $(TMP)/%.o: $(SRC)/%.cpp $(wildcard $(SRC)/*.h) echo "Compiling $(LIBRARY)/$(notdir $(basename $@))" $(CXX) -fPIC $(CXXFLAGS) -c $< -o $@ # Installs .PHONY: install install: install_headers install_lib install_staticlib $(TGT)/$(pkgincludedir): mkdir -p $@ $(TGT)/$(libdir): mkdir -p $@ .PHONY: install_headers install_headers: $(TGT)/$(pkgincludedir) echo "Installing $(LIBRARY) headers to $<" $(CP) $(SRC)/*.h $< .PHONY: install_lib install_lib: $(TGT)/$(libdir) $(TMP)/$(LIBFILE).so echo "Installing dynamic library to $<" $(CP) $(TMP)/$(LIBFILE).so $< .PHONY: install_staticlib install_staticlib: $(TGT)/$(libdir) $(TMP)/$(LIBFILE).a echo "Installing static library to $<" $(CP) $(TMP)/$(LIBFILE).a $<