Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6710871
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:04:22+00:00 2026-05-26T08:04:22+00:00

I have a make file that uses pattern matching to automate compilation using a

  • 0

I have a make file that uses pattern matching to automate compilation using a rule like this:

%.o : %.c
    gcc -c $<

However in this project I have a number of source files which differ in case of their extension. Is there a way to match sets in make files like in regular expressions.

Pseudo-example:

%.o : %.[cC]
    gcc -c $<

It is not possible to simply change the case of the source files as this is used for module testing of an existing project which mixes modules from several other.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T08:04:23+00:00Added an answer on May 26, 2026 at 8:04 am

    I found the solution. It turns out that the makefile had several issues.

    First the example I posted actually works as Banthar pointed out. However my problem was that my sourcefiles weren’t in the root directory but in a src/ subdirectory which I had added to vpath. I honestly thought it was irrelevant to my question as I believed make would automatically scan its vpath for source files. Turns out vpath does not apply to rule checking.

    To make it work do:

    vpath = %.c src
    vpath = %.C src
    
    %o : src/%.[Cc]
        gcc -c $<
    

    Next as I was working through examples of how to get it done make would sometimes build sourcefiles behind my back. If you do:

    all : main.o
        gcc -o test main.o
    

    … and not have rule to build the .o file make will build it using implicit inbuild rules. Quite confusing. It can be disabled using the -r flag.

    make -r all
    

    Third compiling .C files using gcc without any extra options will result in linker errors because gcc interprets .C files as C++ files as default. In order to compiles as C files use -x flag.

    %.o : %.C
        gcc -x c -c %<
    

    Hope this helps someone.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have bat-file, that make some operations. How to run this file from Delphi
I have an htaccess file that uses mod_rewrite to redirect /controller to /index.php?controller=%controller% Like
we have some C++ code that we need to create a make file in.
I have a Makefile that looks like this CXX = g++ -O2 -Wall all:
I have a CPP source file that uses #if / #endif to compile out
I have an application that uses a properties file that was added by hand
I was wondering if theres a way to make a batch file that uses
I have a CSS file that uses CSS3 properties ( opacity and -moz-* and
Currently I have a website on my local computer that uses PHP to make
I have created a WCF service that uses windows authentication and would like to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.