@@ -13,7 +13,8 @@
BOARD_TARGETS = tools_build romfs_build clients_build stage1 subdirs
SUBDIRS = slof rtas
-COMMON_LIBS = libc libipmi libbootmsg libbases libnvram libelf libusb libbcm
+COMMON_LIBS = libc libipmi libbootmsg libbases libnvram libelf libusb \
+ libbcm libnet
all: $(BOARD_TARGETS)
$(MAKE) boot_rom.bin
@@ -14,8 +14,8 @@ BOARD_TARGETS = tools_build romfs_build clients_build stage1 subdirs
SUBDIRS = slof
-COMMON_LIBS = libc libbootmsg libbases libnvram libelf libhvcall libvirtio libusb \
- libveth libe1k
+COMMON_LIBS = libc libbootmsg libbases libnvram libelf libhvcall libvirtio \
+ libusb libveth libe1k libnet
all: $(BOARD_TARGETS)
$(MAKE) boot_rom.bin
@@ -17,7 +17,7 @@ include $(TOP)/make.rules
OBJS = kernel/kernel.o oflib/oflib.o libc/libc-glue.o app/app.o
.PHONY : subdirs clean depend mrproper
-CLIENTLIBS = $(LIBCMNDIR)/libelf.a $(LIBCMNDIR)/libc.a
+CLIENTLIBS = $(LIBCMNDIR)/libelf.a $(LIBCMNDIR)/libnet.a $(LIBCMNDIR)/libc.a
all: .depend subdirs
$(MAKE) client
@@ -16,10 +16,10 @@ export TOP
endif
include $(TOP)/make.rules
-CFLAGS +=$(ADDCFLAGS) -Inetlib
+CFLAGS +=$(ADDCFLAGS) -I$(LIBCMNDIR)/libnet
OBJS = main.o
-OBJDIRS = netlib/netlib.o netapps/netboot.o
+OBJDIRS = netapps/netboot.o
OBJDIRS += netapps/ping.o
OBJDIRS += netapps/args.o
@@ -16,7 +16,7 @@ ifndef TOP
endif
include $(TOP)/make.rules
-CFLAGS += -I.. -I../netlib -I../../../../lib/ -Wall -W
+CFLAGS += -I.. -I$(LIBCMNDIR)/libnet -I$(LIBCMNDIR) -Wall -W
OBJS = netboot.o ping.o args.o
@@ -11,7 +11,7 @@
# ****************************************************************************/
SUBDIRS = libc libipmi libbootmsg libbases libnvram libelf libhvcall libvirtio \
- libusb libveth libe1k libbcm
+ libusb libveth libe1k libbcm libnet
all: subdirs
similarity index 50%
rename from clients/net-snk/app/netlib/Makefile
rename to lib/libnet/Makefile
@@ -16,27 +16,36 @@ ifndef TOP
endif
include $(TOP)/make.rules
-CFLAGS += -I../netapps
+CFLAGS += -I. -I.. -I../libc/include
+CFLAGS += -I../../clients/net-snk/app/netapps -I../../clients/net-snk/include
-ifeq ($(SNK_USE_MTFTP), 1)
-CFLAGS += -DUSE_MTFTP
-endif
+SRCS = ethernet.c ipv4.c udp.c tcp.c dns.c bootp.c dhcp.c tftp.c \
+ ipv6.c dhcpv6.c icmpv6.c ndp.c
-OBJS = ethernet.o ipv4.o udp.o tcp.o dns.o bootp.o \
- dhcp.o ipv6.o dhcpv6.o icmpv6.o ndp.o
+OBJS = $(SRCS:%.c=%.o)
-ifeq ($(SNK_USE_MTFTP), 1)
-OBJS += mtftp.o
-else
-OBJS += tftp.o
-endif
+TARGET = ../libnet.a
+
+all: $(TARGET)
+
+$(TARGET): $(OBJS)
+ $(AR) -rc $@ $(OBJS)
+ $(RANLIB) $@
+
+clean:
+ $(RM) $(TARGET) $(OBJS)
+
+distclean: clean
+ $(RM) Makefile.dep
-all: netlib.o
-netlib.o: $(OBJS)
- $(LD) $(LDFLAGS) $^ -o $@ -r
+# Rules for creating the dependency file:
+depend:
+ $(RM) Makefile.dep
+ $(MAKE) Makefile.dep
-clean:
- $(RM) -f *.o *.a *.i
+Makefile.dep: Makefile
+ $(CC) -M $(CPPFLAGS) $(CFLAGS) $(SRCS) > Makefile.dep
-include $(TOP)/make.depend
+# Include dependency file if available:
+-include Makefile.dep
similarity index 100%
rename from clients/net-snk/app/netlib/bootp.c
rename to lib/libnet/bootp.c
similarity index 100%
rename from clients/net-snk/app/netlib/dhcp.c
rename to lib/libnet/dhcp.c
similarity index 100%
rename from clients/net-snk/app/netlib/dhcp.h
rename to lib/libnet/dhcp.h
similarity index 100%
rename from clients/net-snk/app/netlib/dhcpv6.c
rename to lib/libnet/dhcpv6.c
similarity index 100%
rename from clients/net-snk/app/netlib/dhcpv6.h
rename to lib/libnet/dhcpv6.h
similarity index 100%
rename from clients/net-snk/app/netlib/dns.c
rename to lib/libnet/dns.c
similarity index 100%
rename from clients/net-snk/app/netlib/dns.h
rename to lib/libnet/dns.h
similarity index 100%
rename from clients/net-snk/app/netlib/ethernet.c
rename to lib/libnet/ethernet.c
similarity index 100%
rename from clients/net-snk/app/netlib/ethernet.h
rename to lib/libnet/ethernet.h
similarity index 100%
rename from clients/net-snk/app/netlib/icmpv6.c
rename to lib/libnet/icmpv6.c
similarity index 100%
rename from clients/net-snk/app/netlib/icmpv6.h
rename to lib/libnet/icmpv6.h
similarity index 100%
rename from clients/net-snk/app/netlib/ipv4.c
rename to lib/libnet/ipv4.c
similarity index 100%
rename from clients/net-snk/app/netlib/ipv4.h
rename to lib/libnet/ipv4.h
similarity index 100%
rename from clients/net-snk/app/netlib/ipv6.c
rename to lib/libnet/ipv6.c
similarity index 100%
rename from clients/net-snk/app/netlib/ipv6.h
rename to lib/libnet/ipv6.h
similarity index 100%
rename from clients/net-snk/app/netlib/ndp.c
rename to lib/libnet/ndp.c
similarity index 100%
rename from clients/net-snk/app/netlib/ndp.h
rename to lib/libnet/ndp.h
similarity index 100%
rename from clients/net-snk/app/netlib/tcp.c
rename to lib/libnet/tcp.c
similarity index 100%
rename from clients/net-snk/app/netlib/tcp.h
rename to lib/libnet/tcp.h
similarity index 100%
rename from clients/net-snk/app/netlib/tftp.c
rename to lib/libnet/tftp.c
similarity index 100%
rename from clients/net-snk/app/netlib/tftp.h
rename to lib/libnet/tftp.h
similarity index 100%
rename from clients/net-snk/app/netlib/udp.c
rename to lib/libnet/udp.c
similarity index 100%
rename from clients/net-snk/app/netlib/udp.h
rename to lib/libnet/udp.h
When we want to link the network stack to other parts of the firmware later (paflof), we've got to turn it into a proper library first. Note: Make sure to run "make distclean" after this patch, so that the dependencies for the moved files get rebuilt properly. Signed-off-by: Thomas Huth <thuth@redhat.com> --- board-js2x/Makefile | 3 +- board-qemu/Makefile | 4 +- clients/net-snk/Makefile | 2 +- clients/net-snk/app/Makefile | 4 +- clients/net-snk/app/netapps/Makefile | 2 +- lib/Makefile | 2 +- .../net-snk/app/netlib => lib/libnet}/Makefile | 43 +++++++++++++--------- {clients/net-snk/app/netlib => lib/libnet}/bootp.c | 0 {clients/net-snk/app/netlib => lib/libnet}/dhcp.c | 0 {clients/net-snk/app/netlib => lib/libnet}/dhcp.h | 0 .../net-snk/app/netlib => lib/libnet}/dhcpv6.c | 0 .../net-snk/app/netlib => lib/libnet}/dhcpv6.h | 0 {clients/net-snk/app/netlib => lib/libnet}/dns.c | 0 {clients/net-snk/app/netlib => lib/libnet}/dns.h | 0 .../net-snk/app/netlib => lib/libnet}/ethernet.c | 0 .../net-snk/app/netlib => lib/libnet}/ethernet.h | 0 .../net-snk/app/netlib => lib/libnet}/icmpv6.c | 0 .../net-snk/app/netlib => lib/libnet}/icmpv6.h | 0 {clients/net-snk/app/netlib => lib/libnet}/ipv4.c | 0 {clients/net-snk/app/netlib => lib/libnet}/ipv4.h | 0 {clients/net-snk/app/netlib => lib/libnet}/ipv6.c | 0 {clients/net-snk/app/netlib => lib/libnet}/ipv6.h | 0 {clients/net-snk/app/netlib => lib/libnet}/ndp.c | 0 {clients/net-snk/app/netlib => lib/libnet}/ndp.h | 0 {clients/net-snk/app/netlib => lib/libnet}/tcp.c | 0 {clients/net-snk/app/netlib => lib/libnet}/tcp.h | 0 {clients/net-snk/app/netlib => lib/libnet}/tftp.c | 0 {clients/net-snk/app/netlib => lib/libnet}/tftp.h | 0 {clients/net-snk/app/netlib => lib/libnet}/udp.c | 0 {clients/net-snk/app/netlib => lib/libnet}/udp.h | 0 30 files changed, 35 insertions(+), 25 deletions(-) rename {clients/net-snk/app/netlib => lib/libnet}/Makefile (50%) rename {clients/net-snk/app/netlib => lib/libnet}/bootp.c (100%) rename {clients/net-snk/app/netlib => lib/libnet}/dhcp.c (100%) rename {clients/net-snk/app/netlib => lib/libnet}/dhcp.h (100%) rename {clients/net-snk/app/netlib => lib/libnet}/dhcpv6.c (100%) rename {clients/net-snk/app/netlib => lib/libnet}/dhcpv6.h (100%) rename {clients/net-snk/app/netlib => lib/libnet}/dns.c (100%) rename {clients/net-snk/app/netlib => lib/libnet}/dns.h (100%) rename {clients/net-snk/app/netlib => lib/libnet}/ethernet.c (100%) rename {clients/net-snk/app/netlib => lib/libnet}/ethernet.h (100%) rename {clients/net-snk/app/netlib => lib/libnet}/icmpv6.c (100%) rename {clients/net-snk/app/netlib => lib/libnet}/icmpv6.h (100%) rename {clients/net-snk/app/netlib => lib/libnet}/ipv4.c (100%) rename {clients/net-snk/app/netlib => lib/libnet}/ipv4.h (100%) rename {clients/net-snk/app/netlib => lib/libnet}/ipv6.c (100%) rename {clients/net-snk/app/netlib => lib/libnet}/ipv6.h (100%) rename {clients/net-snk/app/netlib => lib/libnet}/ndp.c (100%) rename {clients/net-snk/app/netlib => lib/libnet}/ndp.h (100%) rename {clients/net-snk/app/netlib => lib/libnet}/tcp.c (100%) rename {clients/net-snk/app/netlib => lib/libnet}/tcp.h (100%) rename {clients/net-snk/app/netlib => lib/libnet}/tftp.c (100%) rename {clients/net-snk/app/netlib => lib/libnet}/tftp.h (100%) rename {clients/net-snk/app/netlib => lib/libnet}/udp.c (100%) rename {clients/net-snk/app/netlib => lib/libnet}/udp.h (100%)