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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T20:15:23+00:00 2026-05-30T20:15:23+00:00

I am very new to Makefiles, so I am probably not doing this the

  • 0

I am very new to Makefiles, so I am probably not doing this the best way (your input is much appreciated, since I would like to learn how/why mine is bad). Anyway, here is my problem:

I have a Daemon that I wrote for a program of mine and I am trying to install it with the Makefile (target is “install”). What the “install” target is supposed to do is move the daemon binary to a location, then move the “service script” to either /etc/init.d/ or /etc/rc.d/ (since different distros have different folders…). Here is my makefile so far:

all:
        @echo "Making Components"
        @cd Daemon; make
        @echo "Components Built"
install:
        @echo "Installing Components"
        @mkdir -p /usr/lib/
        @cp Daemon/myprog_d /usr/lib/myprog_d
        -@test -d /etc/init.d && cp Scripts/myprog /etc/init.d/
        -@test -d /etc/rc.d && cp Scripts/myprog /etc/rc.d/
        -@test ! -d /etc/init.d -a ! -d /etc/rc.d && echo "  Warning: Couldn't install script. Manually install Scripts/myprog"
        @mkdir -p /var/log/
        @echo "Installed."
uninstall:
        @echo "Uninstalling Components"
        @./Scripts/myprog stop > /dev/null
        @rm -f /usr/lib/myprog_d
        @echo "Uninstall complete"
clean:
        @echo "Cleaning Components"
        @cd Daemon; make clean
        @echo "Clean complete"

As you can see, the “install” target tests to see if those two directories exist and, if they do, copies the script into them (I haven’t yet done it to “uninstall”, don’t worry).

My first question: Is this the right way to do this? The “all” and “clean” targets work (there is another makefile in “Daemon/”, as you can deduce), but I want to know if there is a cleaner way of doing this.

Secondly, because the “test” function returns non-zero, I had to do “-” before it so the error would be ignored. Unfortunately, that results in the “make install” output being:

Installing Components
make: [install] Error 1 (ignored)
make: [install] Error 1 (ignored)
Installed.

Which is very ugly and probably not good practice. What can I do in this case? (I have tried both -@ and @-, but @ will not suppress the “ignored” output)

Sincerely,
Chris

  • 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-30T20:15:25+00:00Added an answer on May 30, 2026 at 8:15 pm

    I’d do it this way:

    @if [ -d /etc/init.d ]; then cp Scripts/myprog /etc/init.d/ ; fi
    @if [ -d /etc/rc.d ]; then cp Scripts/myprog /etc/rc.d/ ; fi
    

    And I’m a little confused by your next line (-@test ! -d /etc/init.d -a !...) but you can probably do it the same way.

    That takes care of the error messages, but if you wanted to keep the makefile as it is, you could suppress them by running make -s.

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

Sidebar

Related Questions

Im very new to mysql, and any help would be much appreciated! I have
Very new to jQuery, if dupe question sorry at this point not even sure
I'm new to make and makefiles, so forgive me if this is very basic.
Very new to python and can't understand why this isn't working. I have a
Im very new in C++ I have found this post http://msdn.microsoft.com/en-us/magazine/cc163486.aspx and trying to
Very new to Objective-C and Xcode and working my way through modifying the DrillDownApp
Very new to this, and I have no idea where to start. I want
im very new to jquery/javascript. So here goes, I found this js code for
To preface: I am very new to C, so I am probably missing something
I'm very new to makefiles. I'm reading the GNU-make manual, but I'm still unclear

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.