-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
43 lines (35 loc) · 1.13 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
#This is a hack to pass arguments to the run command and probably only
#works with gnu make.
ifeq (run,$(firstword $(MAKECMDGOALS)))
# use the rest as arguments for "run"
RUN_ARGS := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS))
# ...and turn them into do-nothing targets
$(eval $(RUN_ARGS):;@:)
endif
# Makefile based on https://stackoverflow.com/questions/30573481/path-include-and-src-directory-makefile
#The following lines contain the generic build options
BIN_NAME=CSftp
SRC_DIR=src
INC_DIR=include
OBJ_DIR=obj
CC=gcc
CPPFLAGS=-I$(INC_DIR)
CFLAGS=-g -Werror-implicit-function-declaration
LIBS=-lpthread
#List all the .o files here that need to be linked
SRCS=$(wildcard $(SRC_DIR)/*.c)
OBJS=$(SRCS:$(SRC_DIR)/%.c=$(OBJ_DIR)/%.o)
all: $(BIN_NAME)
$(BIN_NAME): $(OBJS)
$(CC) -o $@ $^ $(LIBS)
clean:
rm -f $(OBJ_DIR)/*.o
rm -f $(BIN_NAME)
.PHONY: run
run: $(BIN_NAME)
./$(BIN_NAME) $(RUN_ARGS)
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c
$(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
# usage.o: $(SRC_DIR)/usage.c $(INC_DIR)/usage.h
# dir.o: $(SRC_DIR)/dir.c $(INC_DIR)/dir.h
# CSftp.o: $(SRC_DIR)/CSftp.c $(INC_DIR)/dir.h $(INC_DIR)/usage.h