]> git.tdb.fi Git - libs/core.git/blob - Makefile
Add relative() to utils
[libs/core.git] / Makefile
1 LIBRARY         = path
2 LIBFILE         = libmsppath
3
4 TMP             = $(HOME)/nightwatch/tmp
5 TGT             = $(HOME)/nightwatch
6
7 CXX             = g++
8 CC              = gcc
9 AR              = ar
10 CP              = cp
11
12 INCLUDE         = -Isource -I$(TMP)/include
13 LIB             = -L$(TMP)
14 DEBUG           = 
15 CFLAGS          = $(DEBUG) $(INCLUDE) -pipe -Wall
16 CXXFLAGS        = $(CFLAGS)
17 MAKEFLAGS       += -s --no-print-directory
18
19 PIC             = -fPIC
20 SHARED          = .so
21 STATIC          = .a
22
23 SRC             = source
24 LIBOBJS         = $(addprefix $(TMP)/, $(addsuffix .o, $(notdir $(basename $(wildcard $(SRC)/*.cpp)))))
25
26 pkgincludedir   = include/msp/$(LIBRARY)
27 libdir          = lib
28
29 .PHONY: all
30 all: $(TMP) $(TMP)/$(LIBFILE)$(SHARED) $(TMP)/$(LIBFILE)$(STATIC) tmpheaders
31
32 # Create temp directory
33 $(TMP):
34         mkdir -p $@
35
36 # Dynamic library
37 $(TMP)/$(LIBFILE)$(SHARED): $(LIBOBJS)
38         echo "Compiling $(notdir $@)"
39         $(CXX) $^ -shared -o $@ $(LIB)
40
41 # Static library
42 $(TMP)/$(LIBFILE)$(STATIC): $(LIBOBJS)
43         echo "Compiling $(notdir $@)"
44         $(AR) rcs $@ $^
45
46 # Copy headers to temp
47 .PHONY: tmpheaders
48 tmpheaders: $(TMP)/$(pkgincludedir)
49         $(CP) $(SRC)/*.h $<
50
51 $(TMP)/$(pkgincludedir):
52         mkdir -p $@
53
54 # Library object file
55 $(TMP)/%.o: $(SRC)/%.cpp $(wildcard $(SRC)/*.h)
56         echo "Compiling $(LIBRARY)/$(notdir $(basename $@))"
57         $(CXX) $(PIC) $(CXXFLAGS) -c $< -o $@
58
59 # Installs
60 .PHONY: install
61 install: install_lib
62
63 $(TGT)/$(pkgincludedir):
64         mkdir -p $@
65
66 $(TGT)/$(libdir):
67         mkdir -p $@
68
69 .PHONY: install_headers
70 install_headers: $(TGT)/$(pkgincludedir)
71         echo "Installing $(LIBRARY) headers to $<"
72         $(CP) $(SRC)/*.h $<
73
74 .PHONY: install_lib
75 install_lib: $(TGT)/$(libdir) $(TMP)/$(LIBFILE)$(SHARED)
76         echo "Installing dynamic library to $<"
77         $(CP) $(TMP)/$(LIBFILE)$(SHARED) $<
78
79 .PHONY: install_staticlib
80 install_staticlib: $(TGT)/$(libdir) $(TMP)/$(LIBFILE)$(STATIC)
81         echo "Installing static library to $<"
82         $(CP) $(TMP)/$(LIBFILE)$(STATIC) $<