+IWINFO_SOVERSION = $(if $(SOVERSION),$(SOVERSION),0)
+
IWINFO_BACKENDS = $(BACKENDS)
IWINFO_CFLAGS = $(CFLAGS) -std=gnu99 -fstrict-aliasing -Iinclude
IWINFO_LDFLAGS = -luci -lubox -lubus
IWINFO_LIB = libiwinfo.so
-IWINFO_LIB_LDFLAGS = $(LDFLAGS) -shared
+IWINFO_LIB_LDFLAGS = $(LDFLAGS) -shared -Wl,-soname -Wl,$(IWINFO_LIB).$(IWINFO_SOVERSION)
IWINFO_LIB_OBJ = iwinfo_utils.o iwinfo_wext.o iwinfo_wext_scan.o iwinfo_lib.o
IWINFO_LUA = iwinfo.so
endif
+compile: clean $(IWINFO_LIB) $(IWINFO_LUA) $(IWINFO_CLI)
+
%.o: %.c
$(CC) $(IWINFO_CFLAGS) $(FPIC) -c -o $@ $<
-compile: clean $(IWINFO_LIB_OBJ) $(IWINFO_LUA_OBJ) $(IWINFO_CLI_OBJ)
- $(CC) $(IWINFO_LDFLAGS) $(IWINFO_LIB_LDFLAGS) -o $(IWINFO_LIB) $(IWINFO_LIB_OBJ)
+$(IWINFO_LIB): $(IWINFO_LIB_OBJ)
+ $(CC) $(IWINFO_LDFLAGS) $(IWINFO_LIB_LDFLAGS) -o $(IWINFO_LIB).$(IWINFO_SOVERSION) $(IWINFO_LIB_OBJ) && \
+ ln -sf $(IWINFO_LIB).$(IWINFO_SOVERSION) $(IWINFO_LIB)
+
+$(IWINFO_LUA): $(IWINFO_LUA_OBJ)
$(CC) $(IWINFO_LDFLAGS) $(IWINFO_LUA_LDFLAGS) -o $(IWINFO_LUA) $(IWINFO_LUA_OBJ)
+
+$(IWINFO_CLI): $(IWINFO_CLI_OBJ)
$(CC) $(IWINFO_LDFLAGS) $(IWINFO_CLI_LDFLAGS) -o $(IWINFO_CLI) $(IWINFO_CLI_OBJ)
clean: