-
Notifications
You must be signed in to change notification settings - Fork 866
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #188 from cs50/develop
Removes stdlib.h and byte, adds stddef, adds static library
- Loading branch information
Showing
15 changed files
with
41 additions
and
594 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
|
This file was deleted.
Oops, something went wrong.
Binary file not shown.
This file was deleted.
Oops, something went wrong.
Binary file not shown.
This file was deleted.
Oops, something went wrong.
Binary file not shown.
Oops, something went wrong.