Skip to content

Commit

Permalink
Merge pull request #188 from cs50/develop
Browse files Browse the repository at this point in the history
Removes stdlib.h and byte, adds stddef, adds static library
  • Loading branch information
Kareem Zidane authored Oct 17, 2019
2 parents a9b003a + 6d9e82c commit b5d03d3
Show file tree
Hide file tree
Showing 15 changed files with 41 additions and 594 deletions.
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

Expand All @@ -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
Expand 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)
Expand Down
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.
Loading

0 comments on commit b5d03d3

Please sign in to comment.