-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile_BAK
86 lines (63 loc) · 2.41 KB
/
Makefile_BAK
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# Change the program name here, the := syntax overwrites any previous value the variable may have
program_NAME := pwgen
# This line fetches the names of all the .c files in the current directory
# and assigns them as a space separated list to the variable program_SRCS
program_SRCS := $(wildcard *.c)
# This copies the filenames changing the .c extension to .o
program_OBJS := ${program_SRCS:.c=.o}
# When you type make clean this is the list of files which will be deleted
# The += syntax appends to the variable
clean_list += $(program_OBJS) $(program_NAME)
# C Preprocessor Flags
CPPFLAGS +=
# compiler flags
CFLAGS += -ansi -Wall -Wextra -pedantic-errors
# libraries to link to ( m == math )
program_LIBRARIES := m
# LDFLAGS is the variable to hold linker flags
LDFLAGS += $(foreach library,$(program_LIBRARIES),-l$(library))
# .PHONY means that these build targets are dummies, i.e. they don't generate any output files.
# This is typically used to run shell commands.
.PHONY: all clean indent
all: $(program_NAME)
clean:
@- $(RM) $(clean_list)
# Generate dependencies for all files in project
# http://stackoverflow.com/questions/2801532/make-include-directive-and-dependency-generation-with-mm
%.d: $(program_SRCS)
@ $(CC) $(CPPFLAGS) -MM $*.c | sed -e 's@^\(.*\)\.o:@\1.d \1.o:@' > $@
# add the list of dependancy files to the clean_list
clean_list += ${program_SRCS:.c=.d}
# This is the line which actually compiles your program.
$(program_NAME): $(program_OBJS)
$(LINK.c) $(program_OBJS) -o $(program_NAME)
# If you type 'make indent' this will format all your source files.
# type 'sudo apt-get install indent' at the command prompt to install indent
indent:
indent -linux -brf $(program_SRCS)
# type 'make test' to run a test.
# for example this runs your program with jackjill.txt as input
# and redirects the stdout to the file jackjill.out
test: $(program_NAME)
./$(program_NAME) test.txt > testoutput.out
ifneq "$(MAKECMDGOALS)" "clean"
# Include the list of dependancies generated for each object file
-include ${program_SRCS:.c=.d}
endif
# CC = gcc
# CFLAGS = -Wall
# # For libraries
# LDFLAGS =
# LIBS =
# OBJFILES = files/main.o files/interface.o
# # Name of program
# TARGET = pwgen
# all : $(TARGET)
# $(TARGET) : $(OBJFILES)
# $(CC) $(CFLAGS) $(LIBS) -o executables/$(TARGET) $(OBJFILES) $(LDFLAGS)
# clean :
# rm -f $(OBJFILES)
# #program:
# # clear
# # gcc files/*.c -o executables/progr
# # ./executables/progr