File: Makefile

package info (click to toggle)
libnfo 1.0.1-1.1
  • links: PTS
  • area: main
  • in suites: buster, stretch
  • size: 340 kB
  • ctags: 382
  • sloc: ansic: 1,801; sh: 777; makefile: 246
file content (117 lines) | stat: -rw-r--r-- 3,200 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
ifeq (,$(wildcard ../config.mak))
$(error "../config.mak is not present, run configure !")
endif
include ../config.mak

LIBNAME = libnfo
STATIC_LIBNAME = $(LIBNAME).a
SHARED_LIBNAME = $(LIBNAME).so
SHARED_LIBNAME_VERSION = $(SHARED_LIBNAME).$(VERSION)
SHARED_LIBNAME_MAJOR = $(SHARED_LIBNAME).$(shell echo $(VERSION) | cut -f1 -d.)
SHARED_LIBNAME_FLAGS = -shared -Wl,-soname,$(SHARED_LIBNAME_MAJOR)

ifeq ($(BUILD_STATIC),yes)
  BUILD_RULES += lib_static
endif
ifeq ($(BUILD_SHARED),yes)
  BUILD_RULES += lib_shared
  ifeq ($(BUILD_DYLIB),yes)
    SHARED_LIBNAME         = ${LIBNAME}.dylib
    SHARED_LIBNAME_VERSION = $(LIBNAME).$(VERSION).dylib
    SHARED_LIBNAME_MAJOR   = $(LIBNAME).$(shell echo $(VERSION) | cut -f1 -d.).dylib
    SHARED_LIBNAME_FLAGS   = -dynamiclib -Wl,-headerpad_max_install_names,-undefined,dynamic_lookup,-install_name,$(SHARED_LIBNAME_VERSION)
  else
    ifeq ($(BUILD_MINGW32),yes)
      SHARED_LIBNAME         = $(LIBNAME)-$(shell echo $(VERSION) | cut -f1 -d.).dll
      SHARED_LIBNAME_VERSION = $(SHARED_LIBNAME)
      SHARED_LIBNAME_MAJOR   = $(SHARED_LIBNAME)
      SHARED_LIBNAME_FLAGS   = -shared -Wl,--out-implib=$(LIBNAME).dll.a -Wl,--export-all-symbols -Wl,--enable-auto-import
    endif
  endif
endif

SRCS =  \
	nfo.c \
	nfo_osdep.c \
	nfo_priv.c \
	nfo_xml_utils.c \
	nfo_xml_parser.c \

EXTRADIST = \
	nfo.h \
	nfo_osdep.h \
	nfo_priv.h \
	nfo_xml_parser.h \
	nfo_xml_utils.h \

OBJS = $(SRCS:.c=.o)

.SUFFIXES: .c .o

all: depend $(BUILD_RULES)

.c.o:
	$(CC) -c $(OPTFLAGS) $(CFLAGS) $(CFG_CPPFLAGS) $(CPPFLAGS) -o $@ $<

lib_static: $(STATIC_LIBNAME)

lib_shared: $(SHARED_LIBNAME)

$(STATIC_LIBNAME): $(OBJS)
	$(AR) r $(STATIC_LIBNAME) $(OBJS)
	$(RANLIB) $(STATIC_LIBNAME)

$(SHARED_LIBNAME): $(OBJS)
	$(CC) $(SHARED_LIBNAME_FLAGS) \
	  $(OBJS) $(CFG_LDFLAGS) $(EXTRALIBS) $(LDFLAGS) -o $(SHARED_LIBNAME_VERSION)
	if [ $(BUILD_MINGW32) = no ]; then \
	  $(LN) -sf $(SHARED_LIBNAME_VERSION) $(SHARED_LIBNAME_MAJOR); \
	  $(LN) -sf $(SHARED_LIBNAME_MAJOR) $(SHARED_LIBNAME); \
	fi

clean:
	rm -f *.o *.a *.so* *.dll
	rm -f .depend

install: $(BUILD_RULES)
	$(INSTALL) -d $(libdir)
	[ $(BUILD_STATIC) = yes ] && $(INSTALL) -c $(STATIC_LIBNAME) $(libdir); \
	if [ $(BUILD_SHARED) = yes ]; then \
	  if [ $(BUILD_MINGW32) = no ]; then \
	    $(INSTALL) -c $(SHARED_LIBNAME_VERSION) $(libdir); \
	    $(LN) -sf $(SHARED_LIBNAME_VERSION) $(libdir)/$(SHARED_LIBNAME_MAJOR); \
	    $(LN) -sf $(SHARED_LIBNAME_MAJOR) $(libdir)/$(SHARED_LIBNAME); \
	  else \
	    $(INSTALL) -c $(SHARED_LIBNAME_VERSION) $(bindir); \
	    $(INSTALL) -c $(LIBNAME).dll.a $(libdir); \
	  fi \
	fi
	$(INSTALL) -d $(includedir)
	$(INSTALL) -c -m 644 nfo.h $(includedir)

uninstall:
	if [ $(BUILD_MINGW32) = yes ]; then \
	  rm -f $(bindir)/$(SHARED_LIBNAME); \
	  rm -f $(libdir)/$(LIBNAME).dll.a; \
	fi
	rm -f $(libdir)/$(STATIC_LIBNAME)
	rm -f $(libdir)/$(SHARED_LIBNAME)*
	rm -f $(includedir)/nfo.h

depend:
	$(CC) -MM $(CFLAGS) $(CFG_CPPFLAGS) $(CPPFLAGS) $(SRCS) 1>.depend

.PHONY: clean depend
.PHONY: uninstall

dist-all:
	cp $(EXTRADIST) $(SRCS) Makefile $(DIST)

.PHONY: dist-all

#
# include dependency files if they exist
#
ifneq ($(wildcard .depend),)
include .depend
endif