iniparser: add build

This commit is contained in:
Kyle Isom 2020-02-18 07:07:33 -08:00
parent be730b75e2
commit b6c2e38bd5
2 changed files with 111 additions and 0 deletions

60
libiniparser/Makefile.in Normal file
View File

@ -0,0 +1,60 @@
VERSION := 1.1.1
TARGET := libiniparser.a
OBJS := iniparser.o
HEADERS := kst
LIBS :=
TEST_LIBS := -L/usr/local/lib -lcunit
PREFIX ?= $PREFIX
MANDIR ?= $MANDIR
CFLAGS += -Wall -Wextra -pedantic -Wshadow -Wpointer-arith -Wcast-align
CFLAGS += -Wwrite-strings -Wmissing-prototypes -Wmissing-declarations
CFLAGS += -Wnested-externs -Winline -Wno-long-long -Wunused-variable -g
CFLAGS += -Wstrict-prototypes -Werror -std=c99 -I. -I/usr/local/include -O0
CFLAGS += OS_CFLAGS
all: $(TARGET)
clean:
-rm -f .*.* *.core *.o *.html tags $(TARGET) $(OBJS)
-rm -rf $(TARGET)-$(VERSION)
-rm -f $(TARGET)-$(VERSION).tgz
-rm -f iniparser-test
$(TARGET): $(OBJS)
$(AR) -rcs $@ $(OBJS)
install: $(TARGET)
install -m 0755 $(TARGET) $(PREFIX)/lib/$(TARGET)
install -m 0755 -d $(MANDIR)/man1
install -m 0444 $(TARGET).3 $(MANDIR)/man3/$(TARGET).3
uninstall:
-rm -f $(PREFIX)/lib/$(TARGET)
-rm -f $(MANDIR)/man3/$(TARGET).3
dist: clean
-mkdir $(TARGET)-$(VERSION)
-cp * $(TARGET)-$(VERSION)
-cd $(TARGET)-$(VERSION) && make distclean && cd ..
-tar czf $(TARGET)-$(VERSION).tgz $(TARGET)-$(VERSION)
distclean: clean
-rm -f Makefile
htmldoc:
-mandoc -Thtml $(TARGET).1 > $(TARGET).1.html
tags:
ctags *.[ch]
test: iniparser-test
iniparser-test: $(TARGET) iniparser_test.o
$(CC) -o $@ iniparser_test.o $(TARGET) $(TEST_LIBS)
.c.o:
$(CC) -c ${CFLAGS} $?
.PHONY: clean all install lint uninstall dist distclean htmldoc tags test

51
libiniparser/config.sh Executable file
View File

@ -0,0 +1,51 @@
#!/bin/sh
TARGET="$(cat Makefile.in | grep 'TARGET :=' | awk -F' ' '{ print $3; }')"
echo "configuring ${TARGET}"
which sed 2>/dev/null 1>/dev/null
if [ $? -ne 0 ]; then
echo "cannot find sed!" 1>&2
fi
OPSYS=$(uname -s)
echo "Configuring for ${OPSYS}..."
if [ "x${OPSYS}" = "xLinux" ]; then
OS_CFLAGS="-D_BSD_SOURCE -D_POSIX_SOURCE -D_XOPEN_SOURCE"
else
OS_CFLAGS=""
fi
if [ -z "${OS_CFLAGS}" ]; then
echo "${OPSYS} requires no extra build flags."
else
echo "${OPSYS} requires build flags ${OS_CFLAGS}"
fi
if [ -z "${PREFIX}" ]; then
PREFIX="/usr/local"
fi
if [ "${PREFIX}" = "/usr" ]; then
MANDIR="$(PREFIX)/share/man"
elif [ "${PREFIX}" = "/usr/local" ]; then
if [ "${OPSYS}" = "Darwin" ]; then
MANDIR="${PREFIX}/share/man"
else
MANDIR="${PREFIX}/man"
fi
else
MANDIR="${PREFIX}/man"
fi
echo "prefix: ${PREFIX}"
echo "mandir: ${MANDIR}"
echo "writing new Makefile"
cat Makefile.in | sed -e "s|OS_CFLAGS|${OS_CFLAGS}|" | \
sed -e "s|\$PREFIX|${PREFIX}|" | \
sed -e "s|\$MANDIR|${MANDIR}|" > Makefile
echo "done."