]> git.tdb.fi Git - libs/core.git/blob - Makefile
Fixed Makefile linker flags
[libs/core.git] / Makefile
1 LIBRARY         = framework
2 LIBFILE         = libmspframework
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 `pkg-config --cflags sigc++-2.0`
16 CXXFLAGS        = $(CFLAGS)
17 LIBLDFLAGS      = `pkg-config --libs sigc++-2.0`
18 MAKEFLAGS       += -s --no-print-directory
19
20 PIC             = -fPIC
21 SHARED          = .so
22 STATIC          = .a
23
24 SRC             = source
25 LIBOBJS         = $(addprefix $(TMP)/, $(addsuffix .o, $(notdir $(basename $(wildcard $(SRC)/*.cpp)))))
26
27 pkgincludedir   = include/msp/$(LIBRARY)
28 libdir          = lib
29
30 .PHONY: all
31 all: $(TMP) $(TMP)/$(LIBFILE)$(SHARED) $(TMP)/$(LIBFILE)$(STATIC) tmpheaders
32
33 # Create temp directory
34 $(TMP):
35         mkdir -p $@
36
37 # Dynamic library
38 $(TMP)/$(LIBFILE)$(SHARED): $(LIBOBJS)
39         echo "Compiling $(notdir $@)"
40         $(CXX) $^ -shared -o $@ $(LIB) $(LIBLDFLAGS)
41
42 # Static library
43 $(TMP)/$(LIBFILE)$(STATIC): $(LIBOBJS)
44         echo "Compiling $(notdir $@)"
45         $(AR) rcs $@ $^
46
47 # Copy headers to temp
48 .PHONY: tmpheaders
49 tmpheaders: $(TMP)/$(pkgincludedir)
50         $(CP) $(SRC)/*.h $<
51
52 $(TMP)/$(pkgincludedir):
53         mkdir -p $@
54
55 # Library object file
56 $(TMP)/%.o: $(SRC)/%.cpp $(wildcard $(SRC)/*.h)
57         echo "Compiling $(LIBRARY)/$(notdir $(basename $@))"
58         $(CXX) $(PIC) $(CXXFLAGS) -c $< -o $@
59
60 # Installs
61 .PHONY: install
62 install: install_headers install_lib install_staticlib
63
64 $(TGT)/$(pkgincludedir):
65         mkdir -p $@
66
67 $(TGT)/$(libdir):
68         mkdir -p $@
69
70 .PHONY: install_headers
71 install_headers: $(TGT)/$(pkgincludedir)
72         echo "Installing $(LIBRARY) headers to $<"
73         $(CP) $(SRC)/*.h $<
74
75 .PHONY: install_lib
76 install_lib: $(TGT)/$(libdir) $(TMP)/$(LIBFILE).so
77         echo "Installing dynamic library to $<"
78         $(CP) $(TMP)/$(LIBFILE).so $<
79
80 .PHONY: install_staticlib
81 install_staticlib: $(TGT)/$(libdir) $(TMP)/$(LIBFILE).a
82         echo "Installing static library to $<"
83         $(CP) $(TMP)/$(LIBFILE).a $<