1
0
mirror of https://github.com/corundum/corundum.git synced 2025-01-16 08:12:53 +08:00

Peel off common software components into a static library

Signed-off-by: Alex Forencich <alex@alexforencich.com>
This commit is contained in:
Alex Forencich 2022-04-19 01:45:01 -07:00
parent 030281b7fc
commit a1cd110074
14 changed files with 69 additions and 16 deletions

40
lib/mqnic/Makefile Normal file
View File

@ -0,0 +1,40 @@
PREFIX ?= /usr/local
INCDIR = $(DESTDIR)$(PREFIX)/include
LIBDIR = $(DESTDIR)$(PREFIX)/lib
DEVLIBDIR = $(LIBDIR)
CC ?= gcc
CFLAGS ?= -O3 -fPIC
CFLAGS += -Wall
CPPFLAGS +=
LIB = libmqnic.a
INCLUDES = mqnic.h mqnic_hw.h mqnic_ioctl.h reg_block.h
GENDEPFLAGS = -MD -MP -MF .$(@F).d
ALL_CFLAGS = $(CFLAGS) $(CPPFLAGS) $(GENDEPFLAGS)
all: $(LIB)
%.o: %.c
$(CC) $(ALL_CFLAGS) -c -o $@ $<
libmqnic.a: mqnic.o reg_block.o
ar rcs $@ $^
install:
install -d $(DEVLIBDIR) $(INCDIR)/mqnic
install -m 0644 $(LIB) $(DEVLIBDIR)
install -m 0644 $(INCLUDES) $(INCDIR)/mqnic
clean:
rm -f $(LIB)
rm -f *.o
rm -f .*.d
-include $(wildcard .*.d)
.PHONY: all install clean

View File

@ -32,6 +32,7 @@ either expressed or implied, of The Regents of the University of California.
*/
#include "mqnic.h"
#include "mqnic_ioctl.h"
#include <dirent.h>
#include <fcntl.h>

View File

@ -39,7 +39,6 @@ either expressed or implied, of The Regents of the University of California.
#include <unistd.h>
#include "mqnic_hw.h"
#include "mqnic_ioctl.h"
#include "reg_block.h"
#define mqnic_reg_read32(base, reg) (((volatile uint32_t *)(base))[(reg)/4])

1
lib/mqnic/mqnic_hw.h Symbolic link
View File

@ -0,0 +1 @@
../../modules/mqnic/mqnic_hw.h

1
lib/mqnic/mqnic_ioctl.h Symbolic link
View File

@ -0,0 +1 @@
../../modules/mqnic/mqnic_ioctl.h

View File

@ -6,7 +6,11 @@ CC ?= gcc
CFLAGS ?= -O3
CFLAGS += -Wall
CPPFLAGS += -I../modules/mqnic -I ../include
CPPFLAGS += -Ilib -Iinclude
LDFLAGS += -Llib/mqnic
LDLIBS += -lmqnic
LIBMQNIC = lib/mqnic/libmqnic.a
BIN = mqnic-config
BIN += mqnic-dump
@ -20,23 +24,28 @@ ALL_CFLAGS = $(CFLAGS) $(CPPFLAGS) $(GENDEPFLAGS)
all: $(BIN)
FORCE:
$(LIBMQNIC): FORCE
$(MAKE) -C $(dir $@) $(notdir $@)
%.o: %.c
$(CC) $(ALL_CFLAGS) -c -o $@ $<
mqnic-config: mqnic-config.o mqnic.o reg_block.o timespec.o
$(CC) $(ALL_CFLAGS) $(LDFLAGS) $^ -o $@
mqnic-config: mqnic-config.o timespec.o $(LIBMQNIC)
$(CC) $(ALL_CFLAGS) $(LDFLAGS) $^ -o $@ $(LDLIBS)
mqnic-dump: mqnic-dump.o mqnic.o reg_block.o
$(CC) $(ALL_CFLAGS) $(LDFLAGS) $^ -o $@
mqnic-dump: mqnic-dump.o $(LIBMQNIC)
$(CC) $(ALL_CFLAGS) $(LDFLAGS) $^ -o $@ $(LDLIBS)
mqnic-fw: mqnic-fw.o mqnic.o reg_block.o flash.o flash_spi.o flash_bpi.o fpga_id.o bitfile.o
$(CC) $(ALL_CFLAGS) $(LDFLAGS) $^ -o $@
mqnic-fw: mqnic-fw.o flash.o flash_spi.o flash_bpi.o fpga_id.o bitfile.o $(LIBMQNIC)
$(CC) $(ALL_CFLAGS) $(LDFLAGS) $^ -o $@ $(LDLIBS)
mqnic-bmc: mqnic-bmc.o mqnic.o reg_block.o
$(CC) $(ALL_CFLAGS) $(LDFLAGS) $^ -o $@
mqnic-bmc: mqnic-bmc.o $(LIBMQNIC)
$(CC) $(ALL_CFLAGS) $(LDFLAGS) $^ -o $@ $(LDLIBS)
perout: perout.o timespec.o
$(CC) $(ALL_CFLAGS) $(LDFLAGS) $^ -o $@
$(CC) $(ALL_CFLAGS) $(LDFLAGS) $^ -o $@ $(LDLIBS)
install:
install -d $(BINDIR)
@ -49,4 +58,4 @@ clean:
-include $(wildcard .*.d)
.PHONY: all install clean
.PHONY: all install clean FORCE

1
utils/include Symbolic link
View File

@ -0,0 +1 @@
../include/

1
utils/lib Symbolic link
View File

@ -0,0 +1 @@
../lib/

View File

@ -35,7 +35,7 @@ either expressed or implied, of The Regents of the University of California.
#include <stdlib.h>
#include <string.h>
#include "mqnic.h"
#include <mqnic/mqnic.h>
static void usage(char *name)
{

View File

@ -50,7 +50,7 @@ either expressed or implied, of The Regents of the University of California.
#include "timespec.h"
#include "mqnic.h"
#include <mqnic/mqnic.h>
#define NSEC_PER_SEC 1000000000

View File

@ -35,7 +35,7 @@ either expressed or implied, of The Regents of the University of California.
#include <stdlib.h>
#include <string.h>
#include "mqnic.h"
#include <mqnic/mqnic.h>
static void usage(char *name)
{

View File

@ -42,7 +42,7 @@ either expressed or implied, of The Regents of the University of California.
#include <sys/stat.h>
#include <linux/pci.h>
#include "mqnic.h"
#include <mqnic/mqnic.h>
#include "bitfile.h"
#include "flash.h"
#include "fpga_id.h"