Skip to content

Commit 2c6e9db

Browse files
committed
Added a makefile
1 parent 80a01a3 commit 2c6e9db

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

Makefile

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
CC=gcc
2+
EXEC=test
3+
LIB=argparse.a
4+
SHARED_LIB=libargparse.so
5+
SOURCE=argparse.c
6+
INCLUDE=argparse.h
7+
TEST_S=test.c
8+
CFLAGS=-fPIC -O2
9+
10+
all: shared static
11+
12+
object:
13+
$(CC) -c -o $(SOURCE:.c=.o) $(CFLAGS) $(SOURCE)
14+
15+
static: object
16+
ar rcs $(LIB) $(SOURCE:.c=.o)
17+
shared: object
18+
gcc -shared -o $(SHARED_LIB) $(SOURCE:.c=.o)
19+
20+
clean:
21+
rm -f $(SHARED_LIB) $(LIB) $(SOURCE:.c=.o)
22+
23+
install:
24+
cp $(INCLUDE) /usr/include
25+
cp $(SHARED_LIB) /usr/lib/$(SHARED_LIB) 2>/dev/null || :
26+
cp $(LIB) /usr/lib/$(LIB) 2>/dev/null || :
27+
chmod 0755 /usr/lib/$(LIB) $(SHARED_LIB)
28+
ldconfig

0 commit comments

Comments
 (0)