Reputation: 349
I'm writing a code for my gtk application written in C, and have some questions about it.
# Compiler
CC = gcc
CFLAGS = -Wall -g -o
RM = rm -f
# ADDITIONAL HEADER PATH
GTKINC = `pkg-config --cflags gtk+-3.0`
GTKLIB = `pkg-config --libs gtk+-3.0`
INC = $(GTKINC)
LIBLNK = $(GTKLIB)
# SOURCES, OBJECTS, EXECUTABLE
SRCS = hello.c
OBJS = $(SRCS:.c = .o)
EXEC = hello
.PHONY: clean
all: $(EXEC)
@echo compile complete
$(EXEC): $(OBJS)
$(CC) $(INC) $(CFLAGS) $(EXEC) $(OBJS) $(LIBLNK)
clean:
$(RM) *.o *~ $(EXEC)
previously, when I wrote Makefiles,I added lines for each object files
for example
blah blah
a.o: 1.h A.c B.c
$(CC) blah blah
blah blah
and then, I got a little lazy and tried to do make something more easy-to-modify file
googling up, and finally the product is the above code.
1. Does this actually do the same thing as what I did previously?(like in the example)
I found out the code compiles properly, but I'm not sure if it checks out-of-date
object files.(which is the whole meaning of 'make')
2. do you have to use 'depend' on header files in order to check out-of-date source files??
3. it's a bit out of subject, but what's the difference between
gcc -o hello.o hello.h hello.c and
gcc -c hello.c ?
Upvotes: 0
Views: 128
Reputation: 136256
2.
do you have to use 'depend' on header files in order to check out-of-date source files
You should auto-generate dependencies on header files. See https://stackoverflow.com/a/9598716/412080
Upvotes: 1