Skip to content

Commit b5d03d3

Browse files
author
Kareem Zidane
authored
Merge pull request #188 from cs50/develop
Removes stdlib.h and byte, adds stddef, adds static library
2 parents a9b003a + 6d9e82c commit b5d03d3

15 files changed

+41
-594
lines changed

Makefile

Lines changed: 41 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,32 @@
1-
VERSION := 10.0.0
2-
MAJOR_VERSION := $(shell echo $(VERSION) | head -c 1)
1+
VERSION := 10.1.0
2+
MAJOR_VERSION := $(shell echo $(VERSION) | cut -d'.' -f1)
33

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

88
SRC := src/cs50.c
99
INCLUDE := src/cs50.h
10-
MANS := $(wildcard docs/*.3)
10+
MANS := $(wildcard docs/*.3.gz)
1111

12-
CFLAGS=-Wall -Wextra -Werror -pedantic -std=c99
12+
CFLAGS=-Wall -Wextra -Werror -pedantic -std=c11
13+
BASENAME=libcs50
14+
LIB_STATIC=$(BASENAME).a
15+
LIB_OBJ=$(BASENAME).o
1316

1417
OS := $(shell uname)
1518

1619
# Linux
1720
ifeq ($(OS),Linux)
18-
LIB_BASE := libcs50.so
19-
LIB_MAJOR := libcs50.so.$(MAJOR_VERSION)
20-
LIB_VERSION := libcs50.so.$(VERSION)
21+
LIB_BASE := $(BASENAME).so
22+
LIB_MAJOR := $(BASENAME).so.$(MAJOR_VERSION)
23+
LIB_VERSION := $(BASENAME).so.$(VERSION)
2124
LINKER_FLAGS := -Wl,-soname,$(LIB_MAJOR)
2225
# Mac
2326
else ifeq ($(OS),Darwin)
24-
LIB_BASE := libcs50.dylib
25-
LIB_MAJOR := libcs50-$(MAJOR_VERSION).dylib
26-
LIB_VERSION := libcs50-$(VERSION).dylib
27+
LIB_BASE := $(BASENAME).dylib
28+
LIB_MAJOR := $(BASENAME)-$(MAJOR_VERSION).dylib
29+
LIB_VERSION := $(BASENAME)-$(VERSION).dylib
2730
LINKER_FLAGS := -Wl,-install_name,$(LIB_VERSION)
2831
endif
2932

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

3538
$(LIBS): $(SRC) $(INCLUDE) Makefile
3639
$(CC) $(CFLAGS) -fPIC -shared $(LINKER_FLAGS) -o $(LIB_VERSION) $(SRC)
40+
$(CC) $(CFLAGS) -c -o $(LIB_OBJ) $(SRC)
41+
ar rcs $(LIB_STATIC) $(LIB_OBJ)
42+
chmod 644 $(LIB_STATIC)
43+
rm -f $(LIB_OBJ)
3744
ln -sf $(LIB_VERSION) $(LIB_BASE)
3845
mkdir -p $(addprefix build/, include lib src)
3946
install -m 644 $(SRC) build/src
4047
install -m 644 $(INCLUDE) build/include
41-
mv $(LIB_VERSION) $(LIB_BASE) build/lib
48+
mv $(LIB_VERSION) $(LIB_BASE) $(LIB_STATIC) build/lib
4249

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

6168
# temporary fpm source
62-
mkdir -p build/deb/libcs50/usr/local
63-
cp -r $(addprefix build/, include lib src) build/deb/libcs50/usr/local
64-
mkdir -p build/deb/libcs50/usr/local/share/man/man3
65-
cp -r $(MANS) build/deb/libcs50/usr/local/share/man/man3
69+
mkdir -p build/deb/$(BASENAME)/usr
70+
cp -r $(addprefix build/, include lib src) build/deb/$(BASENAME)/usr
71+
mkdir -p build/deb/$(BASENAME)/usr/share/man/man3
72+
chmod 755 build/deb/$(BASENAME)/usr/share/man/man3
73+
cp -r $(MANS) build/deb/$(BASENAME)/usr/share/man/man3
74+
chmod 644 build/deb/$(BASENAME)/usr/share/man/man3/*
6675
fpm \
6776
--after-install postinst \
6877
--after-remove postrm \
6978
--category libs \
70-
--chdir build/deb/libcs50 \
79+
--chdir build/deb/$(BASENAME) \
7180
--conflicts lib50-c \
72-
--conflicts libcs50 \
81+
--conflicts $(BASENAME) \
7382
--conflicts library50-c \
83+
--deb-no-default-config-files \
7484
--deb-priority optional \
7585
--description "CS50 library for C" \
7686
--input-type dir \
7787
--license "MIT" \
7888
--maintainer "CS50 <[email protected]>" \
79-
--name libcs50 \
89+
--name $(BASENAME) \
8090
--output-type deb \
8191
--package build/deb \
8292
--provides lib50-c \
83-
--provides libcs50 \
93+
--provides $(BASENAME) \
8494
--provides library50-c \
8595
--replaces lib50-c \
86-
--replaces libcs50 \
96+
--replaces $(BASENAME) \
8797
--replaces library50-c \
8898
--url https://github.com/cs50/libcs50 \
8999
--vendor CS50 \
90100
--version $(VERSION) \
91101
.
92102

93-
rm -rf build/deb/libcs50
103+
rm -rf build/deb/$(BASENAME)
94104

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

98-
# temporary fpm source
99-
mkdir -p build/rpm/libcs50/usr/local
100-
cp -r $(addprefix build/, include lib src) build/rpm/libcs50/usr/local
101-
mkdir -p build/rpm/libcs50/usr/local/share/man/man3
102-
cp -r $(MANS) build/rpm/libcs50/usr/local/share/man/man3
108+
# Temporary fpm source
109+
mkdir -p build/rpm/$(BASENAME)/usr
110+
cp -r $(addprefix build/, include lib src) build/rpm/$(BASENAME)/usr
111+
mkdir -p build/rpm/$(BASENAME)/usr/share/man/man3
112+
cp -r $(MANS) build/rpm/$(BASENAME)/usr/share/man/man3
103113
fpm \
104114
--after-install post \
105115
--after-remove postun \
106116
--category libs \
107-
--chdir build/rpm/libcs50 \
117+
--chdir build/rpm/$(BASENAME) \
108118
--description "CS50 library for C" \
109119
--input-type dir \
110120
--license "MIT" \
111121
--maintainer "CS50 <[email protected]>" \
112-
--name libcs50 \
122+
--name $(BASENAME) \
113123
--output-type rpm \
114124
--package build/rpm \
115-
--provides libcs50 \
125+
--provides $(BASENAME) \
116126
--url https://github.com/cs50/libcs50 \
117127
--vendor CS50 \
118128
--version $(VERSION) \
119129
.
120130

121-
rm -rf build/rpm/libcs50
131+
rm -rf build/rpm/$(BASENAME)
122132

123-
# used by .travis.yml
133+
# Used by .travis.yml
124134
.PHONY: version
125135
version:
126136
@echo $(VERSION)

docs/get_char.3

Lines changed: 0 additions & 78 deletions
This file was deleted.

docs/get_char.3.gz

840 Bytes
Binary file not shown.

docs/get_double.3

Lines changed: 0 additions & 82 deletions
This file was deleted.

docs/get_double.3.gz

942 Bytes
Binary file not shown.

docs/get_float.3

Lines changed: 0 additions & 81 deletions
This file was deleted.

docs/get_float.3.gz

912 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)