liboptcfg
view Makefile @ 5:aca7267dfee0
fixed cross-compilation with mingw-w64
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Thu, 31 Aug 2017 05:59:19 +0300 |
parents | 8fd2858c6a29 |
children |
line source
1 # installation prefix, change it to install elsewhere
2 PREFIX = /usr/local
3 # -----------------------------
5 src = $(wildcard src/*.c)
6 obj = $(src:.c=.o)
7 name = optcfg
9 so_major = 0
10 so_minor = 1
12 alib = lib$(name).a
14 sodir = lib
16 CFLAGS = -pedantic -Wall -g
18 sys := $(shell uname -s | sed 's/MINGW.*/mingw/')
19 ifeq ($(sys), Darwin)
20 solib = lib$(name).dylib
21 shared = -dynamiclib
22 else ifeq ($(sys), mingw)
23 solib = lib$(name).dll
24 shared = -shared
25 sodir = bin
26 else
27 ldname = lib$(name).so
28 soname = lib$(name).so.$(so_major)
29 solib = lib$(name).so.$(so_major).$(so_minor)
30 shared = -shared -Wl,-soname=$(soname)
31 CFLAGS += -fPIC
32 endif
34 .PHONY: all
35 all: $(solib) $(alib)
37 $(solib): $(obj)
38 $(CC) -o $@ $(shared) $(obj) $(LDFLAGS)
40 $(alib): $(obj)
41 $(AR) rcs $@ $(obj)
43 .PHONY: clean
44 clean:
45 rm -f $(obj) $(alib) $(solib)
47 .PHONY: install
48 install:
49 mkdir -p $(DESTDIR)$(PREFIX)/bin $(DESTDIR)$(PREFIX)/include $(DESTDIR)$(PREFIX)/lib
50 cp src/optcfg.h $(DESTDIR)$(PREFIX)/include/optcfg.h
51 cp $(alib) $(DESTDIR)$(PREFIX)/lib/$(alib)
52 cp $(solib) $(DESTDIR)$(PREFIX)/$(sodir)/$(solib)
53 [ -n "$(soname)" ] && cd $(DESTDIR)$(PREFIX)/$(sodir) && \
54 rm -f $(soname) $(ldname) && \
55 ln -s $(solib) $(soname) && \
56 ln -s $(soname) $(ldname) || true
58 .PHONY: uninstall
59 uninstall:
60 rm -f $(DESTDIR)$(PREFIX)/include/optcfg.h
61 rm -f $(DESTDIR)$(PREFIX)/lib/$(alib)
62 rm -f $(DESTDIR)$(PREFIX)/$(sodir)/$(solib)
63 [ -n "$(soname)" ] && \
64 rm -f $(DESTDIR)$(PREFIX)/$(sodir)/$(soname) && \
65 rm -f $(DESTDIR)$(PREFIX)/$(sodir)/$(ldname) || true