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