-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
57 lines (40 loc) · 1.51 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
49
50
51
52
53
54
55
EXECUTABLE_CLIENT = elev_client
EXECUTABLE_SERVER = elev_server
EXECUTABLE_DRIVERS = elev_drivers
CC = gcc
CFLAGS = -Wall -Wextra -g -std=gnu11
LDFLAGS = -lcomedi -lm
CLIENT_SOURCES = elevator.c elevator_io_device.c fsm.c main.c requests.c timer.c driver/io.c
SERVER_SOURCES = elevator_manager.c elevator_storage.c main.c queue.c
DRIVER_SOURCES = network_io.c sverresnetwork.c backup.c
CLIENT_OBJECTS = $(addprefix $(CLIENTOBJDIR)/, $(CLIENT_SOURCES:.c=.o))
SERVER_OBJECTS = $(addprefix $(SERVEROBJDIR)/, $(SERVER_SOURCES:.c=.o))
DRIVER_OBJECTS = $(addprefix $(DRIVEROBJDIR)/, $(DRIVER_SOURCES:.c=.o))
CLIENTOBJDIR = obj/clientobj
SERVEROBJDIR = obj/serverobj
DRIVEROBJDIR = obj/driverobj
all: $(EXECUTABLE_DRIVERS) $(EXECUTABLE_SERVER) $(EXECUTABLE_CLIENT)
client: $(EXECUTABLE_DRIVERS) $(EXECUTABLE_CLIENT)
server: $(EXECUTABLE_DRIVERS) $(EXECUTABLE_SERVER)
rebuild: clean all
clean:
rm -f $(EXECUTABLE_CLIENT)
rm -rf $(CLIENTOBJDIR)
rm -f $(EXECUTABLE_SERVER)
rm -rf $(SERVEROBJDIR)
rm -rf $(DRIVEROBJDIR)
$(EXECUTABLE_CLIENT): $(CLIENT_OBJECTS)
$(CC) $^ $(DRIVER_OBJECTS) -o $@ $(LDFLAGS) -pthread
$(EXECUTABLE_SERVER): $(SERVER_OBJECTS)
$(CC) $^ $(DRIVER_OBJECTS) -o $@ $(LDFLAGS) -pthread
$(EXECUTABLE_DRIVERS): $(DRIVER_OBJECTS)
$(SERVEROBJDIR)/%.o: server/%.c
@mkdir -p $(@D)
$(CC) -o $@ -c $(CFLAGS) $<
$(CLIENTOBJDIR)/%.o: elevator/%.c
@mkdir -p $(@D)
$(CC) -o $@ -c $(CFLAGS) $<
$(DRIVEROBJDIR)/%.o: drivers/%.c
@mkdir -p $(@D)
$(CC) -o $@ -c $(CFLAGS) $< -pthread
.PHONY: all rebuild clean