Skip to content

Commit cdc3f60

Browse files
author
Kareem Zidane
committedOct 13, 2019
added static lib, gzipped man pages
1 parent b29c9bf commit cdc3f60

15 files changed

+35
-591
lines changed
 

‎Makefile

+35-28
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
VERSION := 10.0.0
1+
VERSION := 10.1.0
22
MAJOR_VERSION := $(shell echo $(VERSION) | head -c 1)
33

44
# installation directory (/usr/local by default)
@@ -7,23 +7,26 @@ 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,66 +66,66 @@ 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/local
70+
cp -r $(addprefix build/, include lib src) build/deb/$(BASENAME)/usr/local
71+
mkdir -p build/deb/$(BASENAME)/usr/local/share/man/man3
72+
cp -r $(MANS) build/deb/$(BASENAME)/usr/local/share/man/man3
6673
fpm \
6774
--after-install postinst \
6875
--after-remove postrm \
6976
--category libs \
70-
--chdir build/deb/libcs50 \
77+
--chdir build/deb/$(BASENAME) \
7178
--conflicts lib50-c \
72-
--conflicts libcs50 \
79+
--conflicts $(BASENAME) \
7380
--conflicts library50-c \
7481
--deb-priority optional \
7582
--description "CS50 library for C" \
7683
--input-type dir \
7784
--license "MIT" \
7885
--maintainer "CS50 <sysadmins@cs50.harvard.edu>" \
79-
--name libcs50 \
86+
--name $(BASENAME) \
8087
--output-type deb \
8188
--package build/deb \
8289
--provides lib50-c \
83-
--provides libcs50 \
90+
--provides $(BASENAME) \
8491
--provides library50-c \
8592
--replaces lib50-c \
86-
--replaces libcs50 \
93+
--replaces $(BASENAME) \
8794
--replaces library50-c \
8895
--url https://github.com/cs50/libcs50 \
8996
--vendor CS50 \
9097
--version $(VERSION) \
9198
.
9299

93-
rm -rf build/deb/libcs50
100+
rm -rf build/deb/$(BASENAME)
94101

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

98105
# 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
106+
mkdir -p build/rpm/$(BASENAME)/usr/local
107+
cp -r $(addprefix build/, include lib src) build/rpm/$(BASENAME)/usr/local
108+
mkdir -p build/rpm/$(BASENAME)/usr/local/share/man/man3
109+
cp -r $(MANS) build/rpm/$(BASENAME)/usr/local/share/man/man3
103110
fpm \
104111
--after-install post \
105112
--after-remove postun \
106113
--category libs \
107-
--chdir build/rpm/libcs50 \
114+
--chdir build/rpm/$(BASENAME) \
108115
--description "CS50 library for C" \
109116
--input-type dir \
110117
--license "MIT" \
111118
--maintainer "CS50 <sysadmins@cs50.harvard.edu>" \
112-
--name libcs50 \
119+
--name $(BASENAME) \
113120
--output-type rpm \
114121
--package build/rpm \
115-
--provides libcs50 \
122+
--provides $(BASENAME) \
116123
--url https://github.com/cs50/libcs50 \
117124
--vendor CS50 \
118125
--version $(VERSION) \
119126
.
120127

121-
rm -rf build/rpm/libcs50
128+
rm -rf build/rpm/$(BASENAME)
122129

123130
# used by .travis.yml
124131
.PHONY: version

‎docs/get_char.3

-78
This file was deleted.

‎docs/get_char.3.gz

840 Bytes
Binary file not shown.

‎docs/get_double.3

-82
This file was deleted.

‎docs/get_double.3.gz

942 Bytes
Binary file not shown.

‎docs/get_float.3

-81
This file was deleted.

‎docs/get_float.3.gz

912 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)
Please sign in to comment.