]> git.tdb.fi Git - libs/core.git/commitdiff
New Makefile to work with subdirs (For Win32 build)
authorNiko Liikanen <cloud@neo-midgar.com>
Mon, 4 Sep 2006 11:03:10 +0000 (11:03 +0000)
committerNiko Liikanen <cloud@neo-midgar.com>
Mon, 4 Sep 2006 11:03:10 +0000 (11:03 +0000)
Makefile

index 9fe2580b6cc964b64f5a47d8c7997268b294461b..a4430526d8817606451db2e70fe28245849a72d3 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,32 +1,39 @@
-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
 
@@ -35,31 +42,36 @@ $(TMP):
        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 $@
@@ -69,8 +81,8 @@ $(TGT)/$(libdir):
 
 .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)