Skip to content

Commit

Permalink
Generate static libraries from liba & libb
Browse files Browse the repository at this point in the history
  • Loading branch information
rolfschr committed Nov 11, 2017
1 parent 08b6172 commit b33dc08
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions c/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@
#
# Makefile $@: The file name of the target of the rule
# Makefile $^: The names of all the prerequisites
#
# ar -c: Create the archive
# ar -r: Update existing files in an archive
# ar -s: Add or update an archive index

main: main.c liba.o libb.o
main: main.c liba.a libb.a
gcc -g -Wall -o $@ $^ -lm

liba.o: liba.c
Expand All @@ -16,5 +20,11 @@ liba.o: liba.c
libb.o: libb.c
gcc -g -Wall -c -o $@ $^

liba.a: liba.o
ar -csr $@ $^

libb.a: libb.o
ar -csr $@ $^

clean:
rm -rf *.o main
rm -rf *.o *.a main

0 comments on commit b33dc08

Please sign in to comment.