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