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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T03:34:50+00:00 2026-05-27T03:34:50+00:00

I have the following makefile: CC = gcc SRC = source1.c EXE = source1

  • 0

I have the following makefile:

CC = gcc
SRC = source1.c
EXE = source1
FLAGS = -fopenmp

all: $(src)
$(CC) -o $(EXE) $(SRC) $(FLAGS)

clean:
rm $(EXE)

How can I modify it so I can use multiple sources, some of them compiled with the flag -fopenmp, some of them compiled without. Thanks a lot.

  • 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-27T03:34:50+00:00Added an answer on May 27, 2026 at 3:34 am

    This should get you started: Note how -fopenmp gets added just for source2.c

    CC=gcc
    SRC=source1.c source2.c
    OBJ=$(patsubst %.c,%.o,$(SRC))
    EXE=source1
    FLAGS= -g -O2
    
    source2.o: FLAGS+=-fopenmp
    
    all: $(EXE)
    
    $(EXE): $(OBJ)
        $(CC) -o $@ $^ $(FLAGS)
    
    %.o: %.c
        $(CC) -c -o $@ $^ $(FLAGS)
    
    clean:
        rm $(EXE)$
    

    Output of make -Bsn:

    gcc -o source1.o source1.c -g -O2
    gcc -o source2.o source2.c -g -O2 -fopenmp
    gcc -o source1 source1.o source2.o -g -O2
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following simple makefile: all: fat_imgen.exe Where fat_imgen.exe is an executable in
I have the following makefile: prog1: prog1.c gcc -o prog1.exe prog1.c prog2: prog2.c gcc
gcc 4.4.4 I have the following Makefile OBJECT_FILES = brd.o logger.o test_brd.o CFLAGS =
I have the following makefile: OUTPUTDIR = build all: v12target v13target v12target: INTDIR =
I want to just type 'make all' and have the following Makefile do everything
I have the following makefile that I use to build a program (a kernel,
I have the following makefile (fragment) SRC_DIR = src OBJ_DIR = obj DEP_DIR =
I have the following makefile for my project, and I'd like to configure it
I have the following PHONY target in Makefile install: echo /usr/bin/shelldecrypt must be writable
In a makefile, I have the following line: helper.cpp: dtds.h Which ensures that helper.cpp

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.