-LIBRARY = framework
-LIBFILE = libmspframework
+NAME = core
-TMP = $(HOME)/nightwatch/tmp
-TGT = $(HOME)/nightwatch
+WORKDIR = $(PWD)/../..
+TMP = $(WORKDIR)/tmp/linux
+TGT = $(HOME)/local
CXX = g++
CC = gcc
AR = ar
CP = cp
+LIBFILE = libmsp$(NAME)
+
+MAKEFLAGS += -s --no-print-directory
INCLUDE = -Isource -I$(TMP)/include
LIB = -L$(TMP)
DEBUG =
-CFLAGS = $(DEBUG) $(INCLUDE) -pipe -Wall `pkg-config --cflags sigc++-2.0`
+CFLAGS = $(DEBUG) $(INCLUDE) -pipe -Wall
CXXFLAGS = $(CFLAGS)
-LIBLDFLAGS = `pkg-config --libs sigc++-2.0`
-MAKEFLAGS += -s --no-print-directory
PIC = -fPIC
SHARED = .so
STATIC = .a
+override CFLAGS += `pkg-config --cflags sigc++-2.0`
+override LDFLAGS += `pkg-config --libs sigc++-2.0`
+override CXXFLAGS += `pkg-config --cflags sigc++-2.0`
+
SRC = source
-LIBOBJS = $(addprefix $(TMP)/, $(addsuffix .o, $(notdir $(basename $(wildcard $(SRC)/*.cpp)))))
+SUBDIRS = core time
+OBJS = $(foreach SUBDIR, $(SUBDIRS), $(addprefix $(TMP)/$(SUBDIR)/, $(addsuffix .o, $(notdir $(basename $(wildcard $(SRC)/$(SUBDIR)/*.cpp))))))
-pkgincludedir = include/msp/$(LIBRARY)
+pkgincludedir = include/msp
libdir = lib
+foo = "echo $</$(SUBDIR); mkdir -p $</$(SUBDIR); $(CP) -r $(SRC)/$(SUBDIR)/*.h $</$(SUBDIR)"
.PHONY: all
all: $(TMP) $(TMP)/$(LIBFILE)$(SHARED) $(TMP)/$(LIBFILE)$(STATIC) tmpheaders
mkdir -p $@
# Dynamic library
-$(TMP)/$(LIBFILE)$(SHARED): $(LIBOBJS)
+$(TMP)/$(LIBFILE)$(SHARED): $(OBJS)
echo "Compiling $(notdir $@)"
- $(CXX) $^ -shared -o $@ $(LIB) $(LIBLDFLAGS)
+ $(CXX) $^ -shared -o $@ $(LIB)
# Static library
-$(TMP)/$(LIBFILE)$(STATIC): $(LIBOBJS)
+$(TMP)/$(LIBFILE)$(STATIC): $(OBJS)
echo "Compiling $(notdir $@)"
$(AR) rcs $@ $^
# Copy headers to temp
.PHONY: tmpheaders
tmpheaders: $(TMP)/$(pkgincludedir)
- $(CP) $(SRC)/*.h $<
+ $(foreach SUBDIR, $(SUBDIRS), \
+ mkdir -p $</$(SUBDIR) ; \
+ $(CP) -R $(SRC)/$(SUBDIR)/*.h $</$(SUBDIR) ; \
+ )
+# $(foreach SUBDIR, $(SUBDIRS), $(CP) -r $(SRC)/$(SUBDIR)/*.h $</$(SUBDIR))
$(TMP)/$(pkgincludedir):
mkdir -p $@
# Library object file
$(TMP)/%.o: $(SRC)/%.cpp $(wildcard $(SRC)/*.h)
- echo "Compiling $(LIBRARY)/$(notdir $(basename $@))"
+ mkdir -p $(dir $@)
+ echo "Compiling $(NAME)/$(notdir $(basename $@))"
$(CXX) $(PIC) $(CXXFLAGS) -c $< -o $@
# Installs
.PHONY: install
-install: install_lib
+install: install_lib
$(TGT)/$(pkgincludedir):
mkdir -p $@
.PHONY: install_headers
install_headers: $(TGT)/$(pkgincludedir)
- echo "Installing $(LIBRARY) headers to $<"
- $(CP) $(SRC)/*.h $<
+ echo "Installing $(NAME) headers to $<"
+ $(foreach SUBDIR, $(SUBDIRS), $(CP) $(SRC)/$(SUBDIR)/*.h $</$(SUBDIR))
.PHONY: install_lib
install_lib: $(TGT)/$(libdir) $(TMP)/$(LIBFILE)$(SHARED)