cs-3516-assignment-1/Makefile

38 lines
1.0 KiB
Makefile
Raw Permalink Normal View History

2018-08-27 14:30:27 +00:00
CC = gcc
CFLAGS = -Wall -g -c -std=gnu99
2018-08-28 04:08:03 +00:00
LDFLAGS = -lm
2018-08-27 14:30:27 +00:00
BUILD_DIR = build
COMMON_OBJ_FILES = $(patsubst %.c,$(BUILD_DIR)/%.o,$(wildcard common/*.c))
CLIENT_OBJ_FILES = $(patsubst %.c,$(BUILD_DIR)/%.o,$(wildcard client/*.c))
2018-09-03 17:23:09 +00:00
SERVER_OBJ_FILES = $(patsubst %.c,$(BUILD_DIR)/%.o,$(wildcard server/*.c))
2018-08-27 14:30:27 +00:00
2018-09-03 19:04:01 +00:00
.PHONY: all clean
all: http_client http_server
2018-08-27 14:30:27 +00:00
clean:
rm -rf $(BUILD_DIR)
rm -f http_client
2018-09-03 22:54:49 +00:00
rm -f http_server
2018-08-27 14:30:27 +00:00
http_client: $(BUILD_DIR)/client $(BUILD_DIR)/common $(COMMON_OBJ_FILES) $(CLIENT_OBJ_FILES)
$(CC) -o $@ $(LDFLAGS) $(filter-out $(BUILD_DIR)/common $(BUILD_DIR)/client,$^)
2018-08-27 14:30:27 +00:00
http_server: $(BUILD_DIR)/server $(BUILD_DIR)/common $(COMMON_OBJ_FILES) $(SERVER_OBJ_FILES)
$(CC) -o $@ $(LDFLAGS) $(filter-out $(BUILD_DIR)/common $(BUILD_DIR)/server,$^)
2018-09-03 17:23:09 +00:00
2018-08-27 14:30:27 +00:00
$(BUILD_DIR)/%.o: %.c
$(CC) $(CFLAGS) -o $@ $<
$(BUILD_DIR)/server: $(BUILD_DIR)
2018-09-03 17:23:09 +00:00
mkdir -p $(BUILD_DIR)/server
$(BUILD_DIR)/client: $(BUILD_DIR)
2018-08-27 14:30:27 +00:00
mkdir -p $(BUILD_DIR)/client
$(BUILD_DIR)/common: $(BUILD_DIR)
2018-08-27 14:30:27 +00:00
mkdir -p $(BUILD_DIR)/common
$(BUILD_DIR):
mkdir -p $(BUILD_DIR)