-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
48 lines (34 loc) · 1.46 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# Makefile
# Řešení IJC-DU2, 19. 4. 2022
# Autor: Matyáš Strelec, FIT
CC = gcc
CFLAGS = -std=c11 -pedantic -Wall -Wextra
.PHONY: all clean zip
all: tail wordcount wordcount-dynamic wordcount-dynamic-mac libhtab.a libhtab.so libhtab.dylib
# Task 1
tail: tail.o
$(CC) $(CFLAGS) -o $@ $<
tail.o: tail.c
$(CC) $(CFLAGS) -c $<
# Task 2
wordcount: wordcount.o io.o libhtab.a
$(CC) $(CFLAGS) $^ -o $@
wordcount-dynamic: wordcount.o io.o libhtab.so
$(CC) $(CFLAGS) $^ -o $@
wordcount-dynamic-mac: wordcount.o io.o libhtab.dylib
$(CC) $(CFLAGS) $^ -o $@
# Libraries
# Static -- .a for both macOS and Linux
libhtab.a: htab_bucket_count.o htab_clear.o htab_erase.o htab_find.o htab_for_each.o htab_free.o htab_hash_function.o htab_init.o htab_lookup_add.o htab_resize.o htab_size.o
ar rcs libhtab.a $^
# Dynamic -- .dylib for macOS, .so for Linux
libhtab.dylib: htab_bucket_count.o htab_clear.o htab_erase.o htab_find.o htab_for_each.o htab_free.o htab_hash_function.o htab_init.o htab_lookup_add.o htab_resize.o htab_size.o
$(CC) $(CFLAGS) -fPIC -shared $^ -o $@
libhtab.so: htab_bucket_count.o htab_clear.o htab_erase.o htab_find.o htab_for_each.o htab_free.o htab_hash_function.o htab_init.o htab_lookup_add.o htab_resize.o htab_size.o
$(CC) $(CFLAGS) -fPIC -shared $^ -o $@
%.o: %.c htab.h htab_priv.h
$(CC) $(CFLAGS) -fPIC -c $<
clean:
rm *.o *.a *.so *.dylib tail wordcount- wordcount wordcount-dynamic wordcount-dynamic-mac *.zip
zip:
zip xstrel03.zip *.h *.c *.cc Makefile