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 7084431
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:18:02+00:00 2026-05-28T07:18:02+00:00

I am trying to write a makefile for compiling a program with source files

  • 0

I am trying to write a makefile for compiling a program with source files with both .f and .f90 extensions. I have the rule to compile the objects:

%.o: %.f90
       $(FC) $(FFLAGS) -c $< -o $(OBJ)/$@

How can I extend this to work with the .f files as well?

  • 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-28T07:18:03+00:00Added an answer on May 28, 2026 at 7:18 am

    You will need to have two separate rules: one for the .f files and one for the .f90 files. For example:

    TARGET := a.out
    OBJFILES := foo.f bar.f90
    OBJ := ./obj
    
    %.o: %.f90
        $(FC) $(FFLAGS) -c $< -o $(OBJ)/$@
    
    %.o: %.f
        $(FC) $(FFLAGS) -c $< -o $(OBJ)/$@
    
    %(TARGET): $(OBJFILES)
        $(FC) $(FFLAGS) -o $@ $(addprefix $(OBJ)/,$(OBJFILES))
    

    or something similar should do the trick.

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

Sidebar

Related Questions

I'm trying write a query to find records which don't have a matching record
Im trying to write something to get my images to show correctly. I have
I'm trying to compile the tetris program I wrote with C++ and SDL on
Trying to write a trivial application, But I have stuck into one of the
I'm trying to simplify/improve the Makefile for compiling my thesis. The Makefile works nicely
I'm trying to write a makefile to package up some PHP scripts. I would
I am trying to modify a Makefile, and I can't find the rule for
I'm trying to write a Ruby extension, and I've been successfully compiling my nmatrix.so
I'm trying to write a Makefile where prerequisites using target specific variables version= target1:
I'm trying to write a Makefile which should download some sources if and only

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.