Skip to content

Commit c22b4da

Browse files
authored
Add Makefile (#59)
1 parent 8204df7 commit c22b4da

5 files changed

Lines changed: 33 additions & 45 deletions

File tree

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
.idea/*
22
cmake-build-debug/*
33
docs/*
4-
4+
containers.a
5+
containers.so

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2017-2019 Bailey Thompson
3+
Copyright (c) 2017-2020 Bailey Thompson
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

Makefile

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
.DEFAULT_GOAL := unspecified
2+
3+
unspecified:
4+
@echo "Error: use 'make static_clang' or 'make dynamic_clang' or 'make static_gcc' or 'make dynamic_gcc'"
5+
6+
static_clang:
7+
clang src/*.c -c -O3 -fpic
8+
ar rcs containers.a *.o
9+
rm *.o
10+
11+
dynamic_clang:
12+
clang -shared -o containers.so -O3 -fPIC src/*.c
13+
14+
static_gcc:
15+
gcc src/*.c -c -O3 -fpic
16+
ar rcs containers.a *.o
17+
rm *.o
18+
19+
dynamic_gcc:
20+
gcc -shared -o containers.so -O3 -fPIC src/*.c
21+
22+
clean:
23+
rm -f containers.a
24+
rm -f containers.so

README.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,15 @@ This library provides various containers. Each container has utility functions t
1111
Inspired by the C++ standard library; however, implemented using C with different function interfaces as the C++ standard library but with the same container names.
1212

1313
## Setup
14-
The `build.sh` script can be used to build either dynamic or static libraries. The script supports clang and gcc.
15-
16-
The benefit of a dynamic library is that changing the `containers.so` library can be done without needing to recompile the codebase which is using the library. Nevertheless, it is slower than a static library.
17-
18-
The benefit of a static library is that it is faster than a dynamic library. However, if the `containers.a` library is modified, the codebase which is using the library needs to be recompiled.
14+
It is possible to compile this library as either static `.a` or dynamic `.so`:
15+
1. A static library is slightly faster than a dynamic one, however, if the library is modified, the entire project codebase which uses it will need to be recompiled.
16+
2. A dynamic library can be changed without recompiling the codebase, assuming no function definitions have changed.
1917

2018
The installation process is as follows:
2119
1. Clone this repository and navigate to it.
22-
2. Run the `build.sh` build script.
23-
3. Follow the instructions that the script prints.
20+
2. Run `make static_clang`/`make static_gcc` or `make dynamic_clang`/`make dynamic_gcc` for either a static or dynamic library.
21+
3. Then, you can copy-paste `containers.h` and `containers.a`/`containers.so` into your project to include the containers.
22+
4. Finally, you remember to link the library by including `containers.a -ldl`/`containers.so -ldl` as an argument.
2423

2524
## Container Types
2625
The container types that this library contains are described below.

build.sh

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

0 commit comments

Comments
 (0)