Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added static lib, gzipped man pages #187

Merged
merged 4 commits into from
Oct 14, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 41 additions & 31 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,29 +1,32 @@
VERSION := 10.0.0
MAJOR_VERSION := $(shell echo $(VERSION) | head -c 1)
VERSION := 10.1.0
MAJOR_VERSION := $(shell echo $(VERSION) | cut -d'.' -f1)

# installation directory (/usr/local by default)
DESTDIR ?= /usr/local
MANDIR ?= share/man/man3

SRC := src/cs50.c
INCLUDE := src/cs50.h
MANS := $(wildcard docs/*.3)
MANS := $(wildcard docs/*.3.gz)

CFLAGS=-Wall -Wextra -Werror -pedantic -std=c99
CFLAGS=-Wall -Wextra -Werror -pedantic -std=c11
BASENAME=libcs50
LIB_STATIC=$(BASENAME).a
LIB_OBJ=$(BASENAME).o

OS := $(shell uname)

# Linux
ifeq ($(OS),Linux)
LIB_BASE := libcs50.so
LIB_MAJOR := libcs50.so.$(MAJOR_VERSION)
LIB_VERSION := libcs50.so.$(VERSION)
LIB_BASE := $(BASENAME).so
LIB_MAJOR := $(BASENAME).so.$(MAJOR_VERSION)
LIB_VERSION := $(BASENAME).so.$(VERSION)
LINKER_FLAGS := -Wl,-soname,$(LIB_MAJOR)
# Mac
else ifeq ($(OS),Darwin)
LIB_BASE := libcs50.dylib
LIB_MAJOR := libcs50-$(MAJOR_VERSION).dylib
LIB_VERSION := libcs50-$(VERSION).dylib
LIB_BASE := $(BASENAME).dylib
LIB_MAJOR := $(BASENAME)-$(MAJOR_VERSION).dylib
LIB_VERSION := $(BASENAME)-$(VERSION).dylib
LINKER_FLAGS := -Wl,-install_name,$(LIB_VERSION)
endif

@@ -34,11 +37,15 @@ all: $(LIBS) $(MANS)

$(LIBS): $(SRC) $(INCLUDE) Makefile
$(CC) $(CFLAGS) -fPIC -shared $(LINKER_FLAGS) -o $(LIB_VERSION) $(SRC)
$(CC) $(CFLAGS) -c -o $(LIB_OBJ) $(SRC)
ar rcs $(LIB_STATIC) $(LIB_OBJ)
chmod 644 $(LIB_STATIC)
rm -f $(LIB_OBJ)
ln -sf $(LIB_VERSION) $(LIB_BASE)
mkdir -p $(addprefix build/, include lib src)
install -m 644 $(SRC) build/src
install -m 644 $(INCLUDE) build/include
mv $(LIB_VERSION) $(LIB_BASE) build/lib
mv $(LIB_VERSION) $(LIB_BASE) $(LIB_STATIC) build/lib

.PHONY: install
install: all
@@ -59,68 +66,71 @@ deb: $(LIBS) $(MANS)
rm -rf build/deb

# temporary fpm source
mkdir -p build/deb/libcs50/usr/local
cp -r $(addprefix build/, include lib src) build/deb/libcs50/usr/local
mkdir -p build/deb/libcs50/usr/local/share/man/man3
cp -r $(MANS) build/deb/libcs50/usr/local/share/man/man3
mkdir -p build/deb/$(BASENAME)/usr
cp -r $(addprefix build/, include lib src) build/deb/$(BASENAME)/usr
mkdir -p build/deb/$(BASENAME)/usr/share/man/man3
chmod 755 build/deb/$(BASENAME)/usr/share/man/man3
cp -r $(MANS) build/deb/$(BASENAME)/usr/share/man/man3
chmod 644 build/deb/$(BASENAME)/usr/share/man/man3/*
fpm \
--after-install postinst \
--after-remove postrm \
--category libs \
--chdir build/deb/libcs50 \
--chdir build/deb/$(BASENAME) \
--conflicts lib50-c \
--conflicts libcs50 \
--conflicts $(BASENAME) \
--conflicts library50-c \
--deb-no-default-config-files \
--deb-priority optional \
--description "CS50 library for C" \
--input-type dir \
--license "MIT" \
--maintainer "CS50 <[email protected]>" \
--name libcs50 \
--name $(BASENAME) \
--output-type deb \
--package build/deb \
--provides lib50-c \
--provides libcs50 \
--provides $(BASENAME) \
--provides library50-c \
--replaces lib50-c \
--replaces libcs50 \
--replaces $(BASENAME) \
--replaces library50-c \
--url https://github.com/cs50/libcs50 \
--vendor CS50 \
--version $(VERSION) \
.

rm -rf build/deb/libcs50
rm -rf build/deb/$(BASENAME)

rpm: $(LIBS) $(MANS)
rm -rf build/rpm

# temporary fpm source
mkdir -p build/rpm/libcs50/usr/local
cp -r $(addprefix build/, include lib src) build/rpm/libcs50/usr/local
mkdir -p build/rpm/libcs50/usr/local/share/man/man3
cp -r $(MANS) build/rpm/libcs50/usr/local/share/man/man3
# Temporary fpm source
mkdir -p build/rpm/$(BASENAME)/usr
cp -r $(addprefix build/, include lib src) build/rpm/$(BASENAME)/usr
mkdir -p build/rpm/$(BASENAME)/usr/share/man/man3
cp -r $(MANS) build/rpm/$(BASENAME)/usr/share/man/man3
fpm \
--after-install post \
--after-remove postun \
--category libs \
--chdir build/rpm/libcs50 \
--chdir build/rpm/$(BASENAME) \
--description "CS50 library for C" \
--input-type dir \
--license "MIT" \
--maintainer "CS50 <[email protected]>" \
--name libcs50 \
--name $(BASENAME) \
--output-type rpm \
--package build/rpm \
--provides libcs50 \
--provides $(BASENAME) \
--url https://github.com/cs50/libcs50 \
--vendor CS50 \
--version $(VERSION) \
.

rm -rf build/rpm/libcs50
rm -rf build/rpm/$(BASENAME)

# used by .travis.yml
# Used by .travis.yml
.PHONY: version
version:
@echo $(VERSION)
78 changes: 0 additions & 78 deletions docs/get_char.3

This file was deleted.

Binary file added docs/get_char.3.gz
Binary file not shown.
82 changes: 0 additions & 82 deletions docs/get_double.3

This file was deleted.

Binary file added docs/get_double.3.gz
Binary file not shown.
81 changes: 0 additions & 81 deletions docs/get_float.3

This file was deleted.

Binary file added docs/get_float.3.gz
Binary file not shown.
81 changes: 0 additions & 81 deletions docs/get_int.3

This file was deleted.

Binary file added docs/get_int.3.gz
Binary file not shown.
81 changes: 0 additions & 81 deletions docs/get_long.3

This file was deleted.

Binary file added docs/get_long.3.gz
Binary file not shown.
83 changes: 0 additions & 83 deletions docs/get_long_long.3

This file was deleted.

Binary file added docs/get_long_long.3.gz
Binary file not shown.
77 changes: 0 additions & 77 deletions docs/get_string.3

This file was deleted.

Binary file added docs/get_string.3.gz
Binary file not shown.