forked from Microsemi/switchtec-user
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.in
200 lines (160 loc) · 5.87 KB
/
Makefile.in
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
# @configure_input@
########################################################################
##
## Microsemi Switchtec(tm) PCIe Management Library
## Copyright (c) 2017, Microsemi Corporation
##
## Permission is hereby granted, free of charge, to any person obtaining a
## copy of this software and associated documentation files (the "Software"),
## to deal in the Software without restriction, including without limitation
## the rights to use, copy, modify, merge, publish, distribute, sublicense,
## and/or sell copies of the Software, and to permit persons to whom the
## Software is furnished to do so, subject to the following conditions:
##
## The above copyright notice and this permission notice shall be included
## in all copies or substantial portions of the Software.
##
## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
## OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
## THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
## OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
## ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
## OTHER DEALINGS IN THE SOFTWARE.
##
########################################################################
OBJDIR ?= build
DESTDIR ?=
PREFIX ?= /usr/local
RPMBUILD ?= rpmbuild
BINDIR ?= $(DESTDIR)$(PREFIX)/bin
LIBDIR ?= $(DESTDIR)$(PREFIX)/lib
INCDIR ?= $(DESTDIR)$(PREFIX)/include
SYSCONFDIR ?= $(DESTDIR)/etc
CC=@CC@
WINDRES=@WINDRES@
override CPPFLAGS+=@CPPFLAGS@
override CPPFLAGS+=-I. -Iinc -I$(OBJDIR) -DCOMPLETE_ENV=\"SWITCHTEC_COMPLETE\"
override CFLAGS+=-g -Wall -Wno-initializer-overrides @CFLAGS@
DEPFLAGS= -MT $@ -MMD -MP -MF $(OBJDIR)/$*.d
LDLIBS=@LIBS@
override LDFLAGS+=@LDFLAGS@
LIB_SRCS=$(wildcard lib/*.c) $(wildcard lib/platform/*.c)
CLI_SRCS=$(wildcard cli/*.c)
LIB_OBJS=$(addprefix $(OBJDIR)/, $(patsubst %.c,%.o, $(LIB_SRCS)))
CLI_OBJS=$(addprefix $(OBJDIR)/, $(patsubst %.c,%.o, $(CLI_SRCS)))
STLIBNAME ?= libswitchtec.a
MACHINE=$(shell $(CC) -dumpmachine)
ifeq ($(findstring mingw,$(MACHINE)),mingw)
EXENAME ?= switchtec.exe
INSTEXENAME ?= switchtec
SHLIBNAME ?= switchtec.dll
IMPLIBNAME ?= libswitchtec.dll.a
override LDFLAGS += -Wl,--out-implib,$(IMPLIBNAME)
SHLDLIBS = -lsetupapi
LDLIBS += -lsetupapi
LDCONFIG=
override CPPFLAGS += -DNTDDI_VERSION=NTDDI_VISTA -D_WIN32_WINNT=_WIN32_WINNT_VISTA
else
EXENAME ?= switchtec
INSTEXENAME ?= $(EXENAME)
SHLIBNAME ?= libswitchtec.so
IMPLIBNAME ?= $(SHLIBNAME)
LDCONFIG=ldconfig
override CFLAGS += -fPIC
endif
ifneq ($(WINDRES), )
CLI_OBJS += $(OBJDIR)/cli/cli.o
LIB_OBJS += $(OBJDIR)/lib/lib.o
endif
ifneq ($(V), 1)
Q=@
else
NQ=:
endif
ifeq ($(W), 1)
CFLAGS += -Werror
endif
compile: $(STLIBNAME) $(SHLIBNAME) $(EXENAME) examples/temp
clean:
$(Q)rm -rf $(STLIBNAME) $(SHLIBNAME) $(EXENAME) $(OBJDIR) *.a \
examples/temp examples/*.o
distclean: clean
$(Q)rm -rf config.log config.status *.lib *.exe *.so *.dll build* \
Makefile autom4te.cache *.tar* switchtec.spec
$(OBJDIR)/version.h $(OBJDIR)/version.mk: FORCE $(OBJDIR)
@$(SHELL_PATH) ./VERSION-GEN
-include $(OBJDIR)/version.mk
$(OBJDIR):
$(Q)mkdir -p $(OBJDIR)/cli $(OBJDIR)/lib $(OBJDIR)/lib/platform
$(OBJDIR)/%.o: %.c | $(OBJDIR)
@$(NQ) echo " CC $<"
$(Q)$(COMPILE.c) $(DEPFLAGS) $< -o $@
$(OBJDIR)/%.o: %.rc $(OBJDIR)/version.h | $(OBJDIR)
@$(NQ) echo " RC $<"
$(Q)$(WINDRES) $(CPPFLAGS) $< $@
$(STLIBNAME): $(LIB_OBJS)
@$(NQ) echo " AR $@"
$(Q)$(AR) rDsc $@ $^
$(SHLIBNAME): $(LIB_OBJS)
@$(NQ) echo " LD $@"
$(Q)$(LINK.o) -shared $^ $(SHLDLIBS) -o $@
$(EXENAME): $(CLI_OBJS) $(STLIBNAME)
@$(NQ) echo " LD $@"
$(Q)$(LINK.o) $^ $(LDLIBS) -o $@
examples/%.o: examples/%.c
@$(NQ) echo " CC $<"
$(Q)$(COMPILE.c) $(DEPFLAGS) $< -o $@
examples/%: examples/%.o | $(SHLIBNAME)
@$(NQ) echo " LD $@"
$(Q)$(LINK.o) $^ $(IMPLIBNAME) -o $@
install-bash-completion:
@$(NQ) echo " INSTALL $(SYSCONFDIR)/bash_completion.d/bash-switchtec-completion.sh"
$(Q)install -d $(SYSCONFDIR)/bash_completion.d
$(Q)install -m 644 -T ./completions/bash-switchtec-completion.sh \
$(SYSCONFDIR)/bash_completion.d/switchtec
install-bin: compile
$(Q)install -d $(BINDIR) $(LIBDIR)
@$(NQ) echo " INSTALL $(BINDIR)/$(INSTEXENAME)"
$(Q)install -s $(EXENAME) $(BINDIR)/$(INSTEXENAME)
@$(NQ) echo " INSTALL $(LIBDIR)/$(STLIBNAME)"
$(Q)install -m 0664 $(STLIBNAME) $(LIBDIR)
@$(NQ) echo " INSTALL $(LIBDIR)/$(IMPLIBNAME).$(VERSION)"
$(Q)install $(IMPLIBNAME) $(LIBDIR)/$(IMPLIBNAME).$(VERSION)
@$(NQ) echo " INSTALL $(LIBDIR)/$(IMPLIBNAME)"
$(Q)ln -fs $(LIBDIR)/$(IMPLIBNAME).$(VERSION) \
$(LIBDIR)/$(IMPLIBNAME)
@$(NQ) echo " INSTALL $(INCDIR)/switchtec"
@$(Q)mkdir -p $(INCDIR)
@$(Q)cp -r inc/switchtec $(INCDIR)
@$(NQ) echo " LDCONFIG"
$(Q)$(LDCONFIG)
install: install-bin install-bash-completion
uninstall:
@$(NQ) echo " UNINSTALL $(BINDIR)/$(INSTEXENAME)"
$(Q)rm -f $(BINDIR)/$(INSTEXENAME)
@$(NQ) echo " UNINSTALL $(LIBDIR)/$(STLIBNAME)"
$(Q)rm -f $(LIBDIR)/$(STLIBNAME)
@$(NQ) echo " UNINSTALL $(LIBDIR)/$(IMPLIBNAME)"
$(Q)rm -f $(LIBDIR)/$(IMPLIBNAME)*
@$(NQ) echo " UNINSTALL $(INCDIR)/switchtec"
@$(Q)rm -rf $(INCDIR)/switchtec
@$(NQ) echo " LDCONFIG"
$(Q)$(LDCONFIG)
switchtec.spec: switchtec.spec.in $(OBJDIR)/version.mk
sed -e 's/@@VERSION@@/$(VERSION)/g' < $< | sed -e 's/@@RELEASE@@/$(RELEASE)/g' > $@+
mv $@+ $@
PKG=switchtec-$(VERSION)-$(RELEASE)
dist: switchtec.spec
git archive --format=tar --prefix=$(PKG)/ HEAD > $(PKG).tar
@echo $(VERSION)-$(RELEASE) > version
tar -rf $(PKG).tar --xform="s%^%$(PKG)/%" switchtec.spec version
xz -f $(PKG).tar
rm -f version
rpm: dist
$(RPMBUILD) -ta $(PKG).tar.xz
doc:
make -C doc
.PHONY: clean compile install unintsall install-bin install-bash-completion doc
.PHONY: FORCE dist rpm
-include $(patsubst %.o,%.d,$(LIB_OBJS) $(CLI_OBJS))