PROGRAM = hello_world
# Define the source files that will be distributed in the tarball
-SOURCE = *.cpp COPYING Makefile README
+SOURCE = *.c COPYING Makefile README
# Define a list of object files needed to link PROGRAM
OBJECTS = $(PROGRAM).o
# target: hello_world - compile the hello_world program
# Use GCC to link the program from object files.
$(PROGRAM): $(OBJECTS)
- $(CXX) $(LDFLAGS) -o $@ $^ $(LIBS)
+ $(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
# target: run - use the program for its intended purpose
# Here we just execute PROGRAM, but you could also use something like
# $ make CXX=/usr/local/bin/g++ CXXFLAGS=-Wall
%.o: %.cpp
$(CXX) $(CXXFLAGS) -c $<
+
+# Matching rule for compiling object files from C source
+# The comments from the C++ rule above also apply here
+%.o: %.c
+ $(CC) $(CFLAGS) -c $<