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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T03:15:02+00:00 2026-06-02T03:15:02+00:00

I am trying to write a makefile for a small scale application I wrote

  • 0

I am trying to write a makefile for a small scale application I wrote in C under Linux. Currently all my source files .c are in the top level directory and all header files in
an include directory. Here is the makefile I used for this.

IDIR =include
CC=gcc
CFLAGS=-I$(IDIR)


ODIR=obj

_OBJ = main.o kernel.o user_app.o myargs.o ofp_msgs.o pkt_ip.o pkt_ether.o pkt_tcp.o pkt_udp.o pkt_icmp.o 
OBJ = $(patsubst %,$(ODIR)/%,$(_OBJ))

#DEPS = ofp_msgs.h




$(ODIR)/%.o: %.c 
    $(CC) -c -o $@ $< $(CFLAGS)            
all: jam

jam: $(OBJ)
    gcc -o $@ $^ $(CFLAGS)  -lpthread

.PHONY: clean

clean:
    rm -f $(ODIR)/*.o *~ jam 

It works fine but what I want is that for example I make a sub directory called "Packet" and all my packet parsing files i-e "pkt_ip.c, pkt_tcp.c etc" should be in that directory where as their header files should still be in the top level directory i-t "toplevel/include". I did a bit of search and the most common way was to use recursive make. Then I see a lots of pages complaining about recursive make. Can anyone please help me in this as how to do this right ?
Thanks

  • 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-06-02T03:15:05+00:00Added an answer on June 2, 2026 at 3:15 am

    there are several ways to do this but you can certainly use VPATH:=Packet to tell make to look for source files inside the ‘Packet’ directory. see make manual

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

Sidebar

Related Questions

I am trying to write a makefile for compiling a program with source files
I'm trying to write a Makefile where prerequisites using target specific variables version= target1:
I am trying to write a C++ application using the OpenCV libraries. As per
I am trying to write a Makefile for a JVM port. I have already
I'm trying to write an application using the UDP module included in the inetmanet
I'm trying to write a Linux device driver. I've got it to work really
I'm trying to write a makefile to package up some PHP scripts. I would
Hi I'm trying to get files in my res/raw folder of my android application
I'm trying to write a Makefile which should download some sources if and only
I'm trying to write a Makefile for a python script, that will create a

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.