Skip to content

Commit 02c16bd

Browse files
author
Kareem Zidane
authored
Merge pull request #83 from cs50/develop
v8.0.3
2 parents 4e763ac + df33569 commit 02c16bd

29 files changed

+434
-487
lines changed

Diff for: .gitignore

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
11
.*
22
!.gitignore
3+
!.travis.yml
34
build/
5+
debian/changelog
6+
debian/docs/
7+
hackerrank/
8+
libcs50-*
9+
libcs50_*

Diff for: .travis.yml

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
dist: trusty
2+
sudo: required
3+
before_install:
4+
- sudo apt-get install build-essential debhelper devscripts dh-make lintian
5+
- gem install asciidoctor
6+
install: true
7+
before_script: echo -e $GPG_SECRET | gpg --import
8+
script: make deb
9+
deploy:
10+
- provider: script
11+
script: 'curl --fail --data "{ \"tag_name\": \"v$(make version)\",
12+
\"target_commitish\": \"$TRAVIS_COMMIT\", \"name\": \"v$(make version)\"
13+
}" --user bot50:$GITHUB_TOKEN https://api.github.com/repos/$TRAVIS_REPO_SLUG/releases'
14+
on:
15+
branch: master
16+
- provider: script
17+
script: dput ppa:cs50/ppa build/deb/*.changes
18+
skip_cleanup: true
19+
on:
20+
branch: master
21+
notifications:
22+
slack:
23+
secure: ISOGlNSGXOrMBrKTnjTWQXVjjoBn78++xF1mUv/PYZxn3J4L4WpybLLjAuBENsD7YeHSaXUnSbIV5mDzlx5Q1cyrS+auGOHqi5xGV01zNBB1Fig1SkUf7zJS8KyjiPKyi+DexnTt1BY4xaA1uGzq9hoGZEPXKHNlz4v1I6f6fHQ=

Diff for: Makefile

+51-108
Original file line numberDiff line numberDiff line change
@@ -1,117 +1,60 @@
1-
# useful paths
2-
SRC_DIR = src
3-
HDR = $(SRC_DIR)/cs50.h
4-
SRC = $(SRC_DIR)/cs50.c
1+
VERSION := 8.0.3
52

6-
BUILD_DIR = build
7-
OBJ = $(BUILD_DIR)/cs50.o
8-
USR_DIR = $(BUILD_DIR)/usr
9-
INCLUDE_DIR = $(USR_DIR)/include
10-
LIB_DIR = $(USR_DIR)/lib
11-
MAN_DIR = $(USR_DIR)/share/man/man3
12-
BUILD_SRC = $(USR_DIR)/src
3+
# soname - libcs50.so.<major_version>
4+
SONAME := libcs50.so.$(shell echo $(VERSION) | head -c 1)
135

14-
# eprintf
15-
EPRINTF_EXE = $(BUILD_DIR)/eprintf
16-
17-
# HackerRank
18-
HR_HDR = $(BUILD_DIR)/cs50.h
19-
HR_EXE = $(BUILD_DIR)/hackerrank
20-
21-
TESTS_DIR = tests
22-
23-
# deb package info
24-
DESCRIPTION = CS50 Library for C
25-
MAINTAINER = CS50 <[email protected]>
26-
NAME = libcs50
27-
OLD_NAMES = lib50-c library50-c
28-
VERSION = 8.0.2
29-
30-
.PHONY: bash
31-
bash:
32-
docker run -i --rm -t -v "$(PWD):/root" cs50/cli
6+
# installation directory (/usr/local by default)
7+
DESTDIR ?= /usr/local
338

349
.PHONY: build
35-
build: clean Makefile $(SRC) $(HDR)
36-
mkdir -p "$(INCLUDE_DIR)" "$(LIB_DIR)" "$(MAN_DIR)" "$(BUILD_SRC)"
37-
gcc -c -fPIC -std=gnu99 -Wall -o "$(OBJ)" "$(SRC)"
38-
gcc -o "$(LIB_DIR)/libcs50.so" -shared "$(OBJ)"
39-
rm -f "$(OBJ)"
40-
cp "$(HDR)" "$(INCLUDE_DIR)"
41-
cp "$(SRC)" "$(BUILD_SRC)"
42-
cp -r docs/* "$(MAN_DIR)"
43-
find "$(BUILD_DIR)" -type d -exec chmod 0755 {} +
44-
find "$(BUILD_DIR)" -type f -exec chmod 0644 {} +
45-
46-
.PHONY: clean
47-
clean:
48-
rm -rf "$(BUILD_DIR)"
49-
50-
.PHONY: deb
51-
deb: build
52-
fpm \
53-
-C "$(BUILD_DIR)" \
54-
-m "$(MAINTAINER)" \
55-
-n "$(NAME)" \
56-
-p "$(BUILD_DIR)" \
57-
-s dir \
58-
-t deb \
59-
-v "$(VERSION)" \
60-
--conflicts "$(NAME) (<< $(VERSION))" \
61-
$(foreach name,$(OLD_NAMES),--conflicts $(name) --provides $(name) --replaces $(name)) \
62-
--deb-no-default-config-files \
63-
--depends c-compiler \
64-
--description "$(DESCRIPTION)" \
65-
--provides "$(NAME)" \
66-
--replaces "$(NAME) (<= $(VERSION))" \
67-
usr
68-
69-
.PHONY: hackerrank
70-
hackerrank: build
71-
cat "$(HDR)" > "$(HR_HDR)"
72-
echo "\n#ifndef _CS50_C\n#define _CS50_C\n" >> "$(HR_HDR)"
73-
cat "$(SRC)" >> "$(HR_HDR)"
74-
echo "\n#endif" >> "$(HR_HDR)"
10+
build: clean
11+
$(CC) -c -fPIC -std=gnu99 -Wall -o cs50.o src/cs50.c
12+
$(CC) -shared -Wl,-soname,$(SONAME) -o libcs50.so.$(VERSION) cs50.o
13+
rm -f cs50.o
14+
ln -s libcs50.so.$(VERSION) $(SONAME)
15+
ln -s $(SONAME) libcs50.so
16+
install -D -m 644 src/cs50.h build/include/cs50.h
17+
mkdir -p build/lib build/src/libcs50
18+
mv libcs50.so* build/lib
19+
cp -r src/* build/src/libcs50
7520

7621
.PHONY: install
77-
install: build
78-
cp "$(INCLUDE_DIR)"/* /usr/include
79-
cp "$(LIB_DIR)"/* /usr/lib
22+
install: build docs
23+
mkdir -p $(DESTDIR) $(DESTDIR)/share/man/man3
24+
cp -r build/* $(DESTDIR)
25+
cp -r debian/docs/* $(DESTDIR)/share/man/man3
8026

81-
# TODO: add dependencies
82-
.PHONY: pacman
83-
pacman: build
84-
rm -f "$(NAME)-$(VERSION)-"*.pkg.tar.xz
85-
fpm \
86-
-C "$(BUILD_DIR)" \
87-
-m "$(MAINTAINER)" \
88-
-n "$(NAME)" \
89-
-p "$(BUILD_DIR)" \
90-
-s dir \
91-
-t pacman \
92-
-v "$(VERSION)" \
93-
--description "$(DESCRIPTION)" \
94-
usr
27+
.PHONY: clean
28+
clean:
29+
rm -rf build debian/docs/ libcs50-* libcs50_*
9530

96-
# TODO: add dependencies
97-
.PHONY: rpm
98-
rpm: build
99-
rm -f "$(NAME)-$(VERSION)-"*.rpm
100-
fpm \
101-
-C "$(BUILD_DIR)" \
102-
-m "$(MAINTAINER)" \
103-
-n "$(NAME)" \
104-
-p "$(BUILD_DIR)" \
105-
-s dir \
106-
-t rpm \
107-
-v "$(VERSION)" \
108-
--description "$(DESCRIPTION)" \
109-
usr
31+
# requires asciidoctor (gem install asciidoctor)
32+
.PHONY: docs
33+
docs:
34+
asciidoctor -d manpage -b manpage -D debian/docs/ docs/*.adoc
11035

111-
# TODO: improve test suite
112-
.PHONY: test
113-
test: build hackerrank
114-
#clang -ggdb3 -I "$(INCLUDE_DIR)" -O0 -Wall -Werror -Wno-deprecated-declarations "$(TESTS_DIR)/eprintf.c" -L "$(LIB_DIR)" -lcs50 -o "$(EPRINTF_EXE)"
115-
#clang -I "$(BUILD_DIR)" -Wall -Werror -Wno-deprecated-declarations "$(TESTS_DIR)/hackerrank.c" -o "$(HR_EXE)"
116-
clang -ggdb3 -I "$(INCLUDE_DIR)" -O0 -Wall -Werror -Wno-deprecated-declarations "$(TESTS_DIR)/get_int.c" -L "$(LIB_DIR)" -lcs50 -o "$(BUILD_DIR)"/get_int
117-
LD_LIBRARY_PATH="$(LIB_DIR)" "$(BUILD_DIR)"/get_int
36+
.PHONY: deb
37+
deb: build docs
38+
@echo "libcs50 ($(VERSION)-0ubuntu1) trusty; urgency=low" > debian/changelog
39+
@echo " * v$(VERSION)" >> debian/changelog
40+
@echo " -- CS50 Sysadmins <[email protected]> $$(date --rfc-2822)" >> debian/changelog
41+
mkdir -p libcs50-$(VERSION)/usr
42+
rsync -a build/* libcs50-$(VERSION)/usr --exclude=hack
43+
tar -cvzf libcs50_$(VERSION).orig.tar.gz libcs50-$(VERSION)
44+
cp -r debian libcs50-$(VERSION)
45+
cd libcs50-$(VERSION) && debuild -S -sa --lintian-opts --display-info --info --show-overrides
46+
mkdir -p build/deb
47+
mv libcs50-* libcs50_* build/deb
48+
49+
.PHONY: hack
50+
hack:
51+
rm -rf build/hack && mkdir -p build/hack
52+
cat src/cs50.h > build/hack/cs50.h
53+
echo "\n#ifndef _CS50_C\n#define _CS50_C\n" >> build/hack/cs50.h
54+
cat src/cs50.c >> build/hack/cs50.h
55+
echo "\n#endif" >> build/hack/cs50.h
56+
57+
# used by .travis.yml
58+
.PHONY: version
59+
version:
60+
@echo $(VERSION)

Diff for: README.md

+23-8
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,28 @@
11
# CS50 Library for C
22

3+
[![Build Status](https://travis-ci.org/cs50/libcs50.svg?branch=master)](https://travis-ci.org/cs50/libcs50)
4+
35
## Development
46

5-
Requires [Docker Engine](https://docs.docker.com/engine/installation/).
7+
`make build`: builds dynamic library
8+
9+
`make deb`: builds source deb
10+
11+
`make hack`: combines library into `cs50.h`
12+
13+
`make install`: installs the library under `/usr/local` by default (set `DESTDIR` to change that)
614

7-
make bash
8-
make build # builds dynamic library
9-
make deb # builds .deb
10-
make pacman # builds .pkg.tar.xz
11-
make rpm # builds .rpm
12-
make test # builds test program
15+
## Installation
1316

14-
# Installation
17+
### Ubuntu
18+
19+
```
20+
$ sudo apt-add-repository ppa:cs50/ppa
21+
$ sudo apt-get update
22+
$ sudo apt-get install libcs50
23+
```
24+
25+
### From Source
1526

1627
1. Download the latest release per https://github.com/cs50/libcs50/releases
1728
1. Extract `libcs50-*.*`
@@ -33,6 +44,10 @@ Link with `-lcs50`.
3344
long long ll = get_long_long();
3445
string s = get_string();
3546

47+
## Documentation
48+
49+
See `man get_*` after installation, or [CS50 Reference](https://reference.cs50.net/cs50/)!
50+
3651
## TODO
3752

3853
* Add tests.

Diff for: debian/compat

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
9

Diff for: debian/control

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
Source: libcs50
2+
Priority: optional
3+
Maintainer: CS50 Sysadmins <[email protected]>
4+
Build-Depends: debhelper (>= 9)
5+
Standards-Version: 3.9.5
6+
Section: libs
7+
Vcs-Git: https://github.com/cs50/libcs50.git
8+
9+
Package: libcs50
10+
Architecture: any
11+
Conflicts: lib50-c, libcs50, library50-c
12+
Depends: ${shlibs:Depends}, ${misc:Depends}
13+
Provides: lib50-c, libcs50, library50-c
14+
Replaces: lib50-c, libcs50, library50-c
15+
Description: CS50 library for C
16+
makes it easier to write programs that prompt the users for input

Diff for: debian/copyright

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
2+
Upstream-Name: libcs50
3+
Source: http://github.com/cs50/libcs50/releases
4+
5+
Files: *
6+
Copyright: 2017 David J. Malan <[email protected]>
7+
2017 Glenn Holloway <[email protected]>
8+
License: BSD-3-Clause
9+
10+
Files: debian/*
11+
Copyright: 2017 CS50 Sysadmins <[email protected]>
12+
License: BSD-3-Clause
13+
14+
License: BSD-3-Clause
15+
Redistribution and use in source and binary forms, with or without
16+
modification, are permitted provided that the following conditions
17+
are met:
18+
1. Redistributions of source code must retain the above copyright
19+
notice, this list of conditions and the following disclaimer.
20+
2. Redistributions in binary form must reproduce the above copyright
21+
notice, this list of conditions and the following disclaimer in the
22+
documentation and/or other materials provided with the distribution.
23+
3. Neither the name of the University nor the names of its contributors
24+
may be used to endorse or promote products derived from this software
25+
without specific prior written permission.
26+
.
27+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
28+
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
29+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
30+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE HOLDERS OR
31+
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
32+
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
33+
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
34+
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
35+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
36+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
37+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Diff for: debian/libcs50.dirs

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
usr/lib
2+
usr/include
3+
usr/src

Diff for: debian/libcs50.install

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
usr/include/*
2+
usr/lib/libcs50.so*
3+
usr/src/*

Diff for: debian/libcs50.manpages

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
debian/docs/eprintf.3
2+
debian/docs/get_char.3
3+
debian/docs/get_double.3
4+
debian/docs/get_float.3
5+
debian/docs/get_int.3
6+
debian/docs/get_long_long.3
7+
debian/docs/get_string.3

Diff for: debian/rules

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/make -f
2+
# -*- makefile -*-
3+
4+
# Uncomment this to turn on verbose mode.
5+
#export DH_VERBOSE=1
6+
7+
%:
8+
dh $@

Diff for: debian/source.lintian-overrides

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
libcs50 source: source-is-missing

Diff for: debian/source/format

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.0 (quilt)

Diff for: debian/watch

Whitespace-only changes.

Diff for: docs/eprintf.3

-44
This file was deleted.

0 commit comments

Comments
 (0)