Since you’re using GNUmake, use a pattern rule for compiling object files:
$(OBJDIR)/%.o: %.c
$(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<
More Related Contents:
- What is the difference between the GNU Makefile variable assignments =, ?=, := and +=?
- Recursive wildcards in GNU make?
- Define make variable at rule execution time
- What do @, – and + do as prefixes to recipe lines in Make?
- Getting make to create object files in a specific directory
- How do you get the list of targets in a makefile?
- Difference between CPPFLAGS and CXXFLAGS in GNU Make
- How to get current relative directory of your Makefile?
- Why .SECONDARY does not work with patterns (%) while .PRECIOUS does?
- Building C-program “out of source tree” with GNU make
- How do I write the ‘cd’ command in a makefile?
- How can I configure my makefile for debug and release builds?
- Run make in each subdirectory
- Wildcard targets in a Makefile
- Suppress make rule error output
- How to print out a variable in makefile
- What does @: (at symbol colon) mean in a Makefile?
- Force gnu make to rebuild objects affected by compiler definition
- Make error: missing separator
- Passing additional variables from command line to make
- How to install and use “make” in Windows?
- Make: how to continue after a command fails?
- Create directories using make file
- Best practice for building a make file
- What are Makefile.am and Makefile.in?
- make *** no targets specified and no makefile found. stop
- Makefile ifeq logical or
- CMAKE_MAKE_PROGRAM not found
- Makefile header dependencies
- @ prefix when setting environment variable in Makefile