6d5ec0e0f34bcd6d62865ccd02ec6a565d077c48
Stefan Schuermans rename "FlexiPix" to "Ether...

Stefan Schuermans authored 6 years ago

1) # EtherPix library
Stefan Schuermans v1.0.0

Stefan Schuermans authored 12 years ago

2) #
Stefan Schuermans update copyright year

Stefan Schuermans authored 6 years ago

3) # Copyright 2010-2017 Stefan Schuermans <stefan schuermans info>
Stefan Schuermans v1.0.0

Stefan Schuermans authored 12 years ago

4) #
5) # This program is free software: you can redistribute it and/or modify
6) # it under the terms of the GNU General Public License as published by
7) # the Free Software Foundation, version 3 of the License.
8) #
9) #
10) # This program is distributed in the hope that it will be useful,
11) # but WITHOUT ANY WARRANTY; without even the implied warranty of
12) # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13) # GNU General Public License for more details.
14) #
15) # You should have received a copy of the GNU Lesser General Public License
16) # along with this program. If not, see <http://www.gnu.org/licenses/>.
17) 
Stefan Schuermans rename "FlexiPix" to "Ether...

Stefan Schuermans authored 6 years ago

18) LIBTARGET := libetherpix
Stefan Schuermans v1.0.6

Stefan Schuermans authored 12 years ago

19) VER_MAJ   := 1
Stefan Schuermans add support for monochrome...

Stefan Schuermans authored 5 years ago

20) VER_MIN   := 3
Stefan Schuermans support multiple addresses...

Stefan Schuermans authored 6 years ago

21) VER_REV   := 0
Stefan Schuermans repair build (lib symlinking)

Stefan Schuermans authored 12 years ago

22) VERSION   := $(VER_MAJ).$(VER_MIN).$(VER_REV)
Stefan Schuermans v1.0.6

Stefan Schuermans authored 12 years ago

23) 
Stefan Schuermans enforce no warnings

Stefan Schuermans authored 7 years ago

24) CFLAGS     := -Wall -Wextra -Werror -O3
Stefan Schuermans rename "FlexiPix" to "Ether...

Stefan Schuermans authored 6 years ago

25) DEFINES    := -DETP_VER_MAJ=$(VER_MAJ) -DETP_VER_MIN=$(VER_MIN) \
26)               -DETP_VER_REV=$(VER_REV)
Stefan Schuermans v1.0.6

Stefan Schuermans authored 12 years ago

27) INCLUDES   := -Iinclude
28) SH_LDFLAGS :=
29) SH_LIBS    :=
30) EX_LDFLAGS := -Llib
Stefan Schuermans rename "FlexiPix" to "Ether...

Stefan Schuermans authored 6 years ago

31) EX_LIBS    := -letherpix -lm
Stefan Schuermans v1.0.6

Stefan Schuermans authored 12 years ago

32) STOW_DIR   := /usr/local/stow
33) DEF_PREFIX := /usr/local
34) 
35) OS_RAW := $(shell uname -s)
36) ifeq ($(OS_RAW),Linux)
37)   OS         := linux
38)   CC         := gcc
39)   AR         := ar
40)   RANLIB     := ranlib
41)   LEXT       := so
42)   LEXTSUF    := .$(VERSION)
43)   BSUF       :=
44)   INSTALL    := install
45)   CFLAGS     += -fPIC
46)   SH_LDFLAGS += -shared -Wl,-soname,$(LIBTARGET).so.$(VER_MAJ)
47)   EX_LDFLAGS += -Wl,-rpath,\$$ORIGIN/../../lib
48)   EX_LIBS    += -lpthread
49) endif
50) 
51) ifeq ($(OS_RAW),Darwin)
52)   OS         := darwin
53)   CC         := gcc
54)   AR         := ar
55)   RANLIB     := ranlib
56)   LEXT       := dylib
57)   LEXTSUF    :=
58)   BSUF       :=
59)   INSTALL    := install
60)   CFLAGS     += -fPIC
61)   SH_LDFLAGS += -dynamiclib
62)   EX_LIBS    += -lpthread
63) endif
64) 
65) ifeq ($(patsubst MINGW32%,MINGW32,$(OS_RAW)),MINGW32)
66)   OS         := mingw32
67)   CC         := gcc
68)   AR         := ar
69)   RANLIB     := ranlib
70)   LEXT       := dll
71)   LEXTSUF    :=
72)   BSUF       := .exe
73)   INSTALL    := install
74)   DEFINES    += -DWINDOWS
75)   SH_LDFLAGS += -shared
76)   SH_LIBS    += -lwsock32
77)   EX_LIBS    += -lwsock32
78) endif
79) 
Stefan Schuermans update Windows support

Stefan Schuermans authored 6 years ago

80) ifeq ($(CROSS_WIN),1)
81)   OS         := mingw32
82)   CC         := x86_64-w64-mingw32-gcc
83)   AR         := ar
84)   RANLIB     := ranlib
85)   LEXT       := dll
86)   LEXTSUF    :=
87)   BSUF       := .exe
88)   INSTALL    := install
89)   DEFINES    += -DWINDOWS
90)   SH_LDFLAGS += -shared
91)   SH_LIBS    += -lwsock32
92)   EX_LIBS    += -lwsock32
93) endif
94) 
Stefan Schuermans v1.0.6

Stefan Schuermans authored 12 years ago

95) ifeq ($(OS),)
96)   $(error unsupported operating system $(OS_RAW))
Stefan Schuermans v1.0.5

Stefan Schuermans authored 12 years ago

97) endif
Stefan Schuermans v1.0.0

Stefan Schuermans authored 12 years ago

98) 
Stefan Schuermans cleanup build system

Stefan Schuermans authored 6 years ago

99) SRCS      := $(wildcard src/*.c)
100) SRCS_BASE := $(notdir $(patsubst %.c,%,$(SRCS)))
101) DEPS      := $(addprefix obj/,$(addsuffix .d,$(SRCS_BASE)))
102) OBJS      := $(addprefix obj/,$(addsuffix .o,$(SRCS_BASE)))
103) 
104) EX_SRCS      := $(wildcard examples/src/*.c)
105) EX_SRCS_BASE := $(notdir $(patsubst %.c,%,$(EX_SRCS)))
106) EX_DEPS      := $(addprefix examples/obj/,$(addsuffix .d,$(EX_SRCS_BASE)))
107) EX_OBJS      := $(addprefix examples/obj/,$(addsuffix .o,$(EX_SRCS_BASE)))
108) EX_TARGETS   := $(addprefix examples/bin/,$(addsuffix $(BSUF),$(EX_SRCS_BASE)))
Stefan Schuermans v1.0.6

Stefan Schuermans authored 12 years ago

109) 
110) TARGET    := lib/$(LIBTARGET).a
111) SH_TARGET := lib/$(LIBTARGET).$(LEXT)$(LEXTSUF)
112) 
113) ENV_PREFIX := $(shell echo $$PREFIX)
Stefan Schuermans rename "FlexiPix" to "Ether...

Stefan Schuermans authored 6 years ago

114) STOW_PREFIX := $(STOW_DIR)/libetherpix-$(VERSION)
Stefan Schuermans v1.0.0

Stefan Schuermans authored 12 years ago

115) ifneq ($(ENV_PREFIX),)
Stefan Schuermans v1.0.6

Stefan Schuermans authored 12 years ago

116)   PREFIX := $(ENV_PREFIX)
Stefan Schuermans v1.0.0

Stefan Schuermans authored 12 years ago

117) else
118)   ifeq ($(shell if [ -d $(STOW_DIR) ]; then echo stow; fi),stow)
Stefan Schuermans v1.0.6

Stefan Schuermans authored 12 years ago

119)     PREFIX := $(STOW_PREFIX)
Stefan Schuermans v1.0.0

Stefan Schuermans authored 12 years ago

120)   else
Stefan Schuermans v1.0.6

Stefan Schuermans authored 12 years ago

121)     PREFIX := $(DEF_PREFIX)
Stefan Schuermans v1.0.0

Stefan Schuermans authored 12 years ago

122)   endif
123) endif
124) 
Stefan Schuermans v1.0.6

Stefan Schuermans authored 12 years ago

125) .PHONY: all clean install uninstall ver pack
Stefan Schuermans v1.0.0

Stefan Schuermans authored 12 years ago

126) .SECONDARY:
127) .SUFFIXES:
128) 
Stefan Schuermans cleanup build system

Stefan Schuermans authored 6 years ago

129) all: $(DEPS) $(TARGET) $(SH_TARGET) $(EX_DEPS) $(EX_TARGETS)
Stefan Schuermans v1.0.0

Stefan Schuermans authored 12 years ago

130) 
131) ifneq ($(MAKECMDGOALS),clean)
Stefan Schuermans improve deps

Stefan Schuermans authored 6 years ago

132)   -include $(DEPS)
Stefan Schuermans v1.0.0

Stefan Schuermans authored 12 years ago

133) endif
134) 
Stefan Schuermans cleanup build system

Stefan Schuermans authored 6 years ago

135) obj:
136) 	mkdir -p $@
Stefan Schuermans v1.0.0

Stefan Schuermans authored 12 years ago

137) 
Stefan Schuermans cleanup build system

Stefan Schuermans authored 6 years ago

138) lib:
139) 	mkdir -p $@
Stefan Schuermans v1.0.0

Stefan Schuermans authored 12 years ago

140) 
Stefan Schuermans cleanup build system

Stefan Schuermans authored 6 years ago

141) obj/%.d: src/%.c | obj
Stefan Schuermans use -o instead of -MF

Stefan Schuermans authored 6 years ago

142) 	$(CC) $(CFLAGS) $(DEFINES) $(INCLUDES) -MM -MT $(@:.d=.o) -o $@ $<
Stefan Schuermans v1.0.0

Stefan Schuermans authored 12 years ago

143) 
Stefan Schuermans cleanup build system

Stefan Schuermans authored 6 years ago

144) obj/%.o: src/%.c | obj
145) 	$(CC) $(CFLAGS) $(DEFINES) $(INCLUDES) -c -o $@ $<
Stefan Schuermans v1.0.0

Stefan Schuermans authored 12 years ago

146) 
Stefan Schuermans v1.0.6

Stefan Schuermans authored 12 years ago

147) $(TARGET): $(OBJS) | lib
Stefan Schuermans v1.0.0

Stefan Schuermans authored 12 years ago

148) 	$(AR) cr $@ $(filter-out lib,$+)
149) 	$(RANLIB) $@
150) 
Stefan Schuermans v1.0.6

Stefan Schuermans authored 12 years ago

151) $(SH_TARGET): $(OBJS) | lib
152) 	$(CC) $(SH_LDFLAGS) -o $@ $+ $(SH_LIBS)
153) ifeq ($(OS),linux)
154) 	cd $(dir $@); \
Stefan Schuermans fixed creation of symlinks...

Stefan Schuermans authored 12 years ago

155) 	  ln -sf $(notdir $@) \
156) 	         $(patsubst %.$(VER_REV),%,$(notdir $@))
Stefan Schuermans v1.0.6

Stefan Schuermans authored 12 years ago

157) 	cd $(dir $@); \
Stefan Schuermans fixed creation of symlinks...

Stefan Schuermans authored 12 years ago

158) 	  ln -sf $(patsubst %.$(VER_REV),%,$(notdir $@)) \
159) 	         $(patsubst %.$(VER_MIN).$(VER_REV),%,$(notdir $@))
Stefan Schuermans v1.0.6

Stefan Schuermans authored 12 years ago

160) 	cd $(dir $@); \
Stefan Schuermans fixed creation of symlinks...

Stefan Schuermans authored 12 years ago

161) 	  ln -sf $(patsubst %.$(VER_MIN).(VER_REV),%,$(notdir $@)) \
162) 	         $(patsubst %.$(VER_MAJ).$(VER_MIN).$(VER_REV),%,$(notdir $@))
Stefan Schuermans v1.0.6

Stefan Schuermans authored 12 years ago

163) endif
Stefan Schuermans v1.0.0

Stefan Schuermans authored 12 years ago

164) 
Stefan Schuermans cleanup build system

Stefan Schuermans authored 6 years ago

165) examples/obj:
166) 	mkdir -p $@
167) 
168) examples/bin:
169) 	mkdir -p $@
170) 
171) examples/obj/%.d: examples/src/%.c | examples/obj
Stefan Schuermans use -o instead of -MF

Stefan Schuermans authored 6 years ago

172) 	$(CC) $(CFLAGS) $(DEFINES) $(INCLUDES) -MM -MT $(@:.d=.o) -o $@ $<
Stefan Schuermans cleanup build system

Stefan Schuermans authored 6 years ago

173) 
174) examples/obj/%.o: examples/src/%.c | examples/obj
175) 	$(CC) $(CFLAGS) $(DEFINES) $(INCLUDES) -c -o $@ $<
176) 
177) examples/bin/%$(BSUF): examples/obj/%.o $(TARGET) $(SH_TARGET) | examples/bin
178) 	$(CC) $(EX_LDFLAGS) -o $@ $< $(EX_LIBS)
179) 
Stefan Schuermans v1.0.0

Stefan Schuermans authored 12 years ago

180) clean:
Stefan Schuermans cleanup build system

Stefan Schuermans authored 6 years ago

181) 	rm -rf obj lib examples/obj examples/bin
Stefan Schuermans v1.0.0

Stefan Schuermans authored 12 years ago

182) 
Stefan Schuermans v1.0.6

Stefan Schuermans authored 12 years ago

183) install: all
Stefan Schuermans rename "FlexiPix" to "Ether...

Stefan Schuermans authored 6 years ago

184) 	$(INSTALL) -d $(PREFIX)/include/etherpix
185) 	$(INSTALL) -m 644 -t $(PREFIX)/include/etherpix $(wildcard include/etherpix/*.h)
Stefan Schuermans v1.0.6

Stefan Schuermans authored 12 years ago

186) 	$(INSTALL) -d $(PREFIX)/lib
187) 	$(INSTALL) -m 644 -t $(PREFIX)/lib $(TARGET) $(SH_TARGET)
188) ifeq ($(OS),linux)
Stefan Schuermans fixed creation of symlinks...

Stefan Schuermans authored 12 years ago

189) 	ln -sf $(LIBTARGET).$(LEXT).$(VER_MAJ).$(VER_MIN).$(VER_REV) \
Stefan Schuermans v1.0.6

Stefan Schuermans authored 12 years ago

190) 	   $(PREFIX)/lib/$(LIBTARGET).$(LEXT).$(VER_MAJ).$(VER_MIN)
Stefan Schuermans fixed creation of symlinks...

Stefan Schuermans authored 12 years ago

191) 	ln -sf $(LIBTARGET).$(LEXT).$(VER_MAJ).$(VER_MIN) \
Stefan Schuermans v1.0.6

Stefan Schuermans authored 12 years ago

192) 	   $(PREFIX)/lib/$(LIBTARGET).$(LEXT).$(VER_MAJ)
193) endif
194) 
195) uninstall:
196) 	rm -f $(PREFIX)/lib/$(notdir $(SH_TARGET))
197) 	rm -f $(PREFIX)/lib/$(notdir $(TARGET))
Stefan Schuermans rename "FlexiPix" to "Ether...

Stefan Schuermans authored 6 years ago

198) 	rm -rf $(PREFIX)/include/etherpix