Initial commit of Pollcat library

This commit is contained in:
2022-06-28 15:25:57 -07:00
commit bbd4625d43
26 changed files with 3534 additions and 0 deletions

101
Makefile Normal file
View File

@@ -0,0 +1,101 @@
# Top-level Makefile
#
# This file is part of the Pollcat Library.
# Copyright (C) 2022 Expatria Technologies Inc.
# Contact: Morgan Hughes <morgan@expatria.ca>
#
# The Pollcat Library is free software: you can redistribute it and/or modify it under the
# terms of the the GNU Lesser General Public License as published by the Free Software
# Foundation; either version 3 of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received copies of the GNU General Public License and the GNU Lesser
# General Public License along with the Pollcat Library. If not, see
# https://www.gnu.org/licenses/
#
# vim:ts=4:noexpandtab
# Integrators should override these
PREFIX ?= /usr/local
export PREFIX DESTDIR
# version numbers
export MAJOR_VERSION := 0
export MINOR_VERSION := 1
export PATCH_VERSION := 0
# output names
export NAME = pollcat
export LNAME = $(NAME)
export ANAME = lib$(LNAME).a
export LDNAME = lib$(LNAME).so
export SONAME = $(LDNAME).$(MAJOR_VERSION)
export OUTPUT = $(SONAME).$(MINOR_VERSION).$(PATCH_VERSION)
# Setup CC/CFLAGS/LFLAGS to allow override
CFLAGS += -O2 -Iinclude -Wall -Werror -fpic
LDFLAGS += -shared
# Debug build
#CFLAGS += -g
# Release build
CFLAGS += -DNDEBUG
LDFLAGS += -s
# Objects list and export script are minimal
OBJS := src/pollcat.o
OBJS += src/timer.o
OBJS += src/struct.o
SCRIPTS := -Wl,--version-script,src/$(NAME).v
# normal build targets
all: $(ANAME) $(LDNAME) $(SONAME) $(OUTPUT)
$(MAKE) -C tests all
$(ANAME): $(OBJS)
$(AR) rcs $@ $^
$(OUTPUT): $(OBJS)
$(CC) $(LDFLAGS) -Wl,-soname,$(SONAME) $(SCRIPTS) -o$(OUTPUT) $(OBJS) $(LIBS)
$(SONAME): $(OUTPUT)
ln -sf $(OUTPUT) $(SONAME)
$(LDNAME): $(SONAME)
ln -sf $(SONAME) $(LDNAME)
%.o: %.c
$(CC) $(CFLAGS) -c $< -o $@
# install runtime libs to rootfs, and includes and static libs.
install: all
$(MAKE) rootfs
mkdir -p $(DESTDIR)$(PREFIX)/lib
install -m644 $(ANAME) $(DESTDIR)$(PREFIX)/lib
mkdir -p $(DESTDIR)$(PREFIX)/include
cp -a include/* $(DESTDIR)$(PREFIX)/include
# install just runtime libs, for embedded rootfs
rootfs: all
mkdir -p $(DESTDIR)$(PREFIX)/lib
install -m755 $(OUTPUT) $(DESTDIR)$(PREFIX)/lib
ln -sf $(OUTPUT) $(DESTDIR)$(PREFIX)/lib/$(SONAME)
ln -sf $(SONAME) $(DESTDIR)$(PREFIX)/lib/$(LDNAME)
clean:
rm -f $(OBJS)
rm -f $(ANAME)
rm -f $(OUTPUT)
rm -f $(SONAME)
rm -f $(LDNAME)
$(MAKE) -C tests clean
.PHONY: all install stage clean